Просмотр исходного кода

Merge branch 'master' into gcj

# Conflicts:
#	src/views/courseView.vue
gcj 2 лет назад
Родитель
Сommit
b88c8bad33

+ 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() {

+ 7 - 25
src/components/Adult/preview/SelectTone.vue

@@ -1,21 +1,7 @@
 <!--  -->
 <template>
   <div class="Big-Book-prev-Textdes SelectTone" v-if="isShowTemp">
-    <h6
-      v-if="judgeAnswer == 'userAnswer' || judgeAnswer == 'studentAnswer'"
-      class="standardTitle"
-      style="margin: 10px 0 8px 24px"
-    >
-      {{ judgeAnswer == "userAnswer" ? "Your answer" : "Student answers" }}
-    </h6>
-    <h6
-      v-else-if="judgeAnswer == 'standardAnswer'"
-      class="standardTitle"
-      style="margin: 10px  0 8px 24px"
-    >
-      Standard answer
-    </h6>
-
+    <AnswerTitle :judgeAnswer="judgeAnswer" />
     <div
       class="aduioLine-box"
       v-if="
@@ -35,13 +21,8 @@
       />
     </div>
     <ul>
-      <li
-        v-for="(item, index) in curQue.option"
-        :key="index"
-        v-if="isShowOption(item, index)"
-      >
-        <!-- {{ judgeAnswer == "standardAnswer" && !item.answer }} 不显示 -->
-        <template>
+      <li v-for="(item, index) in curQue.option" :key="index">
+        <div v-if="isShowOption(item, index)">
           <a
             v-if="curQue.wordTime && curQue.wordTime.length > 0"
             :class="[
@@ -68,7 +49,7 @@
           >
             <img :src="itmes" />
           </a>
-        </template>
+        </div>
       </li>
     </ul>
   </div>
@@ -77,9 +58,10 @@
 <script>
 import Audio from "../preview/components/AudioRed.vue"; // 音频播放
 import AudioLine from "../preview/AudioLine.vue";
+import AnswerTitle from "../preview/components/AnswerTitle.vue";
 
 export default {
-  components: { Audio, AudioLine },
+  components: { Audio, AudioLine, AnswerTitle },
   props: ["curQue", "themeColor", "TaskModel", "judgeAnswer"],
   data() {
     return {
@@ -292,7 +274,7 @@ export default {
     align-items: flex-start;
     padding: 24px 12px;
 
-    li {
+    div {
       width: 363px;
       background: #ffffff;
       border: 1px solid rgba(0, 0, 0, 0.1);

+ 200 - 63
src/components/Adult/preview/SelectYinjie.vue

@@ -1,9 +1,9 @@
 <!--  -->
 <template>
-  <div
-    class="Big-Book-prev-Textdes SelectYinjie"
-    v-if="curQue && curQue.Bookanswer"
-  >
+  <div class="Big-Book-prev-Textdes SelectYinjie" v-if="isShowTemp">
+    <div>
+      <AnswerTitle :judgeAnswer="judgeAnswer" />
+    </div>
     <div
       class="aduioLine-box"
       v-if="
@@ -22,53 +22,61 @@
         @handleListenRead="handleListenRead"
       />
     </div>
-    <div class="item-box" v-for="(item, index) in curQue.option" :key="index">
-      <a
-        v-if="curQue.wordTime && curQue.wordTime.length > 0"
-        :class="[
-          'play-btn',
-          curTime >= curQue.wordTime[index].bg &&
-          curTime < curQue.wordTime[index].ed &&
-          stopAudio
-            ? 'active'
-            : '',
-        ]"
-        @click="
-          handleChangeTime(curQue.wordTime[index].bg, curQue.wordTime[index].ed)
-        "
-      ></a>
-      <b v-if="item.number">{{ item.number }}</b>
-      <div class="zijie-box">
-        <p
+    <div v-for="(item, index) in curQue.option" :key="index">
+      <div class="item-box" v-if="isShowOption(item, index)">
+        <a
+          v-if="curQue.wordTime && curQue.wordTime.length > 0"
+          :class="[
+            'play-btn',
+            curTime >= curQue.wordTime[index].bg &&
+            curTime < curQue.wordTime[index].ed &&
+            stopAudio
+              ? 'active'
+              : '',
+          ]"
+          @click="
+            handleChangeTime(
+              curQue.wordTime[index].bg,
+              curQue.wordTime[index].ed
+            )
+          "
+        ></a>
+        <b v-if="item.number">{{ item.number }}</b>
+        <div class="zijie-box">
+          <p
+            :class="[
+              !judgeAnswer ? 'exercise-model' : '',
+              lookanswerClass(index, indexs),
+            ]"
+            v-for="(items, indexs) in item.option"
+            :key="indexs"
+            @click="handleClick(index, indexs)"
+          >
+            {{ items.pinyin }}
+          </p>
+        </div>
+        <a
+          v-if="!judgeAnswer"
           :class="[
-            curQue.Bookanswer[index].indexOf(indexs) > -1 ? 'active' : '',
+            'clear-btn',
+            curQue.Bookanswer[index].length > 0 && TaskModel != 'ANSWER'
+              ? 'active'
+              : '',
+            TaskModel == 'ANSWER' ? 'notAllow' : '',
           ]"
-          v-for="(items, indexs) in item.option"
-          :key="indexs"
-          @click="handleClick(index, indexs)"
-        >
-          {{ items.pinyin }}
-        </p>
+          @click="handleClear(index)"
+        ></a>
       </div>
-      <a
-        :class="[
-          'clear-btn',
-          curQue.Bookanswer[index].length > 0 && TaskModel != 'ANSWER'
-            ? 'active'
-            : '',
-          TaskModel == 'ANSWER' ? 'notAllow' : '',
-        ]"
-        @click="handleClear(index)"
-      ></a>
     </div>
   </div>
 </template>
 
 <script>
 import AudioLine from "../preview/AudioLine.vue";
+import AnswerTitle from "../preview/components/AnswerTitle.vue";
 
 export default {
-  components: { AudioLine },
+  components: { AudioLine, AnswerTitle },
   props: ["curQue", "themeColor", "TaskModel", "judgeAnswer"],
   data() {
     return {
@@ -78,34 +86,152 @@ export default {
       ed: null,
     };
   },
-  computed: {},
+  computed: {
+    lookanswerClass() {
+      return function (index, indexs) {
+        let _this = this;
+        let className = "";
+        let userAnswer = this.curQue.Bookanswer[index].value.toString();
+        if (this.curQue.option[index].answer) {
+          let answer = (this.curQue.option[index].answer - 1).toString();
+          if (_this.judgeAnswer == "standardAnswer") {
+            if (indexs.toString() === answer) {
+              className = "userRight";
+            } else {
+              className = "";
+            }
+          } else if (
+            _this.judgeAnswer == "userAnswer" ||
+            _this.judgeAnswer == "studentAnswer"
+          ) {
+            if (indexs.toString() === userAnswer) {
+              if (answer === userAnswer) {
+                className = "userRight";
+              } else {
+                className = "userError";
+              }
+            } else {
+              className = "";
+            }
+          }
+        }
+
+        if (!_this.judgeAnswer && userAnswer == indexs.toString()) {
+          className = "active";
+        }
+
+        return className;
+      };
+    },
+    isShowTemp() {
+      let _this = this;
+      let bool = false;
+      if (_this.curQue && _this.curQue.Bookanswer) {
+        if (_this.judgeAnswer == "standardAnswer") {
+          if (_this.userErrorNumberTotal > 0) {
+            bool = true;
+          } else {
+            bool = false;
+          }
+        } else {
+          bool = true;
+        }
+      }
+
+      return bool;
+    },
+    isShowOption() {
+      return function (item, index) {
+        let _this = this;
+        let bool = true;
+        if (_this.judgeAnswer == "standardAnswer") {
+          if (!item.answer) {
+            bool = false;
+          } else if (
+            _this.curQue.Bookanswer[index].userAnswerJudge ==
+            "[JUDGE##T##JUDGE]"
+          ) {
+            bool = false;
+          }
+        }
+        return bool;
+      };
+    },
+  },
   watch: {},
   //方法集合
   methods: {
+    // 处理数据
     handleData() {
-      let userList = [];
-      this.curQue.option.forEach((item) => {
-        userList.push([]);
+      let _this = this;
+      let option = JSON.parse(JSON.stringify(_this.curQue.option));
+      option.forEach((item, index) => {
+        item.answer = null;
+        for (let i = 0; i < item.option.length; i++) {
+          let oItem = item.option[i];
+          if (oItem.isAnswer) {
+            item.answer = i + 1;
+            break;
+          }
+        }
       });
-      if (!this.curQue.Bookanswer) {
-        this.$set(this.curQue, "Bookanswer", userList);
+      _this.$set(_this.curQue, "option", JSON.parse(JSON.stringify(option)));
+      if (!_this.curQue.Bookanswer) {
+        let userSelect = [];
+        _this.curQue.option.forEach((item) => {
+          let obj = {
+            value: "",
+            userAnswerJudge: item.answer ? "[JUDGE##F##JUDGE]" : "",
+          };
+          userSelect.push(JSON.parse(JSON.stringify(obj)));
+        });
+        _this.$set(this.curQue, "Bookanswer", userSelect);
+      } else {
+        let BookanswerStr = JSON.stringify(_this.curQue.Bookanswer);
+        let errReg = /\[JUDGE##F##JUDGE\]/g;
+        if (errReg.test(BookanswerStr)) {
+          let errorArr = BookanswerStr.match(/\[JUDGE##F##JUDGE\]/g);
+          _this.userErrorNumberTotal = errorArr.length;
+        }
       }
     },
     handleClick(index, indexs) {
-      if (!this.TaskModel || this.TaskModel != "ANSWER") {
-        if (this.curQue.Bookanswer[index].indexOf(indexs) > -1) {
-          this.curQue.Bookanswer[index].splice(
-            this.curQue.Bookanswer[index].indexOf(indexs),
-            1
-          );
-        } else {
-          // this.userList[index].push(indexs);
-          this.$set(this.curQue.Bookanswer, index, [indexs]);
+      let _this = this;
+      if (
+        !_this.TaskModel ||
+        _this.TaskModel != "ANSWER" ||
+        !_this.judgeAnswer
+      ) {
+        _this.$set(_this.curQue.Bookanswer[index], "value", indexs);
+        if (_this.curQue.option[index].answer) {
+          let answer = _this.curQue.option[index].answer - 1;
+          if (indexs.toString() === answer.toString()) {
+            _this.$set(
+              _this.curQue.Bookanswer[index],
+              "userAnswerJudge",
+              "[JUDGE##T##JUDGE]"
+            );
+          } else {
+            _this.$set(
+              _this.curQue.Bookanswer[index],
+              "userAnswerJudge",
+              "[JUDGE##F##JUDGE]"
+            );
+          }
         }
       }
     },
     handleClear(index) {
-      this.$set(this.curQue.Bookanswer, index, []);
+      let _this = this;
+      _this.$set(_this.curQue.Bookanswer[index], "value", "");
+      let userAnswerJudge = _this.curQue.option[index].answer
+        ? "[JUDGE##F##JUDGE]"
+        : "";
+      _this.$set(
+        _this.curQue.Bookanswer[index],
+        "userAnswerJudge",
+        userAnswerJudge
+      );
     },
     getCurTime(curTime) {
       this.curTime = curTime * 1000;
@@ -204,13 +330,7 @@ export default {
         cursor: pointer;
         font-family: "GB-PINYINOK-B";
         overflow: hidden;
-        &:hover {
-          background: rgba(0, 0, 0, 0.05)
-            url("../../../assets/NPC/selectYinjie-hover.png") right bottom
-            no-repeat;
-          background-size: 11px;
-          border: 1px solid rgba(0, 0, 0, 0.1);
-        }
+
         &.active {
           background: rgba(0, 188, 75, 0.05)
             url("../../../assets/NPC/selectYinjie-active.png") right bottom
@@ -218,6 +338,23 @@ export default {
           background-size: 11px;
           border: 1px solid #00bc4b;
         }
+        &.userRight {
+          background: rgba(44, 167, 103, 0.1);
+          border-color: #2ca767;
+        }
+        &.userError {
+          background: rgba(237, 52, 45, 0.1);
+          border-color: #ed342d;
+        }
+      }
+      .exercise-model {
+        &:hover {
+          background: rgba(0, 0, 0, 0.05)
+            url("../../../assets/NPC/selectYinjie-hover.png") right bottom
+            no-repeat;
+          background-size: 11px;
+          border: 1px solid rgba(0, 0, 0, 0.1);
+        }
       }
     }
     .clear-btn {

+ 50 - 0
src/components/Adult/preview/components/AnswerTitle.vue

@@ -0,0 +1,50 @@
+<!--  -->
+<template>
+  <div class="answer-title">
+    <h6
+      v-if="judgeAnswer == 'userAnswer' || judgeAnswer == 'studentAnswer'"
+      class="standardTitle"
+    >
+      {{ judgeAnswer == "userAnswer" ? "Your answer" : "Student answers" }}
+    </h6>
+    <h6 v-else-if="judgeAnswer == 'standardAnswer'" class="standardTitle">
+      Standard answer
+    </h6>
+  </div>
+</template>
+
+<script>
+export default {
+  components: {},
+  props: ["judgeAnswer"],
+  data() {
+    return {};
+  },
+  computed: {},
+  watch: {},
+  //方法集合
+  methods: {},
+  //生命周期 - 创建完成(可以访问当前this实例)
+  created() {},
+  //生命周期 - 挂载完成(可以访问DOM元素)
+  mounted() {},
+  beforeCreate() {}, //生命周期 - 创建之前
+  beforeMount() {}, //生命周期 - 挂载之前
+  beforeUpdate() {}, //生命周期 - 更新之前
+  updated() {}, //生命周期 - 更新之后
+  beforeDestroy() {}, //生命周期 - 销毁之前
+  destroyed() {}, //生命周期 - 销毁完成
+  activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
+};
+</script>
+<style lang='scss' scoped>
+//@import url(); 引入公共css类
+.standardTitle {
+  font-weight: 510;
+  font-size: 16px;
+  line-height: 150%;
+  color: #cc5e20;
+  margin: 0;
+  margin-bottom: 16px;
+}
+</style>

+ 2 - 1
src/views/courseView.vue

@@ -109,7 +109,8 @@ export default {
           ],
         },
       ],
-      bookAnswerContent:"",
+      bookAnswerContent:
+        '[{"table_list":[[{"data":{"Bookanswer":[{"value":0,"userAnswerJudge":"[JUDGE##F##JUDGE]"},{"value":1,"userAnswerJudge":""},{"value":0,"userAnswerJudge":"[JUDGE##T##JUDGE]"}]}}]]}]',
       TaskModel: "", // TEST 考试模式; PRACTICE 练习模式; ANSWER 查看答案模式; 空 预览模式
       category: "",
       FatherTreeData: null,