|
@@ -13,6 +13,7 @@ export const useExam = () => {
|
|
|
[EnumQuestionType.SHORT_ANSWER]: '简答题',
|
|
[EnumQuestionType.SHORT_ANSWER]: '简答题',
|
|
|
[EnumQuestionType.ESSAY]: '问答题',
|
|
[EnumQuestionType.ESSAY]: '问答题',
|
|
|
[EnumQuestionType.ANALYSIS]: '分析题',
|
|
[EnumQuestionType.ANALYSIS]: '分析题',
|
|
|
|
|
+ [EnumQuestionType.OTHER]: '阅读题'
|
|
|
}
|
|
}
|
|
|
// 题型顺序
|
|
// 题型顺序
|
|
|
const questionTypeOrder = [
|
|
const questionTypeOrder = [
|
|
@@ -23,7 +24,8 @@ export const useExam = () => {
|
|
|
EnumQuestionType.SUBJECTIVE,
|
|
EnumQuestionType.SUBJECTIVE,
|
|
|
EnumQuestionType.SHORT_ANSWER,
|
|
EnumQuestionType.SHORT_ANSWER,
|
|
|
EnumQuestionType.ESSAY,
|
|
EnumQuestionType.ESSAY,
|
|
|
- EnumQuestionType.ANALYSIS
|
|
|
|
|
|
|
+ EnumQuestionType.ANALYSIS,
|
|
|
|
|
+ EnumQuestionType.OTHER
|
|
|
];
|
|
];
|
|
|
let interval: NodeJS.Timeout | null = null;
|
|
let interval: NodeJS.Timeout | null = null;
|
|
|
const countDownCallback = ref<() => void>(() => { });
|
|
const countDownCallback = ref<() => void>(() => { });
|
|
@@ -53,6 +55,14 @@ export const useExam = () => {
|
|
|
const markList = ref<Study.Question[]>([]);
|
|
const markList = ref<Study.Question[]>([]);
|
|
|
// 包含状态的问题列表
|
|
// 包含状态的问题列表
|
|
|
const stateQuestionList = computed(() => {
|
|
const stateQuestionList = computed(() => {
|
|
|
|
|
+ return questionList.value.map(item => {
|
|
|
|
|
+ return {
|
|
|
|
|
+ ...item,
|
|
|
|
|
+ isDone: isDone(item)
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+ const groupedQuestionList = computed(() => {
|
|
|
// 状态:已做、未做、是否不会、是否标记,整体按照题型分组
|
|
// 状态:已做、未做、是否不会、是否标记,整体按照题型分组
|
|
|
const state = questionTypeOrder.map(type => {
|
|
const state = questionTypeOrder.map(type => {
|
|
|
return {
|
|
return {
|
|
@@ -87,16 +97,20 @@ export const useExam = () => {
|
|
|
});
|
|
});
|
|
|
const doneCount = computed(() => {
|
|
const doneCount = computed(() => {
|
|
|
// 有答案的或者不会做的,都认为是做了
|
|
// 有答案的或者不会做的,都认为是做了
|
|
|
- return stateQuestionList.value.reduce((acc, item) => acc + item.list.filter(q => q.question.isDone || q.question.isNotKnow).length, 0);
|
|
|
|
|
|
|
+ // return groupedQuestionList.value.reduce((acc, item) => acc + item.list.filter(q => q.question.isDone || q.question.isNotKnow).length, 0);
|
|
|
|
|
+ return stateQuestionList.value.filter(q => q.isDone || q.isNotKnow).length;
|
|
|
});
|
|
});
|
|
|
const notDoneCount = computed(() => {
|
|
const notDoneCount = computed(() => {
|
|
|
- return questionList.value.length - doneCount.value;
|
|
|
|
|
|
|
+ // return questionList.value.length - doneCount.value;
|
|
|
|
|
+ return stateQuestionList.value.length - doneCount.value;
|
|
|
});
|
|
});
|
|
|
const notKnowCount = computed(() => {
|
|
const notKnowCount = computed(() => {
|
|
|
- return stateQuestionList.value.reduce((acc, item) => acc + item.list.filter(q => q.question.isNotKnow).length, 0);
|
|
|
|
|
|
|
+ // return groupedQuestionList.value.reduce((acc, item) => acc + item.list.filter(q => q.question.isNotKnow).length, 0);
|
|
|
|
|
+ return stateQuestionList.value.filter(q => q.isNotKnow).length;
|
|
|
});
|
|
});
|
|
|
const markCount = computed(() => {
|
|
const markCount = computed(() => {
|
|
|
- return stateQuestionList.value.reduce((acc, item) => acc + item.list.filter(q => q.question.isMark).length, 0);
|
|
|
|
|
|
|
+ // return groupedQuestionList.value.reduce((acc, item) => acc + item.list.filter(q => q.question.isMark).length, 0);
|
|
|
|
|
+ return stateQuestionList.value.filter(q => q.isMark).length;
|
|
|
});
|
|
});
|
|
|
const isDone = (qs: Study.Question): boolean => {
|
|
const isDone = (qs: Study.Question): boolean => {
|
|
|
if (qs.subQuestions && qs.subQuestions.length > 0) {
|
|
if (qs.subQuestions && qs.subQuestions.length > 0) {
|
|
@@ -117,7 +131,6 @@ export const useExam = () => {
|
|
|
currentIndex.value--;
|
|
currentIndex.value--;
|
|
|
}
|
|
}
|
|
|
const nextQuestionQuickly = () => {
|
|
const nextQuestionQuickly = () => {
|
|
|
- // currentIndex.value += 10;
|
|
|
|
|
if (currentIndex.value >= questionList.value.length - 1) {
|
|
if (currentIndex.value >= questionList.value.length - 1) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
@@ -187,15 +200,6 @@ export const useExam = () => {
|
|
|
const setCountDownCallback = (callback: () => void) => {
|
|
const setCountDownCallback = (callback: () => void) => {
|
|
|
countDownCallback.value = callback;
|
|
countDownCallback.value = callback;
|
|
|
}
|
|
}
|
|
|
- const loadExamData = async (paperType: string, paperId: number) => {
|
|
|
|
|
- // const res = await getPaper({
|
|
|
|
|
- // type: paperType,
|
|
|
|
|
- // id: paperId
|
|
|
|
|
- // });
|
|
|
|
|
- // // questionList.value = res.data.questions;
|
|
|
|
|
- // console.log(questionList.value)
|
|
|
|
|
- // startPracticeDuration();
|
|
|
|
|
- }
|
|
|
|
|
const setQuestionList = (list: Study.ApiQuestion[]) => {
|
|
const setQuestionList = (list: Study.ApiQuestion[]) => {
|
|
|
const orders = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
|
|
const orders = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
|
|
|
// 数据预处理
|
|
// 数据预处理
|
|
@@ -203,18 +207,19 @@ export const useExam = () => {
|
|
|
const parseQuestion = (item: Study.ApiQuestion): Study.Question => {
|
|
const parseQuestion = (item: Study.ApiQuestion): Study.Question => {
|
|
|
return {
|
|
return {
|
|
|
title: item.title,
|
|
title: item.title,
|
|
|
- typeId: item.typeId,
|
|
|
|
|
|
|
+ // 处理没有题型的大题,统一作为阅读题
|
|
|
|
|
+ typeId: (item.typeId === null || item.typeId === undefined) ? EnumQuestionType.OTHER : item.typeId,
|
|
|
id: item.id,
|
|
id: item.id,
|
|
|
answers: item.answers || [],
|
|
answers: item.answers || [],
|
|
|
subQuestions: item.subQuestions?.map(parseQuestion) || [],
|
|
subQuestions: item.subQuestions?.map(parseQuestion) || [],
|
|
|
- options: item.options.map((option, index) => {
|
|
|
|
|
|
|
+ options: item.options?.map((option, index) => {
|
|
|
return {
|
|
return {
|
|
|
name: option,
|
|
name: option,
|
|
|
no: orders[index],
|
|
no: orders[index],
|
|
|
id: index,
|
|
id: index,
|
|
|
isAnswer: false
|
|
isAnswer: false
|
|
|
} as Study.QuestionOption
|
|
} as Study.QuestionOption
|
|
|
- }),
|
|
|
|
|
|
|
+ }) || [],
|
|
|
isDone: false,
|
|
isDone: false,
|
|
|
isMark: item.isMark,
|
|
isMark: item.isMark,
|
|
|
isNotKnow: item.isNotKnow,
|
|
isNotKnow: item.isNotKnow,
|
|
@@ -224,7 +229,6 @@ export const useExam = () => {
|
|
|
const arr: Study.Question[] = list.map(item => {
|
|
const arr: Study.Question[] = list.map(item => {
|
|
|
return parseQuestion(item);
|
|
return parseQuestion(item);
|
|
|
});
|
|
});
|
|
|
- console.log(222, arr)
|
|
|
|
|
questionList.value = arr;
|
|
questionList.value = arr;
|
|
|
}
|
|
}
|
|
|
const reset = () => {
|
|
const reset = () => {
|
|
@@ -244,6 +248,7 @@ export const useExam = () => {
|
|
|
}
|
|
}
|
|
|
return {
|
|
return {
|
|
|
questionList,
|
|
questionList,
|
|
|
|
|
+ groupedQuestionList,
|
|
|
stateQuestionList,
|
|
stateQuestionList,
|
|
|
favoriteList,
|
|
favoriteList,
|
|
|
notKnowList,
|
|
notKnowList,
|
|
@@ -255,7 +260,6 @@ export const useExam = () => {
|
|
|
notDoneCount,
|
|
notDoneCount,
|
|
|
notKnowCount,
|
|
notKnowCount,
|
|
|
markCount,
|
|
markCount,
|
|
|
- loadExamData,
|
|
|
|
|
questionTypeDesc,
|
|
questionTypeDesc,
|
|
|
nextQuestion,
|
|
nextQuestion,
|
|
|
prevQuestion,
|
|
prevQuestion,
|