From 706fc58eea8b31ecd2e5003615a4874bf0200d76 Mon Sep 17 00:00:00 2001 From: ZhangXianQiang <1135831638@qq.com> Date: 星期三, 19 六月 2024 10:58:50 +0800 Subject: [PATCH] feat:答题进度 --- src/store/modules/exam.js | 107 +++++++++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 95 insertions(+), 12 deletions(-) diff --git a/src/store/modules/exam.js b/src/store/modules/exam.js index 712d267..edafdef 100644 --- a/src/store/modules/exam.js +++ b/src/store/modules/exam.js @@ -8,6 +8,7 @@ examStatus: '鑰冭瘯鐘舵��', examStartTime: '2021-01-01', examEndTime: '2021-01-01', + examTime: 60, }); const examType = ref({ @@ -17,6 +18,8 @@ const currentType = ref(1); const currentIndex = ref(0); + + const answerProgress = ref(0); const examDetail = ref([ { @@ -48,7 +51,7 @@ ], "analyze": "闂皬鏈嬪弸", "correct": "", - "score": "", + "score": "3", "difficult": 5 }, { @@ -77,7 +80,7 @@ ], "analyze": "闂皬鏈嬪弸", "correct": "", - "score": "", + "score": "3", "difficult": 5 } ] @@ -111,7 +114,7 @@ ], "analyze": "闂皬鏈嬪弸", "correct": "", - "score": "", + "score": "5", "difficult": 5 }, { @@ -140,22 +143,93 @@ ], "analyze": "闂皬鏈嬪弸", "correct": "", - "score": "", + "score": "5", + "difficult": 5 + }, + { + "id": null, + "questionType": 1, + "gradeLevel": null, + "subjectId": 2, + "title": "1+1=锛�", + "items": [ + { + "prefix": "A", + "content": "1" + }, + { + "prefix": "B", + "content": "2" + }, + { + "prefix": "C", + "content": "3" + }, + { + "prefix": "D", + "content": "4" + } + ], + "analyze": "闂皬鏈嬪弸", + "correct": "", + "score": "5", + "difficult": 5 + }, + { + "id": null, + "questionType": 1, + "gradeLevel": null, + "subjectId": 2, + "title": "1+1=锛�", + "items": [ + { + "prefix": "A", + "content": "1" + }, + { + "prefix": "B", + "content": "2" + }, + { + "prefix": "C", + "content": "3" + }, + { + "prefix": "D", + "content": "4" + } + ], + "analyze": "闂皬鏈嬪弸", + "correct": "", + "score": "5", "difficult": 5 } ] } ]); - const activeQuestion = ref(null); - - const getActiveQuestion = computed(() => { const temp = examDetail.value.find(item => item.questionType === currentType.value); - if(temp) { + if (temp) { return temp.questionList[currentIndex.value]; } - }) + }); + + const getAnswerInfo = computed(() => { + let total = 0; + let grade = 0; + examDetail.value.forEach(item => { + total += item.questionList.length; + item.questionList.forEach(question => { + grade += Number(question.score); + }); + }); + return { + total, + grade, + }; + }); + const setExamInfo = (info) => { examInfo.value = info; @@ -167,22 +241,31 @@ const setQuestionAnswer = (type, index, answer) => { const temp = examDetail.value.find(item => item.questionType === type); - if(temp) { + if (temp) { temp.questionList[index].correct = answer; } }; + + const setProgress = (progress) => { + answerProgress.value = progress; + } return { examInfo, examDetail, examType, - activeQuestion, + currentType, currentIndex, + answerProgress, + getActiveQuestion, + getAnswerInfo, + setExamInfo, setExamDetail, - setQuestionAnswer + setQuestionAnswer, + setProgress }; }); -- Gitblit v1.8.0