|
@@ -204,7 +204,7 @@ const handleSubmit = (tempSave: boolean = false) => {
|
|
|
};
|
|
};
|
|
|
console.log('提交试卷参数', params)
|
|
console.log('提交试卷参数', params)
|
|
|
await commitExamineePaper(params);
|
|
await commitExamineePaper(params);
|
|
|
- uni.report(events.examStartSubmitSuccess, getReportData(params));
|
|
|
|
|
|
|
+ uni.report(events.examStartSubmitSuccess, getReportData());
|
|
|
if (isSimulationExam.value || isTestExam.value) {
|
|
if (isSimulationExam.value || isTestExam.value) {
|
|
|
if (!tempSave) {
|
|
if (!tempSave) {
|
|
|
setTimeout(async () => {
|
|
setTimeout(async () => {
|
|
@@ -288,6 +288,52 @@ const restoreQuestion = (savedQuestion: Study.ExamineeQuestion[], fullQuestion:
|
|
|
}
|
|
}
|
|
|
return fullQuestion;
|
|
return fullQuestion;
|
|
|
}
|
|
}
|
|
|
|
|
+/**
|
|
|
|
|
+ * 带超时检测的 getOpenExaminee 请求
|
|
|
|
|
+ * 在 3s, 5s, 10s, 15s, 20s 这 5 个时间点检测超时并上报
|
|
|
|
|
+ * 每个时间点如果请求还未返回,都会上报一次
|
|
|
|
|
+ */
|
|
|
|
|
+const getOpenExamineeWithTimeoutCheck = async (params: Study.OpenExamineeRequestDTO) => {
|
|
|
|
|
+ // 超时时间档次(单位:毫秒)
|
|
|
|
|
+ const timeoutLevels = [3000, 5000, 10000, 15000, 20000];
|
|
|
|
|
+ // 存储所有定时器ID,用于清理
|
|
|
|
|
+ const timers: number[] = [];
|
|
|
|
|
+ // 请求是否已完成
|
|
|
|
|
+ let isCompleted = false;
|
|
|
|
|
+
|
|
|
|
|
+ // 创建超时检测定时器
|
|
|
|
|
+ timeoutLevels.forEach((timeout) => {
|
|
|
|
|
+ const timer = setTimeout(() => {
|
|
|
|
|
+ // 如果请求已完成,不进行上报
|
|
|
|
|
+ if (isCompleted) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ // 上报超时数据,超时时间单位为秒
|
|
|
|
|
+ // 每个时间点如果请求还未返回,都会上报一次
|
|
|
|
|
+ uni.report(events.ExamStartLoadSlow, getReportData({
|
|
|
|
|
+ timeout: timeout / 1000, // 转换为秒
|
|
|
|
|
+ timeoutLevel: timeout,
|
|
|
|
|
+ }));
|
|
|
|
|
+ }, timeout) as unknown as number;
|
|
|
|
|
+ timers.push(timer);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ // 执行请求
|
|
|
|
|
+ const result = await getOpenExaminee(params);
|
|
|
|
|
+ // 标记请求已完成
|
|
|
|
|
+ isCompleted = true;
|
|
|
|
|
+ // 清除所有定时器
|
|
|
|
|
+ timers.forEach((timer) => clearTimeout(timer));
|
|
|
|
|
+ return result;
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ // 请求失败时也要清除定时器
|
|
|
|
|
+ isCompleted = true;
|
|
|
|
|
+ timers.forEach((timer) => clearTimeout(timer));
|
|
|
|
|
+ throw error;
|
|
|
|
|
+ }
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
// 1、加载知识点练习数据
|
|
// 1、加载知识点练习数据
|
|
|
const loadPracticeData = async () => {
|
|
const loadPracticeData = async () => {
|
|
|
const { paperType, readonly, practiceInfo } = prevData.value;
|
|
const { paperType, readonly, practiceInfo } = prevData.value;
|
|
@@ -298,17 +344,29 @@ const loadPracticeData = async () => {
|
|
|
data = res.data;
|
|
data = res.data;
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
- const params = {
|
|
|
|
|
- paperType: paperType,
|
|
|
|
|
- relateId: practiceInfo?.relateId,
|
|
|
|
|
- } as Study.OpenExamineeRequestDTO;
|
|
|
|
|
- if (userStore.isVHS) {
|
|
|
|
|
- params.questionType = practiceInfo?.questionType;
|
|
|
|
|
- } else {
|
|
|
|
|
- params.directed = practiceInfo?.directed || false;
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ const params = {
|
|
|
|
|
+ paperType: paperType,
|
|
|
|
|
+ relateId: practiceInfo?.relateId,
|
|
|
|
|
+ } as Study.OpenExamineeRequestDTO;
|
|
|
|
|
+ if (userStore.isVHS) {
|
|
|
|
|
+ params.questionType = practiceInfo?.questionType;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ params.directed = practiceInfo?.directed || false;
|
|
|
|
|
+ }
|
|
|
|
|
+ const startTime = Date.now();
|
|
|
|
|
+ const res = await getOpenExamineeWithTimeoutCheck(params);
|
|
|
|
|
+ data = res.data || {};
|
|
|
|
|
+ const endTime = Date.now() - startTime;
|
|
|
|
|
+ console.log('开卷用时:', endTime);
|
|
|
|
|
+ uni.report(events.examStartLoadSuccess, getReportData({
|
|
|
|
|
+ time: Date.now() - startTime
|
|
|
|
|
+ }));
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ uni.report(events.examStartLoadError, getReportData({
|
|
|
|
|
+ error: error
|
|
|
|
|
+ }));
|
|
|
}
|
|
}
|
|
|
- const res = await getOpenExaminee(params);
|
|
|
|
|
- data = res.data || {};
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (!data) {
|
|
if (!data) {
|
|
@@ -378,6 +436,7 @@ const combinePaperData = async (examinee: Study.Examinee, paperType: EnumPaperTy
|
|
|
console.log('初始化数据', paperData.value.questions)
|
|
console.log('初始化数据', paperData.value.questions)
|
|
|
setQuestionList(paperData.value.questions);
|
|
setQuestionList(paperData.value.questions);
|
|
|
setDuration(examinee.duration || 0);
|
|
setDuration(examinee.duration || 0);
|
|
|
|
|
+ uni.report(events.examStartGetPaperSuccess, getReportData());
|
|
|
await nextTick();
|
|
await nextTick();
|
|
|
const targetQuestion = flatQuestionList.value.find(item => item.id === prevData.value.questionId);
|
|
const targetQuestion = flatQuestionList.value.find(item => item.id === prevData.value.questionId);
|
|
|
if (targetQuestion) {
|
|
if (targetQuestion) {
|
|
@@ -409,9 +468,11 @@ const combinePaperData = async (examinee: Study.Examinee, paperType: EnumPaperTy
|
|
|
startTime();
|
|
startTime();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- uni.report(events.examStartLoadSuccess, getReportData());
|
|
|
|
|
|
|
+ uni.report(events.examStartGetPaperSuccess, getReportData());
|
|
|
} else {
|
|
} else {
|
|
|
- uni.report(events.examStartLoadError, getReportData());
|
|
|
|
|
|
|
+ uni.report(events.examStartGetPaperError, getReportData({
|
|
|
|
|
+ error: '获取试卷数据失败,没有paperId'
|
|
|
|
|
+ }));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
const handleSwiperTipNext = () => {
|
|
const handleSwiperTipNext = () => {
|