Prechádzať zdrojové kódy

没到冻结时间,前端不允许交卷。活体检测时间不够的话,不进行活体检测的提示和弹框。

Michael Wang 6 rokov pred
rodič
commit
bb04a8cd29

+ 30 - 2
src/features/OnlineExam/Examing/ExamingHome.vue

@@ -68,7 +68,11 @@ export default {
       process.env.NODE_ENV === "production" &&
       /^\d+$/.test(this.$route.query.faceVerifyMinute)
     ) {
-      // TODO: 根据remaintime,计算是否还继续做活检。后台也可以计算。
+      const enoughTimeForFaceId = this.remainTime // 如果remainTime取到了的话
+        ? this.remainTime / (60 * 1000) - 1 > this.$route.query.faceVerifyMinute
+        : true;
+      if (!enoughTimeForFaceId) return;
+
       this.faceIdMsgTimeout = setTimeout(() => {
         this.toggleSnapNow();
         this.$Message.info("30秒后开始活体检测");
@@ -192,6 +196,17 @@ export default {
         exam.practiceType = practiceType;
       }
 
+      try {
+        let freezeTimeData = await this.$http.get(
+          "/api/ecs_exam_work/exam/examOrgProperty/" +
+            this.$route.params.examId +
+            `/FREEZE_TIME`
+        );
+        exam.freezeTime = freezeTimeData.data;
+      } catch (error) {
+        console.log("获取考试冻结时间失败--忽略");
+      }
+
       // init subNumber
       let questionId = null;
       let i = 1;
@@ -301,6 +316,18 @@ export default {
         return;
       }
 
+      if (
+        this.exam.freezeTime &&
+        this.remainTime >
+          (this.exam.duration - this.exam.freezeTime) * 60 * 1000
+      ) {
+        this.$Message.info({
+          content: `考试开始${this.exam.freezeTime}分钟后才允许交卷。`,
+          duration: 5
+        });
+        return;
+      }
+
       const answered = this.examQuestionList.filter(
         q => q.studentAnswer !== null
       ).length;
@@ -390,7 +417,8 @@ export default {
       "examQuestionList",
       "snapNow",
       "snapProcessingCount",
-      "shouldSubmitPaper"
+      "shouldSubmitPaper",
+      "remainTime"
     ]),
     previousQuestionOrder: vm => {
       if (vm.examQuestion().order > 1) {

+ 2 - 1
src/features/OnlineExam/Examing/RemainTime.vue

@@ -30,7 +30,7 @@ export default {
     this.clearIntervals();
   },
   methods: {
-    ...mapMutations(["setShouldSubmitPaper"]),
+    ...mapMutations(["setShouldSubmitPaper", "updateRemainTime"]),
     async getRemainTimeFromServer() {
       if (this.$route.name !== "OnlineExamingHome") {
         // 非考试页,不继续发心跳。可能退出后再进,导致心跳多发一次。可能会话已过期。
@@ -89,6 +89,7 @@ export default {
       if (val !== null && val === 0) {
         this.setShouldSubmitPaper();
       }
+      this.updateRemainTime(val);
     }
   }
 };

+ 0 - 1
src/features/OnlineExam/OnlineExamFaceCheckModal.vue

@@ -12,7 +12,6 @@
       <div class="avatar" :style="{ backgroundImage: `url('${userPhoto}')` }">
         <!-- <img :src="userPhoto" width="200px" height="300px" alt="底照" /> -->
         <div class="avatar-info" style="text-align: center; margin-top: 260px; color: white;">
-          <!-- FIXME: 没有底照的逻辑 -->
           <span style="background-color: rgba(0, 0, 0, 0.5); display: inline-block;padding: 6px 16px; border-radius: 6px;">我的底照</span>
         </div>
       </div>

+ 0 - 1
src/features/OnlineExam/OnlineExamList.vue

@@ -124,7 +124,6 @@ export default {
         return;
       }
 
-      // TODO: 待确认. 前端控制展示“是否进入考试”。后端控制不在有效期内不准访问。
       if (course.faceEnable) {
         // if 人脸检测 && 没有底照,提示,并返回
         if (!this.user.photoPath) {

+ 4 - 0
src/store.js

@@ -27,11 +27,15 @@ const examingHomeModule = {
     examQuestionList: null,
     questionFilterType: "ALL",
     snapNow: false,
+    remainTime: null,
     snapProcessingCount: 0,
     shouldSubmitPaper: false,
     allAudioPlayTimes: []
   },
   mutations: {
+    updateRemainTime(state, remainTime) {
+      state = Object.assign(state, { remainTime });
+    },
     toggleSnapNow(state) {
       state.snapNow = !state.snapNow;
       if (state.snapNow) {