Parcourir la source

交卷前提交所有答案

Michael Wang il y a 6 ans
Parent
commit
1548580412
1 fichiers modifiés avec 56 ajouts et 13 suppressions
  1. 56 13
      src/features/OnlineExam/Examing/ExamingHome.vue

+ 56 - 13
src/features/OnlineExam/Examing/ExamingHome.vue

@@ -1,32 +1,66 @@
 <template>
-  <div v-if="exam && examQuestion()" class="container" :key="exam.id">
+  <div
+    v-if="exam && examQuestion()"
+    class="container"
+    :key="exam.id"
+  >
     <div class="header">
       <RemainTime></RemainTime>
       <OverallProgress :exam-question-list="examQuestionList"></OverallProgress>
       <QuestionFilters :exam-question-list="examQuestionList"></QuestionFilters>
-      <Button class="qm-primary-button" @click="submitPaper">交卷</Button>
+      <Button
+        class="qm-primary-button"
+        @click="submitPaper"
+      >交卷</Button>
     </div>
-    <div class="main" id="examing-home-question">
+    <div
+      class="main"
+      id="examing-home-question"
+    >
       <QuestionView :exam-question="examQuestion()"></QuestionView>
-      <ArrowNavView :previousQuestionOrder="previousQuestionOrder" :nextQuestionOrder="nextQuestionOrder"></ArrowNavView>
+      <ArrowNavView
+        :previousQuestionOrder="previousQuestionOrder"
+        :nextQuestionOrder="nextQuestionOrder"
+      ></ArrowNavView>
     </div>
     <div :class="['side', 'side-row-size']">
       <div :class="['question-nav', !faceEnable && 'question-nav-long']">
         <QuestionNavView :paperStruct="paperStruct" />
       </div>
-      <div v-if="faceEnable" class="camera">
-        <FaceRecognition v-if="faceEnable" width="100%" height="100%" :showRecognizeButton="false" />
+      <div
+        v-if="faceEnable"
+        class="camera"
+      >
+        <FaceRecognition
+          v-if="faceEnable"
+          width="100%"
+          height="100%"
+          :showRecognizeButton="false"
+        />
       </div>
     </div>
-    <Modal v-model="showFaceId" :mask-closable="false" :closable="false" width=800 :styles="{top: '20px'}">
-      <FaceId v-if="showFaceId" @closeFaceId="closeFaceId" />
+    <Modal
+      v-model="showFaceId"
+      :mask-closable="false"
+      :closable="false"
+      width=800
+      :styles="{top: '20px'}"
+    >
+      <FaceId
+        v-if="showFaceId"
+        @closeFaceId="closeFaceId"
+      />
       <p slot="footer">
       </p>
     </Modal>
     <FaceTracking v-if="faceEnable && PRODUCTION" />
   </div>
   <div v-else>
-    正在等待数据返回... <i-button class="qm-primary-button" v-if="timeouted" @click="reloadPage">重试</i-button>
+    正在等待数据返回... <i-button
+      class="qm-primary-button"
+      v-if="timeouted"
+      @click="reloadPage"
+    >重试</i-button>
   </div>
 </template>
 
@@ -84,7 +118,7 @@ export default {
     }
     // for test
     // setTimeout(() => {
-    //   this.showFaceId = false;
+    //   this.showFaceId = true;
     //   // this.$Modal.remove();
     //   // }, this.$route.query.faceVerifyMinute * 60 * 1000); // 定时做活体检测
     // }, 5 * 1000); // 定时做活体检测
@@ -137,6 +171,13 @@ export default {
     // iview bug: https://github.com/iview/iview/issues/4061
     // document.body.style = "";
   },
+  // FIXME: 在上线前删除
+  beforeRouteUpdate(from, to, next) {
+    // this.answerAllQuestions();
+    // next();
+    console.log(this.$route.fullPath);
+    next();
+  },
   beforeDestroy() {
     clearTimeout(this.timeoutTimeout);
     clearInterval(this.submitInterval);
@@ -283,9 +324,10 @@ export default {
     closeFaceId() {
       this.showFaceId = false;
     },
-    async answerAllQuestions() {
+    async answerAllQuestions(ignoreDirty) {
       const answers = this.examQuestionList
-        .filter(eq => eq.dirty && eq.getQuestionContent)
+        .filter(eq => !ignoreDirty && eq.dirty)
+        .filter(eq => eq.getQuestionContent)
         .map(eq => {
           return Object.assign(
             {
@@ -311,7 +353,8 @@ export default {
     },
     async submitPaper() {
       try {
-        await this.answerAllQuestions();
+        // 交卷前强制提交所有答案
+        await this.answerAllQuestions(true);
       } catch (error) {
         return;
       }