Browse Source

切屏交卷

Michael Wang 3 years ago
parent
commit
c788b3454c

+ 28 - 5
src/App.vue

@@ -11,9 +11,10 @@
 </template>
 
 <script>
-import { mapState } from "vuex";
+import { mapState, createNamespacedHelpers } from "vuex";
 import { nodeCheckProcess } from "./utils/nativeExe";
 import { isElectron } from "./utils/util";
+const { mapMutations } = createNamespacedHelpers("examingHomeModule");
 
 export default {
   name: "APP",
@@ -65,10 +66,31 @@ export default {
             "学生端不是置顶状态",
           ]);
           if (this.$route.name === "OnlineExamingHome") {
-            this.$http.post(
-              "/api/ecs_oe_student/examControl/switchScreen?examRecordDataId=" +
-                this.$route.params.examRecordDataId
-            );
+            this.$http
+              .post(
+                "/api/ecs_oe_student/examControl/switchScreen?examRecordDataId=" +
+                  this.$route.params.examRecordDataId
+              )
+              .then((res) => {
+                if (
+                  this.QECSConfig.PREVENT_CHEATING_CONFIG.includes[
+                    "RECORD_SWITCH_SCREEN"
+                  ]
+                ) {
+                  if (res.data) {
+                    // console.log(res.data);
+                    const [switchScreenCount, maxSwitchScreenCount] = res.data;
+                    if (
+                      typeof switchScreenCount === "number" &&
+                      typeof maxSwitchScreenCount === "number"
+                    ) {
+                      if (switchScreenCount > maxSwitchScreenCount) {
+                        this.updateExceedSwitchCount(true);
+                      }
+                    }
+                  }
+                }
+              });
           }
           return;
 
@@ -115,6 +137,7 @@ export default {
     clearInterval(this.processInterval);
   },
   methods: {
+    ...mapMutations(["updateExceedSwitchCount"]),
     async sendOnlineSignal() {
       if (!window.sessionStorage.getItem("token")) {
         return;

+ 1 - 0
src/features/OnlineExam/Examing/ExamingEnd.vue

@@ -153,6 +153,7 @@ export default {
       pictureAnswer: {},
       snapNow: false,
       snapProcessingCount: 0,
+      exceedSwitchCount: false,
     });
 
     // 清除考试过程中存储的音频

+ 8 - 0
src/features/OnlineExam/Examing/ExamingHome.vue

@@ -163,6 +163,7 @@ export default {
       "remainTime",
       "questionAnswerFileUrl",
       "uploadModalVisible",
+      "exceedSwitchCount",
     ]),
     previousQuestionOrder: (vm) => {
       if (vm.examQuestion().order > 1) {
@@ -243,6 +244,12 @@ export default {
         }
       }
     },
+    exceedSwitchCount(val) {
+      if (val) {
+        this.logger({ action: "切屏超出次数自动交卷" });
+        this.realSubmitPaper();
+      }
+    },
     // examQuestionList(val, oldVal) {
     //   // console.log(val, oldVal);
     // }
@@ -366,6 +373,7 @@ export default {
       pictureAnswer: {},
       snapNow: false,
       snapProcessingCount: 0,
+      exceedSwitchCount: false,
     });
     // TODO: 是否是个错误点?this.$Modal 不存在?
     this.$Modal.remove();

+ 9 - 8
src/mixins/mixins.js

@@ -57,21 +57,22 @@ Vue.mixin({
 
         examingRes = examingRes.data.data; // 保持和原接口一致
 
-        if (examingRes && examingRes.isExceed) {
+        if (
+          examingRes &&
+          (examingRes.isExceed || examingRes.exceedMaxSwitchScreenCount)
+        ) {
+          const hintStr = examingRes.isExceed
+            ? `超出最大断点续考次数(${examingRes.maxInterruptNum}),正在自动交卷...`
+            : `超出最大切屏次数(${examingRes.maxSwitchScreenCount}),正在自动交卷...`;
           // 超出断点续考次数的逻辑,仅此block
           this.$Message.info({
-            content: `超出最大断点续考次数(${examingRes.maxInterruptNum}),正在自动交卷...`,
+            content: hintStr,
             duration: 15,
             closable: true,
           });
           this.$Spin.show({
             render: () => {
-              return (
-                <div style="font-size: 24px">
-                  超出最大断点续考次数({examingRes.maxInterruptNum}
-                  ),正在自动交卷...
-                </div>
-              );
+              return <div style="font-size: 24px">{hintStr}</div>;
             },
           });
           // 断点续考消息一闪而过,此处可以加延迟

+ 4 - 0
src/store.js

@@ -39,6 +39,7 @@ const examingHomeModule = {
     pictureAnswer: {},
     uploadModalVisible: false,
     isDoingFaceLiveness: false,
+    exceedSwitchCount: false,
   },
   mutations: {
     updateRemainTime(state, remainTime) {
@@ -190,6 +191,9 @@ const examingHomeModule = {
     updateIsDoingFaceLiveness(state, payload) {
       state.isDoingFaceLiveness = payload;
     },
+    updateExceedSwitchCount(state, payload) {
+      state.exceedSwitchCount = payload;
+    },
   },
   actions: {},
   getters: {