Browse Source

输入+录音和连线userAnswerJudge的添加。

qinpeng 2 years ago
parent
commit
db1339c175

+ 35 - 12
src/components/Adult/preview/InputHasRecord.vue

@@ -81,7 +81,8 @@
                                 ? 'noFont'
                                 : '',
                             ]"
-                            >{{ itemCon.pinyin }}</span>
+                            >{{ itemCon.pinyin }}</span
+                          >
                         </div>
                         <div style="text-align: left">
                           <span
@@ -148,7 +149,8 @@
                 v-model="curQue.Bookanswer[indexs].answer"
                 placeholder="输入"
                 maxlength="200"
-                :readonly="TaskModel=='ANSWER'"
+                :readonly="TaskModel == 'ANSWER'"
+                @change="changeuserAnswerJudge(indexs)"
               ></el-input>
               <div v-if="items.record" class="luyin-inner">
                 <Soundrecord
@@ -276,7 +278,8 @@
             v-model="curQue.Bookanswer[indexs].answer"
             placeholder="输入"
             maxlength="200"
-            :readonly="TaskModel=='ANSWER'"
+            :readonly="TaskModel == 'ANSWER'"
+            @change="changeuserAnswerJudge(indexs)"
           ></el-input>
           <div v-if="items.record" class="luyin-inner">
             <Soundrecord
@@ -298,23 +301,42 @@
 import Soundrecord from "../preview/Soundrecord.vue"; // 录音模板
 export default {
   components: { Soundrecord },
-  props: ["curQue","TaskModel"],
+  props: ["curQue", "TaskModel"],
   data() {
     return {
       wordShow: true,
       textareaCon: "", // 输入框
       chsFhList: [",", "。", "“", ":", "》", "《", "?", "!", ";"],
       noFont: ["~", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")"], // 对应不要拼音字体
-      answerArr:[]
+      answerArr: [],
     };
   },
   computed: {},
   watch: {},
   //方法集合
   methods: {
+    changeuserAnswerJudge(index) {
+      let _this = this;
+      if (
+        _this.curQue.option[index].answer ==
+        _this.curQue.Bookanswer[index].answer.trim()
+      ) {
+        _this.$set(
+          _this.curQue.Bookanswer[index],
+          "userAnswerJudge",
+          "[JUDGE##T##JUDGE]"
+        );
+      } else {
+        _this.$set(
+          _this.curQue.Bookanswer[index],
+          "userAnswerJudge",
+          "[JUDGE##F##JUDGE]"
+        );
+      }
+    },
     handleWav(list, tmIndex) {
-        tmIndex = tmIndex ? tmIndex : 0;
-        this.$set(this.curQue.Bookanswer[tmIndex], "recordList", list);
+      tmIndex = tmIndex ? tmIndex : 0;
+      this.$set(this.curQue.Bookanswer[tmIndex], "recordList", list);
     },
     // 处理数据
     handleData() {
@@ -323,9 +345,10 @@ export default {
       let curQue = JSON.parse(JSON.stringify(this.curQue));
       curQue.option.forEach((dItem, dIndex) => {
         curCorrect.push({
-            answer: "",
-            recordList: [],
-          });
+          answer: "",
+          recordList: [],
+          userAnswerJudge: dItem.answer ? "[JUDGE##F##JUDGE]" : "",
+        });
         let paraArr = [];
         dItem.detail.wordsList.forEach((sItem, sIndex) => {
           this.mergeWordSymbol(dItem.detail.wordsList, sItem, sIndex);
@@ -339,14 +362,14 @@ export default {
         this.$set(_this.curQue.option[dIndex].detail, "resArr", paraArr);
       });
       if (!this.curQue.Bookanswer) {
-          this.$set(this.curQue, "Bookanswer", curCorrect);
+        this.$set(this.curQue, "Bookanswer", curCorrect);
       }
     },
     //词和标点合一起
     mergeWordSymbol(sItem, wItem, curIndex) {
       let leg = sItem.length;
       if (curIndex < leg - 1) {
-        if (this.chsFhList.indexOf(wItem.chs) > -1&&curIndex!=0) {
+        if (this.chsFhList.indexOf(wItem.chs) > -1 && curIndex != 0) {
           wItem.isShow = false;
         } else {
           wItem.isShow = true;

+ 90 - 21
src/components/Adult/preview/Ligature.vue

@@ -281,24 +281,33 @@ export default {
     //   清除所有连线
     clearLine() {
       if (!this.TaskModel || this.TaskModel != "ANSWER") {
-        let arr = [];
         this.data.forEach((item) => {
-          if (item.source.indexOf("Isexample") != -1) {
-            arr.push(item);
+          if (item.source) {
+            if (item.source.indexOf("Isexample") == -1) {
+              item.source = null;
+              item.target = null;
+              if (
+                Object.prototype.toString.call(item.answer).indexOf("Number") !=
+                -1
+              ) {
+                item.userAnswerJudge = "[JUDGE##F##JUDGE]";
+              }
+            }
           }
         });
         this.jsPlumb.deleteEveryConnection(); //清除连线方法
-        this.data = [];
-        this.$set(this.curQue, "Bookanswer", JSON.stringify(this.data));
-        if (arr.length > 0) {
-          this.data = JSON.parse(JSON.stringify(arr));
-          this.data.forEach((item) => {
-            this.jsPlumb.connect({
-              source: item.source,
-              target: item.target,
-            });
+        this.$set(
+          this.curQue,
+          "Bookanswer",
+          JSON.parse(JSON.stringify(this.data))
+        );
+
+        this.data.forEach((item) => {
+          this.jsPlumb.connect({
+            source: item.source,
+            target: item.target,
           });
-        }
+        });
       }
     },
     showPlumb() {
@@ -355,15 +364,27 @@ export default {
         }
         if (!this.TaskModel || this.TaskModel != "ANSWER") {
           // 删除点击的线
-          this.data.forEach((item, i) => {
-            if (item.source == conn.sourceId) {
-              this.data.splice(i, 1);
+          this.curQue.con.forEach((item, i) => {
+            if (item.nodeId == conn.sourceId) {
+              this.$set(this.data[i], "source", null);
+              this.$set(this.data[i], "target", null);
+              if (
+                Object.prototype.toString
+                  .call(item.AnswerList)
+                  .indexOf("Number") != -1
+              ) {
+                this.$set(this.data[i], "userAnswerJudge", "[JUDGE##F##JUDGE]");
+              }
             }
           });
           let node = document.getElementById(conn.sourceId);
           this.jsPlumb.removeAllEndpoints(node);
           sessionStorage.setItem("LineData", JSON.stringify(this.data));
-          this.$set(this.curQue, "Bookanswer", JSON.stringify(this.data));
+          this.$set(
+            this.curQue,
+            "Bookanswer",
+            JSON.parse(JSON.stringify(this.data))
+          );
         }
       });
 
@@ -377,12 +398,43 @@ export default {
             }
           });
           if (!fig) {
-            this.data.push({
-              source: conn.sourceId,
-              target: conn.targetId,
+            this.curQue.con.forEach((item, i) => {
+              if (conn.sourceId == item.nodeId) {
+                this.$set(this.data[i], "source", conn.sourceId);
+                this.$set(this.data[i], "target", conn.targetId);
+                if (
+                  Object.prototype.toString
+                    .call(item.AnswerList)
+                    .indexOf("Number") != -1
+                ) {
+                  if (
+                    conn.targetId == this.curQue.option[item.AnswerList].nodeId
+                  ) {
+                    this.$set(
+                      this.data[i],
+                      "userAnswerJudge",
+                      "[JUDGE##T##JUDGE]"
+                    );
+                  } else {
+                    this.$set(
+                      this.data[i],
+                      "userAnswerJudge",
+                      "[JUDGE##F##JUDGE]"
+                    );
+                  }
+                }
+              }
             });
+            // this.data.push({
+            //   source: conn.sourceId,
+            //   target: conn.targetId,
+            // });
             sessionStorage.setItem("LineData", JSON.stringify(this.data));
-            this.$set(this.curQue, "Bookanswer", JSON.stringify(this.data));
+            this.$set(
+              this.curQue,
+              "Bookanswer",
+              JSON.parse(JSON.stringify(this.data))
+            );
           }
         }
       });
@@ -463,10 +515,12 @@ export default {
       }
       if (item.Isexample) {
         this.data.push({
+          id: item.nodeId,
           source: item.nodeId,
           target: "right_" + item.AnswerList + this.number,
           index: i,
           answer: item.AnswerList,
+          userAnswerJudge: "",
         });
       }
     });
@@ -479,6 +533,21 @@ export default {
         this.allimgnumber++;
       }
     });
+    this.curQue.con.forEach((item, i) => {
+      if (!item.Isexample) {
+        this.data.push({
+          answer: item.AnswerList,
+          index: i,
+          source: null,
+          target: null,
+          userAnswerJudge:
+            Object.prototype.toString.call(item.AnswerList).indexOf("Number") ==
+            -1
+              ? ""
+              : "[JUDGE##F##JUDGE]",
+        });
+      }
+    });
   },
   //生命周期 - 挂载完成(可以访问DOM元素)
   mounted() {