|
@@ -227,21 +227,17 @@ export const useExam = () => {
|
|
|
return answer1.includes(answers[0]);
|
|
return answer1.includes(answers[0]);
|
|
|
} else if ([EnumQuestionType.MULTIPLE_CHOICE].includes(typeId)) {
|
|
} else if ([EnumQuestionType.MULTIPLE_CHOICE].includes(typeId)) {
|
|
|
return answers.length === answer1.length && answers.every(item => answer1.includes(item));
|
|
return answers.length === answer1.length && answers.every(item => answer1.includes(item));
|
|
|
- } else if ([EnumQuestionType.SUBJECTIVE, EnumQuestionType.SHORT_ANSWER, EnumQuestionType.ESSAY].includes(typeId)) {
|
|
|
|
|
|
|
+ } else {
|
|
|
// 主观题 A 对 B 错
|
|
// 主观题 A 对 B 错
|
|
|
return answers.includes('A') && !answers.includes('B');
|
|
return answers.includes('A') && !answers.includes('B');
|
|
|
}
|
|
}
|
|
|
- if (!answer1) {
|
|
|
|
|
- return false;
|
|
|
|
|
- }
|
|
|
|
|
- return false;
|
|
|
|
|
};
|
|
};
|
|
|
/// 题目是否未作答
|
|
/// 题目是否未作答
|
|
|
const isQuestionNotAnswer = (qs: Study.Question): boolean => {
|
|
const isQuestionNotAnswer = (qs: Study.Question): boolean => {
|
|
|
if (qs.subQuestions && qs.subQuestions.length > 0) {
|
|
if (qs.subQuestions && qs.subQuestions.length > 0) {
|
|
|
return qs.subQuestions.every(q => isQuestionNotAnswer(q));
|
|
return qs.subQuestions.every(q => isQuestionNotAnswer(q));
|
|
|
}
|
|
}
|
|
|
- return !qs.answers || qs.answers.length === 0;
|
|
|
|
|
|
|
+ return !qs.answers || qs.answers.filter(item => !!item).length === 0;
|
|
|
}
|
|
}
|
|
|
/// 选项是否正确
|
|
/// 选项是否正确
|
|
|
const isOptionCorrect = (question: Study.Question, option: Study.QuestionOption) => {
|
|
const isOptionCorrect = (question: Study.Question, option: Study.QuestionOption) => {
|
|
@@ -250,10 +246,9 @@ export const useExam = () => {
|
|
|
return answer1?.includes(option.no);
|
|
return answer1?.includes(option.no);
|
|
|
} else if ([EnumQuestionType.MULTIPLE_CHOICE].includes(typeId)) {
|
|
} else if ([EnumQuestionType.MULTIPLE_CHOICE].includes(typeId)) {
|
|
|
return answer1?.includes(option.no);
|
|
return answer1?.includes(option.no);
|
|
|
- } else if ([EnumQuestionType.SUBJECTIVE, EnumQuestionType.SHORT_ANSWER, EnumQuestionType.ESSAY].includes(typeId)) {
|
|
|
|
|
|
|
+ } else {
|
|
|
return answers?.includes(option.no) && option.no === 'A';
|
|
return answers?.includes(option.no) && option.no === 'A';
|
|
|
}
|
|
}
|
|
|
- return false;
|
|
|
|
|
}
|
|
}
|
|
|
/// 选项是否选中
|
|
/// 选项是否选中
|
|
|
const isOptionSelected = (question: Study.Question, option: Study.QuestionOption) => {
|
|
const isOptionSelected = (question: Study.Question, option: Study.QuestionOption) => {
|
|
@@ -275,11 +270,20 @@ export const useExam = () => {
|
|
|
const nextEnable = computed(() => {
|
|
const nextEnable = computed(() => {
|
|
|
if (currentQuestion.value) {
|
|
if (currentQuestion.value) {
|
|
|
if (currentQuestion.value.isSubQuestion) {
|
|
if (currentQuestion.value.isSubQuestion) {
|
|
|
|
|
+ console.log(5, subQuestionIndex.value < currentQuestion.value.subQuestions.length - 1)
|
|
|
return subQuestionIndex.value < currentQuestion.value.subQuestions.length - 1;
|
|
return subQuestionIndex.value < currentQuestion.value.subQuestions.length - 1;
|
|
|
} else {
|
|
} else {
|
|
|
- return currentIndex.value < questionList.value.length - 1;
|
|
|
|
|
|
|
+ if (currentQuestion.value.subQuestions && currentQuestion.value.subQuestions.length > 0) {
|
|
|
|
|
+ console.log(subQuestionIndex.value, currentQuestion.value.subQuestions.length - 1)
|
|
|
|
|
+ // 子题可以切换
|
|
|
|
|
+ return subQuestionIndex.value < currentQuestion.value.subQuestions.length - 1;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 大题可以切换
|
|
|
|
|
+ return currentIndex.value < questionList.value.length - 1;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ console.log(7, currentQuestion.value)
|
|
|
return false;
|
|
return false;
|
|
|
});
|
|
});
|
|
|
// 下一题
|
|
// 下一题
|
|
@@ -310,31 +314,31 @@ export const useExam = () => {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
if (currentIndex.value > 0) {
|
|
if (currentIndex.value > 0) {
|
|
|
- currentIndex.value--;
|
|
|
|
|
- setTimeout(() => {
|
|
|
|
|
- subQuestionIndex.value = 0;
|
|
|
|
|
- }, 300);
|
|
|
|
|
|
|
+ // currentIndex.value--;
|
|
|
|
|
+ // setTimeout(() => {
|
|
|
|
|
+ // subQuestionIndex.value = 0;
|
|
|
|
|
+ // }, 300);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (currentQuestion.value.subQuestions && currentQuestion.value.subQuestions.length > 0) {
|
|
|
|
|
+ if (subQuestionIndex.value > 0) {
|
|
|
|
|
+ subQuestionIndex.value--;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ currentIndex.value--;
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if (currentIndex.value > 0) {
|
|
|
|
|
+ currentIndex.value--;
|
|
|
|
|
+ // 如果上一个题是子题,那么,默认选中最后一个子题
|
|
|
|
|
+ const prevQuestion = questionList.value[currentIndex.value - 1];
|
|
|
|
|
+ if (prevQuestion && prevQuestion.subQuestions && prevQuestion.subQuestions.length > 0) {
|
|
|
|
|
+ subQuestionIndex.value = prevQuestion.subQuestions.length - 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- // if (currentQuestion.value.subQuestions && currentQuestion.value.subQuestions.length > 0) {
|
|
|
|
|
- // if (subQuestionIndex.value > 0) {
|
|
|
|
|
- // subQuestionIndex.value--;
|
|
|
|
|
- // } else {
|
|
|
|
|
- // currentIndex.value--;
|
|
|
|
|
- // }
|
|
|
|
|
- // } else {
|
|
|
|
|
- // if (currentIndex.value > 0) {
|
|
|
|
|
- // currentIndex.value--;
|
|
|
|
|
- // // 如果上一个题是子题,那么,默认选中最后一个子题
|
|
|
|
|
- // const prevQuestion = questionList.value[currentIndex.value - 1];
|
|
|
|
|
- // if (prevQuestion.subQuestions && prevQuestion.subQuestions.length > 0) {
|
|
|
|
|
- // subQuestionIndex.value = prevQuestion.subQuestions.length - 1;
|
|
|
|
|
- // }
|
|
|
|
|
- // }
|
|
|
|
|
- // }
|
|
|
|
|
}
|
|
}
|
|
|
// 快速下一题
|
|
// 快速下一题
|
|
|
const nextQuestionQuickly = () => {
|
|
const nextQuestionQuickly = () => {
|
|
|
- if (!nextEnable.value) {
|
|
|
|
|
|
|
+ if (!nextEnable) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
swiperDuration.value = 0;
|
|
swiperDuration.value = 0;
|
|
@@ -486,12 +490,16 @@ export const useExam = () => {
|
|
|
answers: [],
|
|
answers: [],
|
|
|
isMark: false,
|
|
isMark: false,
|
|
|
isNotKnow: false,
|
|
isNotKnow: false,
|
|
|
|
|
+ hasParsed: false,
|
|
|
|
|
+ showParse: false,
|
|
|
subQuestions: item.subQuestions.map(subItem => {
|
|
subQuestions: item.subQuestions.map(subItem => {
|
|
|
return {
|
|
return {
|
|
|
...subItem,
|
|
...subItem,
|
|
|
answers: [],
|
|
answers: [],
|
|
|
isMark: false,
|
|
isMark: false,
|
|
|
- isNotKnow: false
|
|
|
|
|
|
|
+ isNotKnow: false,
|
|
|
|
|
+ hasParsed: false,
|
|
|
|
|
+ showParse: false
|
|
|
}
|
|
}
|
|
|
}),
|
|
}),
|
|
|
options: item.options.map(option => {
|
|
options: item.options.map(option => {
|
|
@@ -499,7 +507,9 @@ export const useExam = () => {
|
|
|
...option,
|
|
...option,
|
|
|
isAnswer: false,
|
|
isAnswer: false,
|
|
|
isCorrect: false,
|
|
isCorrect: false,
|
|
|
- isSelected: false
|
|
|
|
|
|
|
+ isSelected: false,
|
|
|
|
|
+ isMissed: false,
|
|
|
|
|
+ isIncorrect: false
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
@@ -525,6 +535,8 @@ export const useExam = () => {
|
|
|
// immediate: false
|
|
// immediate: false
|
|
|
// });
|
|
// });
|
|
|
watch([() => currentIndex.value, () => subQuestionIndex.value], (val) => {
|
|
watch([() => currentIndex.value, () => subQuestionIndex.value], (val) => {
|
|
|
|
|
+ console.log('currentIndex.value', currentIndex.value)
|
|
|
|
|
+ console.log('subQuestionIndex.value', subQuestionIndex.value)
|
|
|
const qs = questionList.value[val[0]];
|
|
const qs = questionList.value[val[0]];
|
|
|
virtualCurrentIndex.value = qs.index + qs.offset + val[1];
|
|
virtualCurrentIndex.value = qs.index + qs.offset + val[1];
|
|
|
}, {
|
|
}, {
|