ZhangXianQiang
2024-06-19 1a20a2c7a9e1ba9a0ffb83fb3d09ee7215d260c4
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
        }
@@ -148,6 +148,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;
@@ -161,6 +169,14 @@
    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,
    examDetail,
@@ -168,8 +184,10 @@
    activeQuestion,
    currentType,
    currentIndex,
    getActiveQuestion,
    setExamInfo,
    setExamDetail,
    setActiveQuestion
    setActiveQuestion,
    setQuestionAnswer
  };
});