Browse Source

涛修改

aaa 3 years ago
parent
commit
85331d47f0

+ 32 - 12
src/views/home/answer/page-answer-recruit.vue

@@ -513,24 +513,44 @@ export default {
       // return isSure;
       let isSure = false;
       let lastAnswer = [""];
-      lastAnswer[0] = this.getUserAnswerSortFun(item);
-      if (lastAnswer[0] === item.finalAnswer[0]) {
-        isSure = true;
+      lastAnswer = this.getUserAnswerSortFun(item);
+      console.log(lastAnswer);
+      for (let i = 0; i < item.finalAnswer.length; i++) {
+        if (lastAnswer[i] && lastAnswer[i] === item.finalAnswer[i]) {
+          isSure = true;
+        } else {
+          isSure = false;
+          break;
+        }
       }
       return isSure;
     },
     // 获取用户所选选项的升序编号答案
     getUserAnswerSortFun(item) {
       let newUnserAnswer = [];
-      item.answers.forEach((itemOne, indexOne) => {
-        item.userAnswer.forEach(itemTwo => {
-          if (itemOne === itemTwo) {
-            newUnserAnswer.push(this.formatQuestionIndex(indexOne));
-          }
-        });
-      });
-      newUnserAnswer.sort();
-      return newUnserAnswer.join("");
+      switch (item.type) {
+        case this.questionType.singleChoice:
+        case this.questionType.multipleChoice:
+        case this.questionType.TrueOrFalse:
+          let arr = [];
+          item.answers.forEach((itemOne, indexOne) => {
+            item.userAnswer.forEach(itemTwo => {
+              if (itemOne === itemTwo) {
+                arr.push(this.formatQuestionIndex(indexOne));
+              }
+            });
+          });
+          arr = arr.sort();
+          newUnserAnswer = [arr.join("")];
+          break;
+        case this.questionType.gapFilling:
+          newUnserAnswer = item.answers;
+          break;
+        default:
+          break;
+      }
+      // return newUnserAnswer.join("");
+      return newUnserAnswer;
     },
     // 操作:下一题
     handleNextFun() {

+ 36 - 13
src/views/home/exam/page-exam-item-doing.vue

@@ -588,26 +588,49 @@ export default {
     getAnswerItemResultFun(item) {
       let isSure = false;
       let lastAnswer = [""];
-      lastAnswer[0] = this.getUserAnswerSortFun(item);
-      if (lastAnswer[0] === item.finalAnswer[0]) {
-        isSure = true;
+    //   lastAnswer[0] = this.getUserAnswerSortFun(item);
+    //   if (lastAnswer[0] === item.finalAnswer[0]) {
+    //     isSure = true;
+    //   }
+      lastAnswer = this.getUserAnswerSortFun(item);
+      for (let i = 0; i < item.finalAnswer.length; i++) {
+        if (lastAnswer[i] && lastAnswer[i] === item.finalAnswer[i]) {
+          isSure = true;
+        } else {
+          isSure = false;
+          break;
+        }
       }
       return isSure;
     },
     // 获取用户所选选项的升序编号答案
     getUserAnswerSortFun(item) {
       let newUnserAnswer = [];
-      item.answers.forEach((itemOne, indexOne) => {
-        item.userAnswer.forEach(itemTwo => {
-          if (itemOne === itemTwo) {
-            newUnserAnswer.push(this.formatQuestionIndex(indexOne));
-          }
-        });
-      });
-      newUnserAnswer.sort();
-      return newUnserAnswer.join("");
+      switch (item.type) {
+        case this.questionType.singleChoice:
+        case this.questionType.multipleChoice:
+        case this.questionType.TrueOrFalse:
+          let arr = [];
+          item.answers.forEach((itemOne, indexOne) => {
+            item.userAnswer.forEach(itemTwo => {
+              if (itemOne === itemTwo) {
+                arr.push(this.formatQuestionIndex(indexOne));
+              }
+            });
+          });
+          arr = arr.sort();
+          newUnserAnswer = [arr.join("")];
+          break;
+        case this.questionType.gapFilling:
+          newUnserAnswer = item.answers;
+          break;
+        default:
+          break;
+      }
+      // return newUnserAnswer.join("");
+      return newUnserAnswer;
     },
-    // 方法:获取题目的答案
+    // 方法:获取用户的作答
     getUserExamAllAnswersFun() {
       let answers = [];
       this.examQuestionList.forEach((item, index) => {