Browse Source

fix: 修正跳回问题时出现NaN的问题

ChenYangfan 6 years ago
parent
commit
f7d46c51a3
1 changed files with 11 additions and 2 deletions
  1. 11 2
      src/views/quiz/StudentDoQuiz.vue

+ 11 - 2
src/views/quiz/StudentDoQuiz.vue

@@ -111,7 +111,14 @@ export default {
       })
       })
       if (uncompleted) return
       if (uncompleted) return
 
 
-      submitQuizStudentAnswer({ quizId, answers, records: this.records }).then(res => {
+      const records = {}
+      Object.keys(this.records).forEach(key => {
+        records[key] = {
+          startAt: new Date(this.records[key].startAt),
+          endAt: new Date(this.records[key].endAt)
+        }
+      })
+      submitQuizStudentAnswer({ quizId, answers, records }).then(res => {
         this.hasSubmit = true
         this.hasSubmit = true
         this.$setSuccessMessage('提交成功')
         this.$setSuccessMessage('提交成功')
         this.$router.go(-1)
         this.$router.go(-1)
@@ -143,9 +150,11 @@ export default {
     pushRecord ({ questionId, startAt, endAt }) {
     pushRecord ({ questionId, startAt, endAt }) {
       const record = this.records[questionId]
       const record = this.records[questionId]
       if (isEmpty(record)) {
       if (isEmpty(record)) {
-        this.records[questionId] = { startAt: new Date(startAt), endAt: new Date(endAt) }
+        this.records[questionId] = { startAt, endAt }
       } else {
       } else {
+        console.log(record.endAt, startAt, endAt)
         record.endAt = record.endAt + endAt - startAt
         record.endAt = record.endAt + endAt - startAt
+        console.log(record)
       }
       }
     },
     },
     momentFromNow,
     momentFromNow,