Parcourir la source

连线及拖拽填空bug解决

qinpeng il y a 2 ans
Parent
commit
9c26c02187

+ 25 - 12
src/components/Adult/preview/Ligature.vue

@@ -287,6 +287,18 @@ export default {
             }
           }
         } else {
+          this.curQue.con.forEach((itemss) => {
+            if (
+              Object.prototype.toString
+                .call(itemss.AnswerList)
+                .indexOf("Number") != -1
+            ) {
+              if (itemss.AnswerList == index) {
+                clss = "error";
+              }
+            }
+          });
+
           for (let i = 0; i < this.data.data.length; i++) {
             let dItems = this.data.data[i];
             if (item.nodeId == dItems.target) {
@@ -377,11 +389,13 @@ export default {
         DrapOptions: { cursor: "crosshair", zIndex: 2000 },
       });
       this.jsPlumb.batch(() => {
-        for (let i = 0; i < this.curQue.con.length; i++) {
-          this.initLeaf(this.curQue.con[i].nodeId, "source");
-        }
-        for (let j = 0; j < this.curQue.option.length; j++) {
-          this.initLeaf(this.curQue.option[j].nodeId, "target");
+        if (!this.TaskModel || this.TaskModel != "ANSWER") {
+          for (let i = 0; i < this.curQue.con.length; i++) {
+            this.initLeaf(this.curQue.con[i].nodeId, "source");
+          }
+          for (let j = 0; j < this.curQue.option.length; j++) {
+            this.initLeaf(this.curQue.option[j].nodeId, "target");
+          }
         }
       });
       this.setjsPlumb(true, true);
@@ -413,10 +427,9 @@ export default {
           );
         }
       });
-
-      //连线时触发
-      this.jsPlumb.bind("connection", (conn, originalEvent) => {
-        if (!this.TaskModel || this.TaskModel != "ANSWER") {
+      if (this.TaskModel != "ANSWER") {
+        //连线时触发
+        this.jsPlumb.bind("connection", (conn, originalEvent) => {
           let fig = false;
           this.data.data.forEach((item) => {
             if (item.source == conn.sourceId && item.target == conn.targetId) {
@@ -438,8 +451,8 @@ export default {
               JSON.parse(JSON.stringify(this.data))
             );
           }
-        }
-      });
+        });
+      }
 
       //右键触发
       this.jsPlumb.bind("contextmenu", (conn, originalEvent) => {
@@ -694,7 +707,7 @@ export default {
           });
         } else {
           this.data.data.push({
-            source: item.nodeId,
+            source: null,
             target: null,
             Isexample: item.Isexample,
           });

+ 76 - 15
src/components/Adult/preview/SelectDrag.vue

@@ -49,7 +49,7 @@
           ? CorrectData.sentences
           : curQue.sentences"
         :key="`sentence-${i}`"
-        :data-serial="i + 1"
+        :data-serial="judgeAnswer == 'standardAnswer' ? changeNumber(i) : i + 1"
         class="drag-sentence"
       >
         <span
@@ -175,6 +175,28 @@ export default {
       if (this.judgeAnswer == "userAnswer") {
       } else if (this.judgeAnswer == "standardAnswer") {
         let data = JSON.parse(JSON.stringify(this.curQue));
+        let arr = [];
+        data.sentences.forEach((item, index) => {
+          let flag = false;
+          item.forEach((items, indexs) => {
+            if (items.isSpace) {
+              if (
+                this.curQue.Bookanswer.answerList[index][items.index]
+                  .userAnswerJudge == "[JUDGE##F##JUDGE]"
+              ) {
+                if (!flag) {
+                  flag = true;
+                }
+              }
+            }
+          });
+          arr.push(flag);
+        });
+        arr.forEach((item, index) => {
+          if (!item) {
+            data.sentences.splice(index, 1);
+          }
+        });
         data.sentences.forEach((item, index) => {
           item.forEach((items, indexs) => {
             if (items.isSpace) {
@@ -221,6 +243,37 @@ export default {
     }
   },
   methods: {
+    // 计算序号
+    changeNumber(i) {
+      let index = null;
+      this.curQue.sentences.forEach((item, indexs) => {
+        let flag = true;
+        if (this.CorrectData.sentences[i].length == item.length) {
+          item.forEach((items, indexss) => {
+            if (items.isSpace) {
+              if (
+                this.CorrectData.sentences[i][indexss].answer != items.answer
+              ) {
+                flag = false;
+              }
+            } else {
+              if (
+                this.CorrectData.sentences[i][indexss].sentence !=
+                items.sentence
+              ) {
+                flag = false;
+              }
+            }
+          });
+        } else {
+          flag = false;
+        }
+        if (flag) {
+          index = indexs;
+        }
+      });
+      return index + 1;
+    },
     changeClass(index, indexs, indexss) {
       let className = "";
       if (Object.prototype.toString.call(index).indexOf("Number") != -1) {
@@ -244,13 +297,14 @@ export default {
           }
         } else if (this.judgeAnswer == "standardAnswer") {
           if (this.CorrectData.sentences[index][indexss].isSpace) {
-            if (this.CorrectData.sentences[index][indexss].dragList.length > 0) {
+            if (
+              this.CorrectData.sentences[index][indexss].dragList.length > 0
+            ) {
               className = "correct";
             }
           }
         }
       }
-
       return className;
     },
     onMove(e) {
@@ -300,20 +354,27 @@ export default {
     },
     // 判断对错
     changeuserAnswerJudge() {
-      this.curQue.Bookanswer.answerList.forEach((item, index) => {
+      this.curQue.sentences.forEach((item, index) => {
         item.forEach((items, indexs) => {
-          if (items.answer) {
-            if (this.curQue.Bookanswer.dragList[index][indexs]) {
-              if (
-                items.answer ==
-                this.curQue.Bookanswer.dragList[index][indexs].sentence
-              ) {
-                items.userAnswerJudge = "[JUDGE##T##JUDGE]";
-              } else {
-                items.userAnswerJudge = "[JUDGE##F##JUDGE]";
+          if (items.isSpace) {
+            if (items.answer) {
+              if (items.dragList) {
+                if (items.dragList.length > 0) {
+                  if (items.answer == items.dragList[0].sentence) {
+                    this.curQue.Bookanswer.answerList[index][
+                      items.index
+                    ].userAnswerJudge = "[JUDGE##T##JUDGE]";
+                  } else {
+                    this.curQue.Bookanswer.answerList[index][
+                      items.index
+                    ].userAnswerJudge = "[JUDGE##F##JUDGE]";
+                  }
+                } else {
+                  this.curQue.Bookanswer.answerList[index][
+                    items.index
+                  ].userAnswerJudge = "[JUDGE##F##JUDGE]";
+                }
               }
-            } else {
-              items.userAnswerJudge = "[JUDGE##F##JUDGE]";
             }
           }
         });