xiangpei
2024-10-31 b0edc0c7a4cb8a0063a56b436a63931904f179c3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import { ref, computed } from 'vue';
import { defineStore } from 'pinia';
export const useGradeStore = defineStore('grade', () => {
  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 getActiveQuestion = computed(() => {
    // console.log("sb", currentType.value)
    const temp = examDetail.value.find(item => item.questionType === currentType.value);
    // console.log(temp, "dssss")
    if (temp) {
      return temp.questionList[currentIndex.value];
    }
  });
 
  const setExamInfo = (info) => {
    examInfo.value = info;
  };
 
  const setExamDetail = (detail) => {
    examDetail.value = detail;
  };
  const initExam = (questionType) => {
    currentIndex.value = 0;
    currentType.value = questionType;
  }
  return {
    examInfo,
    examDetail,
    examType,
 
    currentType,
    currentIndex,
 
    initExam,
 
    getActiveQuestion,
 
    setExamInfo,
    setExamDetail,
  };
});