浏览代码

fix error reporting

Michael Wang 3 年之前
父节点
当前提交
e768f1c1a3

+ 2 - 0
src/features/OnlineExam/Examing/setups/useAnswerQuestions.ts

@@ -21,6 +21,8 @@ type Answer = {
 export async function answerAllQuestions(
   ignoreDirty?: boolean
 ): Promise<boolean> {
+  // 根据线上错误排查:可能已经退出页面了,没有数据了
+  if (!store.exam.examQuestionList) return false;
   const answers: Answer[] = store.exam.examQuestionList
     .filter((eq) => (ignoreDirty ? true : eq.dirty))
     .filter((eq) => eq.gotQuestionContent)

+ 4 - 3
src/features/OnlineExam/Examing/setups/useSubmitPaper.tsx

@@ -69,13 +69,14 @@ export function useRealSubmitPaper(examId: number, examRecordDataId: number) {
     store.spinMessage = "正在交卷,请耐心等待...";
     logger({ cnl: ["server"], act: "正在交卷,请耐心等待..." });
     let delay = 0;
-    const oldSnapCount = store.exam.compareResultMap.size;
+    const oldSnapCount = store.exam.compareResultMap?.size;
     if (store.exam.faceCheckEnabled) {
       logger({ cnl: ["server"], act: "交卷前抓拍" });
       doSnap();
       await new Promise((resolve) => setTimeout(resolve, 3 * 1000));
-      const newSnapCount = store.exam.compareResultMap.size;
-      if (newSnapCount - oldSnapCount === 0) {
+      // 根据线上错误排查:可能已经退出页面了,没有数据了
+      const newSnapCount = store.exam.compareResultMap?.size;
+      if (store.exam.compareResultMap && newSnapCount - oldSnapCount === 0) {
         // 给抓拍照片多2秒处理时间
         delay = 8;
         logger({ cnl: ["server"], act: "交卷前抓拍", dtl: "3秒内未上传完毕" });