From 0a45ebd0372b7209d5b84156ef540d5b0e68c248 Mon Sep 17 00:00:00 2001
From: ZhangXianQiang <1135831638@qq.com>
Date: 星期三, 19 六月 2024 10:04:27 +0800
Subject: [PATCH] feat(考试):多选题答题

---
 src/store/modules/exam.js |   29 +++++++++++++++++++++--------
 1 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/src/store/modules/exam.js b/src/store/modules/exam.js
index fb33503..712d267 100644
--- a/src/store/modules/exam.js
+++ b/src/store/modules/exam.js
@@ -1,4 +1,4 @@
-import { ref,computed } from 'vue';
+import { ref, computed } from 'vue';
 import { defineStore } from 'pinia';
 export const useExamStore = defineStore('exam', () => {
   const examInfo = ref({
@@ -47,7 +47,7 @@
             }
           ],
           "analyze": "闂皬鏈嬪弸",
-          "correct": "B",
+          "correct": "",
           "score": "",
           "difficult": 5
         },
@@ -76,7 +76,7 @@
             }
           ],
           "analyze": "闂皬鏈嬪弸",
-          "correct": "B",
+          "correct": "",
           "score": "",
           "difficult": 5
         }
@@ -110,7 +110,7 @@
             }
           ],
           "analyze": "闂皬鏈嬪弸",
-          "correct": "B",
+          "correct": "",
           "score": "",
           "difficult": 5
         },
@@ -139,7 +139,7 @@
             }
           ],
           "analyze": "闂皬鏈嬪弸",
-          "correct": "B",
+          "correct": "",
           "score": "",
           "difficult": 5
         }
@@ -149,6 +149,14 @@
 
   const activeQuestion = ref(null);
 
+
+  const getActiveQuestion = computed(() => {
+    const temp = examDetail.value.find(item => item.questionType === currentType.value);
+    if(temp) {
+      return temp.questionList[currentIndex.value];
+    }
+  })
+
   const setExamInfo = (info) => {
     examInfo.value = info;
   };
@@ -157,9 +165,13 @@
     examDetail.value = detail;
   };
 
-  const setActiveQuestion = (detail) => {
-    activeQuestion.value = detail;
+  const setQuestionAnswer = (type, index, answer) => {
+    const temp = examDetail.value.find(item => item.questionType === type);
+    if(temp) {
+      temp.questionList[index].correct = answer;
+    }
   };
+
 
   return {
     examInfo,
@@ -168,8 +180,9 @@
     activeQuestion,
     currentType,
     currentIndex,
+    getActiveQuestion,
     setExamInfo,
     setExamDetail,
-    setActiveQuestion
+    setQuestionAnswer
   };
 });

--
Gitblit v1.8.0