Michael Wang 3 жил өмнө
parent
commit
9868dc0555

+ 1 - 1
src/features/OnlineExam/Examing/QuestionFilters.vue

@@ -10,7 +10,7 @@ const answered = $computed(
     store.exam.examQuestionList.filter((q) => q.studentAnswer !== null).length
 );
 const signed = $computed(
-  () => store.exam.examQuestionList.filter((q) => q.isSign).length
+  () => store.exam.examQuestionList.filter((q) => q.isStarred).length
 );
 const unanswered = $computed(
   () =>

+ 2 - 2
src/features/OnlineExam/Examing/QuestionNavView.vue

@@ -37,7 +37,7 @@ function isSelectedQuestion(section: number, index2: number) {
     q.studentAnswer !== null
   ) {
     return true;
-  } else if (store.exam.questionFilterType === "SIGNED" && q.isSign) {
+  } else if (store.exam.questionFilterType === "SIGNED" && q.isStarred) {
     return true;
   } else if (
     store.exam.questionFilterType === "UNANSWERED" &&
@@ -55,7 +55,7 @@ function itemClass(section: number, index2: number) {
   return {
     item: true,
     "current-question": isCurrentQuestion,
-    "star-question": eq.isSign,
+    "star-question": eq.isStarred,
     "is-answered": eq.studentAnswer !== null,
   };
 }

+ 4 - 4
src/features/OnlineExam/Examing/QuestionView.vue

@@ -68,7 +68,7 @@ async function updateQuestion() {
   const isNestedQuestion = qContentRes.questionUnitList.length > 1;
   store.exam.examQuestionList.forEach((q) => {
     if (q.questionId === questionId) {
-      q.getQuestionContent = true;
+      q.gotQuestionContent = true;
       let qc = qContentRes.questionUnitList[i++];
       q.answerType = qc.answerType;
       q.parentBody = transferWellNumber(qContentRes.body);
@@ -109,19 +109,19 @@ async function updateQuestion() {
 function toggleSign() {
   store.updateExamQuestion({
     order: store.exam.currentQuestion.order,
-    isSign: !store.exam.currentQuestion.isSign,
+    isStarred: !store.exam.currentQuestion.isStarred,
   });
 }
 </script>
 
 <template>
   <div
-    v-if="store.exam.currentQuestion.getQuestionContent"
+    v-if="store.exam.currentQuestion.gotQuestionContent"
     class="question-container"
   >
     <div class="question-header">
       <n-icon
-        :component="store.exam.currentQuestion.isSign ? Star : StarOutline"
+        :component="store.exam.currentQuestion.isStarred ? Star : StarOutline"
         class="star"
         @click="toggleSign"
       />

+ 1 - 1
src/features/OnlineExam/Examing/QuestionViewSingle.vue

@@ -11,7 +11,7 @@ const examQuestion = $computed(() => store.exam.currentQuestion);
 <template>
   <transition name="fade">
     <div
-      v-show="examQuestion.getQuestionContent"
+      v-show="examQuestion.gotQuestionContent"
       :key="examQuestion.order"
       class="question-view"
     >

+ 3 - 3
src/features/OnlineExam/Examing/setups/useAnswerQuestions.ts

@@ -12,7 +12,7 @@ type Answer = {
   order: number;
   studentAnswer: string;
   audioPlayTimes: AudioPlayTime[];
-  isSign: boolean;
+  isStarred: boolean;
 };
 
 export async function answerAllQuestions(
@@ -20,7 +20,7 @@ export async function answerAllQuestions(
 ): Promise<boolean> {
   const answers: Answer[] = store.exam.examQuestionList
     .filter((eq) => (ignoreDirty ? true : eq.dirty))
-    .filter((eq) => eq.getQuestionContent)
+    .filter((eq) => eq.gotQuestionContent)
     .map((eq) => {
       return Object.assign(
         {
@@ -30,7 +30,7 @@ export async function answerAllQuestions(
         eq.audioPlayTimes && {
           audioPlayTimes: JSON.stringify(eq.audioPlayTimes) as any,
         },
-        eq.isSign && { isSign: eq.isSign }
+        eq.isStarred && { isStarred: eq.isStarred }
       ) as Answer;
     });
   if (answers.length > 0) {

+ 6 - 5
src/features/OnlineExam/Examing/setups/useFaceLive.ts

@@ -31,14 +31,15 @@ export function useFaceLive(doSnap: () => void) {
     // 仅在线上使用活体检测
     // if (process.env.NODE_ENV === "production" && faceVerifyMinute) {
     if (faceVerifyMinute) {
-      // TODO: 活检定时,通过watch remain 来确定
+      // 活检定时,通过watch remain 来确定是否可行
       logger({
         cnl: ["server"],
         act: "活检定时",
-        ext: {
-          faceVerifyMinute,
-          remainTime: store.exam.remainTime,
-        },
+        dtl:
+          faceVerifyMinute * 60 * 1000 - store.exam.remainTime > 60 * 1000
+            ? "活检时间可行"
+            : "活检时间不可行",
+        ext: { faceVerifyMinute, remainTime: store.exam.remainTime },
       });
 
       addTimeout(() => {

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

@@ -36,7 +36,9 @@ export function useRealSubmitPaper(examId: number, examRecordDataId: number) {
     const unanswered = store.exam.examQuestionList.filter(
       (q) => q.studentAnswer === null
     ).length;
-    const signed = store.exam.examQuestionList.filter((q) => q.isSign).length;
+    const signed = store.exam.examQuestionList.filter(
+      (q) => q.isStarred
+    ).length;
     $dialog.info({
       title: "确认交卷",
       content: () => (

+ 1 - 1
src/features/OnlineExam/FaceRecognition.vue

@@ -212,7 +212,7 @@ async function getSnapShot(compareSync: boolean): Promise<Blob | unknown> {
     context?.drawImage(video, 0, 0, 220, 165);
 
     canvas.toBlob((blob) => resolve(blob!), "image/png", 0.95);
-  }).finally(() => void videoStartPlay()); // TODO: finally 此处的错误捕捉还需验证
+  }).finally(() => void videoStartPlay()); // finally 会在返回前执行,满足我们的要求
 }
 
 // 用来比对两次抓拍照片的md5是否一样

+ 8 - 11
src/features/OnlinePractice/OnlinePractice.vue

@@ -42,17 +42,14 @@ async function checkExamInProgress() {
 }
 async function toEnterPractice(course: PracticeExam) {
   if (enterButtonClicked) return;
-  const examInProgress = await checkExamInProgress();
-  if (examInProgress) {
-    // TODO:
-  } else {
-    void router.push({
-      name: "OnlineExamOverview",
-      params: {
-        examId: course.examId,
-      },
-    });
-  }
+  // 有断点或者异常,停止后续处理
+  if (await checkExamInProgress().catch(() => true)) return;
+  void router.push({
+    name: "OnlineExamOverview",
+    params: {
+      examId: course.examId,
+    },
+  });
 }
 function toEnterPracticeList(course: PracticeExam) {
   void router.push({

+ 9 - 9
src/store/store.ts

@@ -102,24 +102,24 @@ export const useStore = defineStore("ecs", {
     updateExamQuestion({
       order,
       studentAnswer,
-      isSign,
+      isStarred,
       audioPlayTimes,
-      getQuestionContent,
+      gotQuestionContent,
     }: {
       order: number;
       studentAnswer?: string;
-      isSign?: boolean;
+      isStarred?: boolean;
       audioPlayTimes?: AudioPlayTime[];
-      getQuestionContent?: boolean;
+      gotQuestionContent?: boolean;
     }) {
       store.exam.examQuestionList.map((eq) => {
         if (eq.order == order) {
           const upEq: typeof eq = {} as any;
-          // 仅在设置getQuestionContent时,不更新dirty
-          if (getQuestionContent === undefined) {
+          // 仅在设置gotQuestionContent时,不更新dirty
+          if (gotQuestionContent === undefined) {
             upEq.dirty = true;
           } else {
-            upEq.getQuestionContent = getQuestionContent;
+            upEq.gotQuestionContent = gotQuestionContent;
           }
           if (studentAnswer !== undefined) {
             upEq.studentAnswer = studentAnswer;
@@ -128,8 +128,8 @@ export const useStore = defineStore("ecs", {
           if (audioPlayTimes !== undefined) {
             upEq.audioPlayTimes = audioPlayTimes;
           }
-          if (isSign !== undefined) {
-            upEq.isSign = isSign;
+          if (isStarred !== undefined) {
+            upEq.isStarred = isStarred;
           }
           return Object.assign(eq, upEq);
         }

+ 4 - 4
src/types/student-client.d.ts

@@ -397,8 +397,8 @@ export type ExamQuestion = {
   groupName: string;
   /** 什么的总分??? */
   groupTotal: number;
-  /** 是否被标上星号。 TODO: 改名为 isStarred */
-  isSign: boolean;
+  /** 是否被标上星号。 */
+  isStarred: boolean;
   /** 大题号 */
   mainNumber: number;
   /** 小题号 */
@@ -419,8 +419,8 @@ export type ExamQuestion = {
   hasAudios: boolean;
   /** 试题内容。通过网络获取。 */
   questionContent: string;
-  /** 试题内容是否已通过网络获取到。 TODO: 改名为 gotQuestionContent */
-  getQuestionContent: boolean;
+  /** 试题内容是否已通过网络获取到。 */
+  gotQuestionContent: boolean;
   /** 答案是否已经被用户更新过了 */
   dirty: boolean;
   /** 只有第一题有此数据,用来像服务器保存音频播放次数 */