Browse Source

fix试卷查看的学生答案

Michael Wang 6 years ago
parent
commit
298834a778
1 changed files with 9 additions and 2 deletions
  1. 9 2
      src/features/OnlineExam/Examing/ExamPaper.vue

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

@@ -22,7 +22,7 @@
 
             <div class="flex">正确答案:<div v-html="rightAnswerToABCD(questionUnit.questionType, questionUnit.rightAnswer, questionWrapper.eqs[index].optionPermutation)"></div>
             </div>
-            <div class="flex">学生答案:<div v-html="questionWrapper.eqs[index].studentAnswer"></div>
+            <div class="flex">学生答案:<div v-html="rightAnswerToABCD(questionUnit.questionType, questionWrapper.eqs[index].studentAnswer, questionWrapper.eqs[index].optionPermutation)"></div>
             </div>
           </div>
         </div>
@@ -236,13 +236,20 @@ export default {
       return optionName[index];
     },
     rightAnswerToABCD(questionType, studentAnswer, optionPermutation) {
+      if (studentAnswer === null) studentAnswer = [];
       if (["SINGLE_CHOICE", "MULTIPLE_CHOICE"].includes(questionType)) {
-        //
+        // 学生的答案是字符串
+        if (typeof studentAnswer === "string") {
+          studentAnswer = studentAnswer.split("");
+        }
         const t = studentAnswer
           .map(v => optionPermutation.indexOf(v - 0))
           .sort();
         return t.map(v => this.indexToABCD(v + "")).join("");
       } else if (["TRUE_OR_FALSE"].includes(questionType)) {
+        if (typeof studentAnswer === "string") {
+          studentAnswer = [studentAnswer];
+        }
         return { true: "正确", false: "错误" }[studentAnswer.join("")];
       }
       return studentAnswer.join("");