| | |
| | | export const useExamStore = defineStore('exam', () => { |
| | | const examInfo = ref(null); |
| | | const examDetail = ref([]); |
| | | |
| | | |
| | | const examType = ref({ |
| | | 1: '单选题', |
| | | 2: '多选题', |
| | |
| | | examDetail.value.forEach(item => { |
| | | total += item.questionList.length; |
| | | item.questionList.forEach(question => { |
| | | grade += Number(question.score); |
| | | grade += Number(question.questionScore); |
| | | }); |
| | | }); |
| | | return { |
| | |
| | | grade, |
| | | }; |
| | | }); |
| | | |
| | | |
| | | const setExamInfo = (info) => { |
| | | examInfo.value = info; |
| | |
| | | const setQuestionAnswer = (type, index, answer) => { |
| | | const temp = examDetail.value.find(item => item.questionType === type); |
| | | if (temp) { |
| | | temp.questionList[index].correct = answer; |
| | | temp.questionList[index].answer = answer; |
| | | } |
| | | }; |
| | | |
| | | const setQuestionAnswerList = (type, index, answer) => { |
| | | const temp = examDetail.value.find(item => item.questionType === type); |
| | | if (temp) { |
| | | temp.questionList[index].answerList = answer; |
| | | } |
| | | } |
| | | |
| | | const setProgress = (progress) => { |
| | | answerProgress.value = progress; |
| | | }; |
| | | |
| | | const initExam = () => { |
| | | const initExam = (questionType) => { |
| | | answerProgress.value = 0; |
| | | currentIndex.value = 0; |
| | | currentType.value = 1; |
| | | currentType.value = questionType; |
| | | } |
| | | |
| | | |
| | |
| | | setExamInfo, |
| | | setExamDetail, |
| | | setQuestionAnswer, |
| | | setQuestionAnswerList, |
| | | setProgress |
| | | }; |
| | | }); |