Bladeren bron

fix: 修复单选题显示问题

weijin 4 jaren geleden
bovenliggende
commit
17510e4e45

+ 1 - 1
src/api/types.d.ts

@@ -90,7 +90,7 @@ export interface ResultSerializer {
   }>
 }
 
-export type OptionSerializer = Map<string, string>
+export type OptionSerializer = Object
 
 export interface OptionLabelTextPair {
   label: string

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

@@ -100,7 +100,14 @@ export default Vue.extend({
         if (records && records.length > 0) {
           this.submitAnswers = new Map()
           records.forEach((val) => {
-            this.submitAnswers.set(val.questionId, val.submitAnswer)
+            this.submitAnswers.set(
+              val.questionId,
+              val.submitAnswer === 't'
+                ? 'true'
+                : val.submitAnswer === 'f'
+                ? 'false'
+                : val.submitAnswer
+            )
           })
         } else {
           this.submitAnswers = new Map()

+ 24 - 1
src/views/exam/PersonalResult.vue

@@ -57,6 +57,9 @@
         </v-expansion-panel>
       </v-expansion-panels>
     </v-container>
+    <v-snackbar v-model="isNotFinished" centered absolute color="error">
+      已经提交试卷,考试结束
+    </v-snackbar>
   </v-container>
 </template>
 
@@ -79,6 +82,7 @@ import dayjs from 'dayjs'
 import { TIME_FORMAT } from '@/utils/common'
 import { getExamAnalysis } from '@/api/analysis'
 import { mapGetters } from 'vuex'
+import { getExamSubmitRecordsByUserId } from '@/api/record'
 
 export default Vue.extend({
   name: 'PersonalResult',
@@ -90,6 +94,7 @@ export default Vue.extend({
   data() {
     return {
       fetching: false,
+      isNotFinished: false,
       breadcrumb: [
         {
           text: '主页',
@@ -130,6 +135,24 @@ export default Vue.extend({
       } else {
         this.loadingText = '考试进行中,请在考试结束后查看排名信息'
       }
+
+      const exam = data.result
+      // 提交过客观题,说明已经交卷
+      getExamSubmitRecordsByUserId(examId)
+        .then(({ data }) => {
+          if (data.result.length <= 0 && new Date(exam.endTime) > new Date()) {
+            this.isNotFinished = true
+            setTimeout(() => {
+              this.$router.push({ name: 'Home' })
+            }, 1000)
+          }
+        })
+        .catch(() => {
+          this.isNotFinished = true
+          setTimeout(() => {
+            this.$router.push({ name: 'Home' })
+          }, 1000)
+        })
     })
 
     getExamQuestions(examId).then(({ data }) => {
@@ -211,7 +234,7 @@ export default Vue.extend({
             formatter: '{a}{b}: {c} 分({d}%)'
           },
           title: {
-            text: '得分   ',
+            text: '得分: ' + score + ' ',
             left: 'right'
           },
           legend: {

+ 15 - 7
src/views/exam/components/ChoicePane.vue

@@ -113,20 +113,28 @@ export default Vue.extend({
   methods: {
     init() {
       if (this.question.type === 'true_false') {
-        this.question.options?.set('true', '')
-        this.question.options?.set('false', '')
+        this.question.options = { true: '', false: '' }
       }
+      console.log(this.question)
 
       let keys = Object.keys(this.question.options ?? {})
       let values = Object.values(this.question.options ?? {})
       this.options = []
 
       for (let i = 0; i < keys.length; i++) {
-        this.options.push({
-          label: keys[i],
-          text: values[i],
-          labelText: keys[i] + '. ' + values[i]
-        })
+        if (this.question.type === 'true_false') {
+          this.options.push({
+            label: keys[i],
+            text: values[i],
+            labelText: keys[i]
+          })
+        } else {
+          this.options.push({
+            label: keys[i],
+            text: values[i],
+            labelText: keys[i] + '. ' + values[i]
+          })
+        }
       }
       this.answer = []
       this.loading = false

+ 0 - 1
src/views/student/components/StudentExamInfoCard.vue

@@ -182,7 +182,6 @@ export default Vue.extend({
       this.examInfo.startTime,
       this.examInfo.endTime
     )
-    console.log(this.examInfo)
   },
   updated() {
     this.state = computeExamStateText(