From 385480120bcda041fe1f43f8a3c63563cff4ebf2 Mon Sep 17 00:00:00 2001
From: ZhangXianQiang <1135831638@qq.com>
Date: 星期四, 04 七月 2024 16:38:03 +0800
Subject: [PATCH] feat:学生上课
---
src/store/modules/exam.js | 100 +++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 94 insertions(+), 6 deletions(-)
diff --git a/src/store/modules/exam.js b/src/store/modules/exam.js
index 96a55e9..854eb4b 100644
--- a/src/store/modules/exam.js
+++ b/src/store/modules/exam.js
@@ -1,11 +1,99 @@
-import { ref } from 'vue';
+import { ref, computed } from 'vue';
import { defineStore } from 'pinia';
-const useExamStore = defineStore('exam', () => {
+export const useExamStore = defineStore('exam', () => {
const examInfo = ref(null);
+ const examDetail = ref([]);
+
+ const examType = ref({
+ 1: '鍗曢�夐',
+ 2: '澶氶�夐',
+ 3: '鍒ゆ柇棰�',
+ 4: '濉┖棰�',
+ 5: '绠�绛旈',
+ 6: '璇煶棰�',
+ 7: '璁$畻棰�',
+ 8: '鍒嗘瀽棰�',
+ });
+
+ const currentType = ref(1);
+ const currentIndex = ref(0);
+
+ const answerProgress = ref(0);
+
+
+ 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.questionScore);
+ });
+ });
+ return {
+ total,
+ grade,
+ };
+ });
+
+ const setExamInfo = (info) => {
+ examInfo.value = info;
+ };
+
+ const setExamDetail = (detail) => {
+ examDetail.value = detail;
+ };
+
+ const setQuestionAnswer = (type, index, answer) => {
+ const temp = examDetail.value.find(item => item.questionType === type);
+ if (temp) {
+ 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 = () => {
+ answerProgress.value = 0;
+ currentIndex.value = 0;
+ currentType.value = 1;
+ }
+
return {
- examInfo
- }
-});
+ examInfo,
+ examDetail,
+ examType,
-export default useExamStore;
\ No newline at end of file
+ currentType,
+ currentIndex,
+ answerProgress,
+
+ getActiveQuestion,
+ getAnswerInfo,
+
+ initExam,
+
+ setExamInfo,
+ setExamDetail,
+ setQuestionAnswer,
+ setQuestionAnswerList,
+ setProgress
+ };
+});
--
Gitblit v1.8.0