ソースを参照

主观题包含更多题型

shmily1213 2 週間 前
コミット
105e864788

+ 8 - 5
src/composables/useExam.ts

@@ -187,14 +187,17 @@ export const useExam = () => {
     return qs.answers && qs.answers.filter(item => !!item).length > 0 || !!qs.isNotKnow;
   }
   const isQuestionCorrect = (qs: Study.ExamineeQuestion): boolean => {
-    const { answers, answer1, answer2, typeId } = qs;
+    let { answers, answer1, answer2, typeId } = qs;
+    answers = answers?.filter(item => !!item) || [];
+    answer1 = answer1 || '';
+    answer2 = answer2 || '';
     if ([EnumQuestionType.SINGLE_CHOICE, EnumQuestionType.JUDGMENT].includes(typeId)) {
-      return answer1?.includes(answers[0]);
+      return answer1.includes(answers[0]);
     } else if ([EnumQuestionType.MULTIPLE_CHOICE].includes(typeId)) {
-      return answers?.length === answer1?.length && answers?.every(item => answer1?.includes(item));
-    } else if (typeId === EnumQuestionType.SUBJECTIVE) {
+      return answers.length === answer1.length && answers.every(item => answer1.includes(item));
+    } else if ([EnumQuestionType.SUBJECTIVE, EnumQuestionType.SHORT_ANSWER, EnumQuestionType.ESSAY].includes(typeId)) {
       // 主观题 A 对 B 错
-      return answers?.includes('A') && !answers?.includes('B');
+      return answers.includes('A') && !answers.includes('B');
     }
     if (!answer1) {
       return false;

+ 4 - 3
src/pagesStudy/pages/exam-start/components/question-item.vue

@@ -15,7 +15,7 @@
           <template v-if="!readonly">
             <view v-if="!isOnlySubjective" class="question-option-index">{{ option.no }}</view>
             <view v-else>
-              <uv-icon name="info-circle" :color="question.isNotKnow ? '#31A0FC' : '#999'" size="18" />
+              <uv-icon name="info-circle" :color="isSelected(option) ? '#31A0FC' : '#999'" size="18" />
             </view>
           </template>
           <view v-else>
@@ -38,7 +38,7 @@
         <view v-if="!readonly && isOnlySubjective" class="mt-40 bg-[#EBF9FF] p-12 rounded-8">
           <view class="rounded-8 bg-white px-10 py-20 text-primary text-24 flex gap-x-6 items-center">
             <uv-icon name="info-circle" color="#31A0FC" size="16" />
-            <text>主观题请线下答题,查看解析对比后,选“会”或“不会”</text>
+            <text>请线下答题,查看解析对比后,选“会”或“不会”</text>
           </view>
           <view class="mt-30 mb-20 text-24 text-white bg-primary w-fit mx-auto px-20 py-12 rounded-full text-center"
             @click="handleShowParse">
@@ -125,7 +125,7 @@ const emit = defineEmits<{
   (e: 'changeQuestion', question: Study.Question): void;
 }>();
 const isOnlySubjective = computed(() => {
-  return props.question.typeId === EnumQuestionType.SUBJECTIVE;
+  return [EnumQuestionType.SUBJECTIVE, EnumQuestionType.SHORT_ANSWER, EnumQuestionType.ESSAY].includes(props.question.typeId);
 });
 const getStyleClass = (option: Study.QuestionOption) => {
   if (!props.readonly) {
@@ -218,6 +218,7 @@ const handleSelect = (option: Study.QuestionOption) => {
       props.question.answers.push(option.no);
     }
   }
+  
   props.question.isNotKnow = false;
   checkIsDone();