Browse Source

练习设置不显示答案。

Michael Wang 6 years ago
parent
commit
99ec66931e
1 changed files with 42 additions and 9 deletions
  1. 42 9
      src/features/OnlineExam/Examing/ExamPaper.vue

+ 42 - 9
src/features/OnlineExam/Examing/ExamPaper.vue

@@ -18,9 +18,9 @@
               </div>
               </div>
             </div>
             </div>
 
 
-            <div class="flex">正确答案:<div v-html="rightAnswerToABCD(questionUnit.questionType, questionUnit.rightAnswer, questionWrapper.eqs[index].optionPermutation)"></div>
+            <div class="flex" v-if="practiceType !== 'NO_ANSWER'">正确答案:<div v-html="rightAnswerToABCD(questionUnit.questionType, questionUnit.rightAnswer, questionWrapper.eqs[index].optionPermutation)"></div>
             </div>
             </div>
-            <div class="flex">学生答案:<div v-html="rightAnswerToABCD(questionUnit.questionType, questionWrapper.eqs[index].studentAnswer, questionWrapper.eqs[index].optionPermutation)"></div>
+            <div class="flex">学生答案:<div v-html="rightAnswerToABCD(questionUnit.questionType, questionWrapper.eqs[index].studentAnswer, questionWrapper.eqs[index].optionPermutation, questionUnit.rightAnswer)"></div>
             </div>
             </div>
           </div>
           </div>
         </div>
         </div>
@@ -51,7 +51,8 @@ export default {
     return {
     return {
       exam: null,
       exam: null,
       questionGroupList: null,
       questionGroupList: null,
-      examQuestionList: null
+      examQuestionList: null,
+      practiceType: null
     };
     };
   },
   },
   props: {
   props: {
@@ -63,6 +64,13 @@ export default {
   },
   },
   methods: {
   methods: {
     async initData() {
     async initData() {
+      const practiceType = (await this.$http.get(
+        "/api/ecs_exam_work/exam/examOrgProperty/" +
+          this.examId +
+          `/PRACTICE_TYPE`
+      )).data;
+      this.practiceType = practiceType; // IN_PRACTICE NO_ANSWER
+
       const [
       const [
         examData,
         examData,
         paperStructData,
         paperStructData,
@@ -233,7 +241,12 @@ export default {
     indexToABCD(index) {
     indexToABCD(index) {
       return optionName[index];
       return optionName[index];
     },
     },
-    rightAnswerToABCD(questionType, studentAnswer, optionPermutation) {
+    rightAnswerToABCD(
+      questionType,
+      studentAnswer,
+      optionPermutation,
+      rightAnswer
+    ) {
       if (studentAnswer === null) studentAnswer = [];
       if (studentAnswer === null) studentAnswer = [];
       if (["SINGLE_CHOICE", "MULTIPLE_CHOICE"].includes(questionType)) {
       if (["SINGLE_CHOICE", "MULTIPLE_CHOICE"].includes(questionType)) {
         // 学生的答案是字符串
         // 学生的答案是字符串
@@ -243,16 +256,36 @@ export default {
         const t = studentAnswer
         const t = studentAnswer
           .map(v => optionPermutation.indexOf(v - 0))
           .map(v => optionPermutation.indexOf(v - 0))
           .sort();
           .sort();
-        return t.map(v => this.indexToABCD(v + "")).join("");
+        let result = t.map(v => this.indexToABCD(v + "")).join("");
+
+        if (rightAnswer && rightAnswer.join("") == studentAnswer.join(""))
+          result +=
+            '<i class="ivu-icon ivu-icon-md-checkmark" style="color: red"></i>';
+        else if (rightAnswer && rightAnswer.join("") != studentAnswer.join(""))
+          result +=
+            '<i class="ivu-icon ivu-icon-md-close" style="color: red"></i>';
+
+        return result;
       } else if (["TRUE_OR_FALSE"].includes(questionType)) {
       } else if (["TRUE_OR_FALSE"].includes(questionType)) {
         if (typeof studentAnswer === "string") {
         if (typeof studentAnswer === "string") {
           studentAnswer = [studentAnswer];
           studentAnswer = [studentAnswer];
         }
         }
-        return { true: "正确", false: "错误" }[studentAnswer.join("")];
+        let result = { true: "正确", false: "错误" }[studentAnswer.join("")];
+        result = result || "";
+        if (rightAnswer && rightAnswer.join("") == studentAnswer.join(""))
+          result +=
+            '<i class="ivu-icon ivu-icon-md-checkmark" style="color: red"></i>';
+        else if (rightAnswer && rightAnswer.join("") != studentAnswer.join(""))
+          result +=
+            '<i class="ivu-icon ivu-icon-md-close" style="color: red"></i>';
+
+        return result;
       }
       }
-      return typeof studentAnswer === "string"
-        ? studentAnswer
-        : studentAnswer.join("");
+      let result =
+        typeof studentAnswer === "string"
+          ? studentAnswer
+          : studentAnswer.join("");
+      return result;
     }
     }
   },
   },
   computed: {},
   computed: {},