Explorar o código

add: 增加未选择选项的处理和结果页中的正误提示

weijin %!s(int64=4) %!d(string=hai) anos
pai
achega
8fb97a644c

+ 19 - 2
src/views/components/ExamQuestionsInfo.vue

@@ -4,7 +4,19 @@
       <v-divider class="my-5"></v-divider>
       <v-row>
         <v-col class="d-flex justify-center align-center" cols="1">
-          <v-chip label>
+          <v-chip label v-if="!analysis">
+            {{ examQuestions.indexOf(question) + 1 }}
+          </v-chip>
+          <v-chip
+            v-else
+            :color="
+              submitAnswers.get(question.id) ===
+              question.answer.replace(/[;]/gi, '')
+                ? 'success'
+                : 'error'
+            "
+            label
+          >
             {{ examQuestions.indexOf(question) + 1 }}
           </v-chip>
         </v-col>
@@ -34,7 +46,12 @@
           我的答案:
           <v-chip
             label
-            color="info"
+            :color="
+              submitAnswers.get(question.id) ===
+              question.answer.replace(/[;]/gi, '')
+                ? 'success'
+                : 'error'
+            "
             class="ml-2 mr-4"
             v-if="submitAnswers.size > 0"
           >

+ 6 - 2
src/views/exam/ExamPane.vue

@@ -181,6 +181,7 @@
               "
               :question="currentQuestion"
               @saveAnswer="saveObjectiveAnswer"
+              @changeChoiceState="changeChoiceState"
             >
               <template #index>
                 <v-chip class="align-self-center"
@@ -199,7 +200,7 @@
               v-if="currentQuestionIndex < this.questionIds.length - 1"
               color="info"
               @click="nextQuestion"
-              :disabled="fetchingStem"
+              :disabled="fetchingStem || !choiceState"
               >下一题</v-btn
             >
           </div>
@@ -267,6 +268,7 @@ export default Vue.extend({
       submitDialog: false,
       submittedError: false,
       currentTime: 0,
+      choiceState: false,
       examInfo: (null as unknown) as ExamSerializer,
       endTime: 0,
       examQuestions: (null as unknown) as ExamQuestionSerializer,
@@ -315,7 +317,9 @@ export default Vue.extend({
         })
         .catch((err) => {})
     },
-
+    changeChoiceState(state: boolean) {
+      this.choiceState = state
+    },
     onTimesUp() {
       this.examTimesUp = true
       this.submitAnswer()

+ 6 - 1
src/views/exam/components/ChoicePane.vue

@@ -108,6 +108,12 @@ export default Vue.extend({
     question(val) {
       this.loading = true
       this.init()
+    },
+    answer: function() {
+      this.$emit(
+        'changeChoiceState',
+        this.answer != undefined && this.answer.length !== 0
+      )
     }
   },
   methods: {
@@ -115,7 +121,6 @@ export default Vue.extend({
       if (this.question.type === 'true_false') {
         this.question.options = { true: '', false: '' }
       }
-      console.log(this.question)
 
       let keys = Object.keys(this.question.options ?? {})
       let values = Object.values(this.question.options ?? {})