From da2f959b7f5e0ec28dc29b638dffad8eae305152 Mon Sep 17 00:00:00 2001 From: ZhangXianQiang <1135831638@qq.com> Date: 星期三, 19 六月 2024 11:52:35 +0800 Subject: [PATCH] fix:限制图片大小 --- src/store/modules/exam.js | 126 +++++++++++++++++++++++++++++++++++++----- 1 files changed, 111 insertions(+), 15 deletions(-) diff --git a/src/store/modules/exam.js b/src/store/modules/exam.js index f436304..edafdef 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({ @@ -8,15 +8,18 @@ examStatus: '鑰冭瘯鐘舵��', examStartTime: '2021-01-01', examEndTime: '2021-01-01', + examTime: 60, }); const examType = ref({ 1: '鍗曢�夐', - 2: '澶氶�夐' + 2: '澶氶�夐', }); const currentType = ref(1); const currentIndex = ref(0); + + const answerProgress = ref(0); const examDetail = ref([ { @@ -47,8 +50,8 @@ } ], "analyze": "闂皬鏈嬪弸", - "correct": "B", - "score": "", + "correct": "", + "score": "3", "difficult": 5 }, { @@ -76,8 +79,8 @@ } ], "analyze": "闂皬鏈嬪弸", - "correct": "B", - "score": "", + "correct": "", + "score": "3", "difficult": 5 } ] @@ -110,8 +113,8 @@ } ], "analyze": "闂皬鏈嬪弸", - "correct": "B", - "score": "", + "correct": "", + "score": "5", "difficult": 5 }, { @@ -139,15 +142,94 @@ } ], "analyze": "闂皬鏈嬪弸", - "correct": "B", - "score": "", + "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 + }, + { + "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) { + 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; @@ -157,19 +239,33 @@ 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; + } }; + + const setProgress = (progress) => { + answerProgress.value = progress; + } + return { examInfo, examDetail, examType, - activeQuestion, + currentType, currentIndex, + answerProgress, + + getActiveQuestion, + getAnswerInfo, + setExamInfo, setExamDetail, - setActiveQuestion + setQuestionAnswer, + setProgress }; }); -- Gitblit v1.8.0