浏览代码

fix: 修复多选题显示问题(上一个提交是判断题显示问题而不是单选题)

weijin 4 年之前
父节点
当前提交
bd3a0a7b90

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

@@ -21,7 +21,7 @@ export type QuestionType =
   | 'choice'
   | 'blank'
   | 'code'
-  | 'multi_choice'
+  | 'multiple_choice'
   | 'true_false'
   | 'short_answer'
 export interface ErrorData extends AxiosResponseInfo {

+ 2 - 2
src/mock/serializers.js

@@ -23,8 +23,8 @@ const basicExtendsTypes = () => ({
     // examStatus || randomArrayValue(['READY', 'AVAILABLE', 'FINISHED', 'CLOSED'])
     examStatus || randomArrayValue(['READY', 'AVAILABLE', 'FINISHED']),
   OBJECTIVE_QUESTION_TYPE: () =>
-    // randomArrayValue(['choice', 'multi_choice', 'blank', 'code']) TODO code
-    randomArrayValue(['choice', 'multi_choice', 'blank']),
+    // randomArrayValue(['choice', 'multiple_choice', 'blank', 'code']) TODO code
+    randomArrayValue(['choice', 'multiple_choice', 'blank']),
   CODE_RESULT_STATUS: () =>
     randomArrayValue([
       'Accepted',

+ 1 - 1
src/utils/common.ts

@@ -79,7 +79,7 @@ export const questionTypeToText = function(type: QuestionType): string {
   switch (type) {
     case 'choice':
       return '单选题'
-    case 'multi_choice':
+    case 'multiple_choice':
       return '多选题'
     case 'true_false':
       return '判断题'

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

@@ -42,7 +42,7 @@
           </v-chip>
           正确答案:
           <v-chip label color="success" class="ml-2">
-            {{ question.answer }}
+            {{ question.answer.replace(/[;]/gi, '') }}
           </v-chip>
           <!--  简答题解析即为答案        -->
         </v-col>
@@ -106,7 +106,7 @@ export default Vue.extend({
                 ? 'true'
                 : val.submitAnswer === 'f'
                 ? 'false'
-                : val.submitAnswer
+                : val.submitAnswer.replace(/[;]/gi, '')
             )
           })
         } else {

+ 1 - 1
src/views/exam/ExamPane.vue

@@ -177,7 +177,7 @@
             <choice-pane
               v-else-if="
                 questionType() === 'choice' ||
-                  questionType() === 'multi_choice' ||
+                  questionType() === 'multiple_choice' ||
                   questionType() === 'true_false'
               "
               :question="currentQuestion"

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

@@ -167,7 +167,13 @@ export default Vue.extend({
         const analysisInfo = data.result
         const infoBenchItem = analysisInfo.all
         const avgPercentage = analysisInfo.avg
-        const myInfo = analysisInfo[this.getId()]
+        let myInfo = analysisInfo[this.getId()]
+        if (!myInfo) {
+          myInfo = JSON.parse(JSON.stringify(analysisInfo.all))
+          for (let [key, val] of Object.entries(myInfo)) {
+            this.$set(myInfo, key, 0)
+          }
+        }
         const myPercentage = new Map()
         Object.entries(myInfo).map((val) => {
           const value = val[1] ?? 0

+ 3 - 3
src/views/exam/components/ChoicePane.vue

@@ -9,7 +9,7 @@
       <v-card-title v-if="question.type === 'choice'"
         >单选题<v-icon>mdi-radiobox-marked</v-icon></v-card-title
       >
-      <v-card-title v-else-if="question.type === 'multi_choice'"
+      <v-card-title v-else-if="question.type === 'multiple_choice'"
         >多选题<v-icon>mdi-checkbox-marked</v-icon></v-card-title
       >
       <v-card-title v-else>
@@ -93,11 +93,11 @@ export default Vue.extend({
         return ''
       }
 
-      if (this.question.type !== 'multi_choice') {
+      if (this.question.type !== 'multiple_choice') {
         return this.answer[0]
       } else {
         const sorted = clone(this.answer).sort()
-        return sorted.join('')
+        return sorted.join(';')
       }
     }
   },

+ 1 - 1
src/views/singleQuestion/SingleQuestion.vue

@@ -14,7 +14,7 @@
           <choice-pane
             v-else-if="
               questionType() === 'choice' ||
-                questionType() === 'multi_choice' ||
+                questionType() === 'multiple_choice' ||
                 questionType() === 'true_false'
             "
             :question="question"