فهرست منبع

30秒提交一次(1, 避免丢失答案。2, 同时避免文本答案大量提交)

Michael Wang 6 سال پیش
والد
کامیت
7541e10f1f

+ 1 - 1
src/components/FaceRecognition/FaceRecognition.vue

@@ -184,7 +184,7 @@ export default {
         } else {
           setTimeout(
             this.showSnapResult.bind(this, fileName, examRecordDataId),
-            10 * 1000
+            30 * 1000
           );
         }
       } catch (e) {

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

@@ -2,7 +2,7 @@
   <div class="question-view">
     <question-body :questionBody="question.body" :examQuestion="examQuestion"></question-body>
     <div class="ops">
-      <div class="stu-answer">{{studentAnswer === 'true' ? '正确' : '错误'}}</div>
+      <div class="stu-answer">{{{'true': '正确', 'false' : '错误'}[studentAnswer]}}</div>
       <div class="score">({{examQuestion.questionScore}}分)</div>
     </div>
     <div @click="() => answerQuestion('true')">

+ 14 - 12
src/features/OnlineExam/Examing/ExamingHome.vue

@@ -92,7 +92,7 @@ export default {
 
     this.submitInterval = setInterval(
       () => this.answerAllQuestions(),
-      1 * 60 * 1000
+      10 * 1000 // 10秒检查是否有更改需要提交答案
     );
 
     // this.$Modal.info({
@@ -111,7 +111,12 @@ export default {
   //   this.updateQuestion(next);
   // },
   methods: {
-    ...mapMutations(["updateExamState", "toggleSnapNow", "updateExamResult"]),
+    ...mapMutations([
+      "updateExamState",
+      "toggleSnapNow",
+      "updateExamResult",
+      "resetExamQuestionDirty"
+    ]),
     async initData() {
       const exam = await this.$http.get(
         "/api/ecs_exam_work/exam/" + this.$route.params.examId
@@ -168,7 +173,6 @@ export default {
       if (!this.exam) return;
     },
     async answerAllQuestions() {
-      // TODO: reset dirty
       const answers = this.examQuestionList.filter(eq => eq.dirty).map(eq => {
         return {
           order: eq.order,
@@ -176,17 +180,15 @@ export default {
           audioPlayTimes: eq.audioPlayTimes
         };
       });
-      await this.$http.post(
-        "/api/ecs_oe_student/examQuestion/submitQuestionAnswer",
-        answers
-      );
-      // this.updateExamQuestion({
-      //   order: this.$route.params.order,
-      //   studentAnswer
-      // });
+      if (answers.length > 0) {
+        await this.$http.post(
+          "/api/ecs_oe_student/examQuestion/submitQuestionAnswer",
+          answers
+        );
+        this.resetExamQuestionDirty();
+      }
     },
     async submitPaper() {
-      //FIXME: submit precondition
       await this.answerAllQuestions();
 
       const answered = this.examQuestionList.filter(

+ 6 - 0
src/store.js

@@ -62,6 +62,12 @@ const examingHomeModule = {
       });
       state = Object.assign(state, { examQuestionList });
     },
+    resetExamQuestionDirty(state) {
+      const examQuestionList = state.examQuestionList.map(eq => {
+        return Object.assign({}, eq, { dirty: false });
+      });
+      state = Object.assign(state, { examQuestionList });
+    },
     setShouldSubmitPaper(state) {
       state.shouldSubmitPaper = !state.shouldSubmitPaper;
     }