|
@@ -94,12 +94,12 @@
|
|
|
import QuestionItem from './components/question-item.vue';
|
|
import QuestionItem from './components/question-item.vue';
|
|
|
import QuestionStatsPopup from './components/question-stats-popup.vue';
|
|
import QuestionStatsPopup from './components/question-stats-popup.vue';
|
|
|
import { useTransferPage } from '@/hooks/useTransferPage';
|
|
import { useTransferPage } from '@/hooks/useTransferPage';
|
|
|
-import { EnumExamMode, EnumQuestionType } from '@/common/enum';
|
|
|
|
|
-import { getOpenExaminee, getPaper, commitExamineePaper } from '@/api/modules/study';
|
|
|
|
|
|
|
+import { EnumExamMode } from '@/common/enum';
|
|
|
|
|
+import { getOpenExaminee, getPaper, commitExamineePaper, collectQuestion } from '@/api/modules/study';
|
|
|
import { useExam } from '@/composables/useExam';
|
|
import { useExam } from '@/composables/useExam';
|
|
|
import { Study } from '@/types';
|
|
import { Study } from '@/types';
|
|
|
import { NEXT_QUESTION, PREV_QUESTION, NEXT_QUESTION_QUICKLY, PREV_QUESTION_QUICKLY } from '@/types/injectionSymbols';
|
|
import { NEXT_QUESTION, PREV_QUESTION, NEXT_QUESTION_QUICKLY, PREV_QUESTION_QUICKLY } from '@/types/injectionSymbols';
|
|
|
-import { Examinee, ExamPaper, ExamPaperSubmit } from '@/types/study';
|
|
|
|
|
|
|
+// import { Examinee, ExamPaper, ExamPaperSubmit } from '@/types/study';
|
|
|
const { prevData, transferBack } = useTransferPage();
|
|
const { prevData, transferBack } = useTransferPage();
|
|
|
const { setQuestionList, questionList, stateQuestionList, questionTypeDesc, favoriteList, notKnowList, markList, currentIndex,
|
|
const { setQuestionList, questionList, stateQuestionList, questionTypeDesc, favoriteList, notKnowList, markList, currentIndex,
|
|
|
totalCount, doneCount, notDoneCount, notKnowCount, markCount, isAllDone,
|
|
totalCount, doneCount, notDoneCount, notKnowCount, markCount, isAllDone,
|
|
@@ -118,8 +118,8 @@ const transitionEndX = ref(null);
|
|
|
const isReady = ref(false);
|
|
const isReady = ref(false);
|
|
|
// 自动提交只提醒1次
|
|
// 自动提交只提醒1次
|
|
|
const hasShowSubmitConfirm = ref(false);
|
|
const hasShowSubmitConfirm = ref(false);
|
|
|
-const examineerData = ref<Examinee>({} as Examinee);
|
|
|
|
|
-const paperData = ref<ExamPaper>({} as ExamPaper);
|
|
|
|
|
|
|
+const examineerData = ref<Study.Examinee>({} as Study.Examinee);
|
|
|
|
|
+const paperData = ref<Study.ExamPaper>({} as Study.ExamPaper);
|
|
|
const pageTitle = computed(() => {
|
|
const pageTitle = computed(() => {
|
|
|
const { mode } = prevData.value;
|
|
const { mode } = prevData.value;
|
|
|
return mode === EnumExamMode.PRACTICE ? '练习' : '考试';
|
|
return mode === EnumExamMode.PRACTICE ? '练习' : '考试';
|
|
@@ -162,8 +162,11 @@ const currentQuestion = computed(() => {
|
|
|
const hanadleNavigate = (index: number) => {
|
|
const hanadleNavigate = (index: number) => {
|
|
|
changeIndex(index);
|
|
changeIndex(index);
|
|
|
}
|
|
}
|
|
|
-const handleFavorite = () => {
|
|
|
|
|
- currentQuestion.value.isFavorite = !currentQuestion.value.isFavorite;
|
|
|
|
|
|
|
+const handleFavorite = async () => {
|
|
|
|
|
+ if (!currentQuestion.value.isFavorite) {
|
|
|
|
|
+ await collectQuestion(currentQuestion.value.id);
|
|
|
|
|
+ }
|
|
|
|
|
+ // currentQuestion.value.isFavorite = !currentQuestion.value.isFavorite;
|
|
|
};
|
|
};
|
|
|
const handleMark = () => {
|
|
const handleMark = () => {
|
|
|
currentQuestion.value.isMark = !currentQuestion.value.isMark;
|
|
currentQuestion.value.isMark = !currentQuestion.value.isMark;
|
|
@@ -275,7 +278,7 @@ const handleSubmit = (tempSave: boolean = false) => {
|
|
|
}),
|
|
}),
|
|
|
examineeId: examineerData.value.examineeId,
|
|
examineeId: examineerData.value.examineeId,
|
|
|
isDone: isAllDone.value
|
|
isDone: isAllDone.value
|
|
|
- } as ExamPaperSubmit;
|
|
|
|
|
|
|
+ } as Study.ExamPaperSubmit;
|
|
|
if (!isExamMode.value) {
|
|
if (!isExamMode.value) {
|
|
|
params.duration = practiceDuration.value;
|
|
params.duration = practiceDuration.value;
|
|
|
}
|
|
}
|
|
@@ -290,7 +293,27 @@ const handleUpdateQuestion = (question: Study.Question) => {
|
|
|
autoSubmit();
|
|
autoSubmit();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ * 恢复上次做题历史数据
|
|
|
|
|
+ * @param savedQuestion 上次做题历史数据
|
|
|
|
|
+ * @param fullQuestion 当前试卷数据
|
|
|
|
|
+ */
|
|
|
|
|
+const restoreQuestion = (savedQuestion: Study.ExamineeQuestion[], fullQuestion: Study.ApiQuestion[]) => {
|
|
|
|
|
+ console.log(savedQuestion, fullQuestion)
|
|
|
|
|
+ for (const item of fullQuestion) {
|
|
|
|
|
+ const savedQs = savedQuestion.find(q => q.id === item.id);
|
|
|
|
|
+ if (savedQs) {
|
|
|
|
|
+ item.answers = savedQs.answers.filter(ans => ans.trim());
|
|
|
|
|
+ item.isMark = savedQs.isMark;
|
|
|
|
|
+ item.isFavorite = savedQs.isFavorite;
|
|
|
|
|
+ item.isNotKnow = savedQs.isNotKnow;
|
|
|
|
|
+ if (item.subQuestions) {
|
|
|
|
|
+ restoreQuestion(savedQs.subQuestions, item.subQuestions);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return fullQuestion;
|
|
|
|
|
+}
|
|
|
const loadData = async () => {
|
|
const loadData = async () => {
|
|
|
uni.$ie.showLoading();
|
|
uni.$ie.showLoading();
|
|
|
const { data } = await getOpenExaminee({
|
|
const { data } = await getOpenExaminee({
|
|
@@ -308,10 +331,12 @@ const loadData = async () => {
|
|
|
type: prevData.value.paperType,
|
|
type: prevData.value.paperType,
|
|
|
id: data.paperId
|
|
id: data.paperId
|
|
|
});
|
|
});
|
|
|
|
|
+ // const savedQuestionList = res.data.questions;
|
|
|
uni.$ie.hideLoading();
|
|
uni.$ie.hideLoading();
|
|
|
paperData.value = res.data;
|
|
paperData.value = res.data;
|
|
|
|
|
+ paperData.value.questions = restoreQuestion(data.questions, res.data.questions);
|
|
|
setQuestionList(paperData.value.questions)
|
|
setQuestionList(paperData.value.questions)
|
|
|
- // console.log(123, paperData)
|
|
|
|
|
|
|
+ console.log(123, paperData.value.questions)
|
|
|
// loadExamData(prevData.value.paperType, data.paperId);
|
|
// loadExamData(prevData.value.paperType, data.paperId);
|
|
|
}
|
|
}
|
|
|
isReady.value = true;
|
|
isReady.value = true;
|