Browse Source

定时抓拍,交卷抓拍

Michael Wang 6 năm trước cách đây
mục cha
commit
80d1925616

+ 16 - 12
src/components/FaceRecognition/FaceRecognition.vue

@@ -75,14 +75,16 @@ export default {
     },
     async snapTimer() {
       const captureBlob = await this.getSnapShot();
-      const captureFilePath = await this.uploadToServer(captureBlob);
-      await this.faceCompare(captureFilePath);
+      const [fileName, captureFilePath] = await this.uploadToServer(
+        captureBlob
+      );
+      await this.faceCompare(fileName, captureFilePath);
       const video = this.$refs.video;
       video && video.play();
     },
     async snap() {
       const captureBlob = await this.getSnapShot();
-      const captureFilePath = await this.uploadToServer(captureBlob);
+      const [, captureFilePath] = await this.uploadToServer(captureBlob);
       await this.faceCompareSync(UPYUN_URL + captureFilePath);
       const video = this.$refs.video;
       video && video.play();
@@ -117,7 +119,7 @@ export default {
         return;
       }
 
-      return "/capture_photo/" + this.user.userId + "/" + fileName;
+      return [fileName, "/capture_photo/" + this.user.userId + "/" + fileName];
     },
     async faceCompareSync(captureFilePath) {
       try {
@@ -138,39 +140,41 @@ export default {
         return;
       }
     },
-    async faceCompare(captureFilePath) {
+    async faceCompare(fileName, captureFilePath) {
       try {
         await this.$http.post(
           "/api/ecs_oe_student_face/examCaptureQueue/uploadExamCapture?fileUrl=" +
             UPYUN_URL +
             captureFilePath +
             "&fileName=" +
-            captureFilePath +
+            fileName +
             "&examRecordDataId=" +
             this.$route.params.examRecordDataId
         );
-        this.showSnapResult(captureFilePath);
+        await this.showSnapResult(fileName);
       } catch (e) {
         console.log(e);
         this.$Message.error(e.message);
         return;
       }
     },
-    async showSnapResult(captureFilePath) {
+    async showSnapResult(fileName) {
       try {
         // 获取抓拍结果
         const snapRes = (await this.$http.get(
           "/api/ecs_oe_student_face/examCaptureQueue/getExamCaptureResult?fileName=" +
-            captureFilePath +
+            fileName +
             "&examRecordDataId=" +
             this.$route.params.examRecordDataId
         )).data;
-        if (snapRes) {
-          if (snapRes.stranger) {
+        if (snapRes.isCompleted) {
+          if (snapRes.isStranger) {
             this.$Message.error("请独立考试");
+          } else if (!snapRes.isPass) {
+            this.$Message.error("请保持正确坐姿");
           }
         } else {
-          setTimeout(this.showSnapResult.bind(this, captureFilePath), 3000);
+          setTimeout(this.showSnapResult.bind(this, fileName), 10 * 1000);
         }
       } catch (e) {
         console.log(e);

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

@@ -42,9 +42,28 @@ export default {
       return;
     }
 
-    setInterval(() => {
+    setTimeout(() => {
       this.toggleSnapNow();
-    }, 10 * 60 * 1000);
+    }, 60 * 1000); // 一分钟后抓拍
+
+    this.$http
+      .get(
+        "/api/ecs_exam_work/exam/examOrgProperty/" +
+          this.$route.params.examId +
+          `/SNAPSHOT_INTERVAL`
+      )
+      .then(res => {
+        // console.log(res);
+        if (res.data) {
+          // 考务设置抓拍间隔
+          setInterval(() => {
+            this.toggleSnapNow();
+          }, res.data * 60 * 1000);
+        }
+      })
+      .catch(reason => {
+        this.$Message.error(reason);
+      });
   },
   // beforeRouteUpdate(to, from, next) {
   //   this.updateQuestion(next);
@@ -86,6 +105,21 @@ export default {
     },
     async submitPaper() {
       //FIXME: submit precondition
+
+      const answered = this.examQuestionList.filter(
+        q => q.studentAnswer !== null
+      ).length;
+      const unanswered = this.examQuestionList.filter(
+        q => q.studentAnswer === null
+      ).length;
+      this.$Modal.confirm({
+        title: "确认交卷",
+        content: `<p>已答题目:${answered}</p><p>未答题目:${unanswered}</p>`,
+        onOk: this.realSubmitPaper
+      });
+    },
+    async realSubmitPaper() {
+      this.toggleSnapNow();
       await this.$http.get("/api/ecs_oe_student/examControl/endExam");
       this.$router.push({
         path: `/online-exam/exam/${this.$route.params.examId}/examRecordData/${

+ 3 - 1
src/features/OnlinePractice/OnlinePracticeHome.vue

@@ -54,7 +54,9 @@ export default {
     };
   },
   async mounted() {
-    const res = await this.$http.get("/api/online_exam_course");
+    const res = await this.$http.get(
+      "/api/ecs_oe_student/practice/queryPracticeCourseList"
+    );
 
     this.courses = res.data.map(c => ({
       courseName: c.courseName,