yhd12345 3 лет назад
Родитель
Сommit
121a31781b
1 измененных файлов с 23 добавлено и 8 удалено
  1. 23 8
      src/views/components/ExamQuestionsInfo.vue

+ 23 - 8
src/views/components/ExamQuestionsInfo.vue

@@ -10,10 +10,10 @@
           <v-chip
             v-else
             :color="
-              submitAnswers.get(question.id) ===
-              question.answer.replace(/[;]/gi, '')
-                ? 'success'
-                : 'error'
+              this.judgeAnswer(
+                question.id,
+                question.answer.replace(/[;]/gi, '')
+              )
             "
             label
           >
@@ -47,10 +47,10 @@
           <v-chip
             label
             :color="
-              submitAnswers.get(question.id) ===
-              question.answer.replace(/[;]/gi, '')
-                ? 'success'
-                : 'error'
+              this.judgeAnswer(
+                question.id,
+                question.answer.replace(/[;]/gi, '')
+              )
             "
             class="ml-2 mr-4"
             v-if="submitAnswers.size > 0"
@@ -135,6 +135,21 @@ export default Vue.extend({
           })
         }
       })
+    },
+
+    judgeAnswer(id: ID, answer: string): string {
+      if (this.submitAnswers.get(id) === answer.replace(/[;]/gi, '')) {
+        return 'success'
+      } else {
+        if (
+          (this.submitAnswers.get(id) === 'true' && answer === '正确') ||
+          (this.submitAnswers.get(id) === 'false' && answer === '错误')
+        ) {
+          return 'success'
+        } else {
+          return 'error'
+        }
+      }
     }
   },
   mounted() {