소스 검색

زمانی که کاربر در انتهای مهلت پاسخ دهی تازه سوال ها رو میگیره شمارنده به پایان زمان آزمون توجه نمیکنه و عدد اشتباه نشون میده

hgh 1 년 전
부모
커밋
9133ec02fc
1개의 변경된 파일과 6개의 추가작업 그리고 4개의 파일을 삭제
  1. 6 4
      src/components/Widgets/Test/TestParticipation/TestParticipation.vue

+ 6 - 4
src/components/Widgets/Test/TestParticipation/TestParticipation.vue

@@ -203,17 +203,19 @@ export default {
           .catch(() => {})
       }).onCancel(() => {})
     },
-    getRemainingTimeInSeconds (serverTimeStr, attendingStartTimeStr, durationInMinutes) {
+    getRemainingTimeInSeconds (serverTimeStr, attendingStartTimeStr, durationInMinutes, testEndTimeStr) {
       // Convert the strings to Date objects
       const serverTime = new Date(serverTimeStr)
       const attendingStartTime = new Date(attendingStartTimeStr)
+      const testEndTime = new Date(testEndTimeStr)
 
       // Calculate the difference in milliseconds
       const timeDiffInMilliseconds = serverTime - attendingStartTime
-
       // Convert the difference to seconds
       const timeDiffInSeconds = timeDiffInMilliseconds / 1000
-
+      if (new Date(serverTime.getTime() + durationInMinutes * 1000 * 60) > testEndTime) {
+        return Math.floor((testEndTime - serverTime) / 1000)
+      }
       // Calculate the remaining time in seconds considering the duration
       return Math.floor((durationInMinutes * 60) - timeDiffInSeconds)
     },
@@ -267,7 +269,7 @@ export default {
       this.answerBook = new AnswerBook(answerBook)
       this.answerBook.loading = false
       if (this.answerBook.remainingTime === null) {
-        this.answerBook.remainingTime = this.getRemainingTimeInSeconds(this.answerBook.server_time, this.answerBook.attending_start_time, this.answerBook.test_info.duration_deadline)
+        this.answerBook.remainingTime = this.getRemainingTimeInSeconds(this.answerBook.server_time, this.answerBook.attending_start_time, this.answerBook.test_info.duration_deadline, this.answerBook.test_info.end_time)
       }
       this.remainingTime = this.answerBook.remainingTime
       this.$store.commit('Test/updateAnswerBook', this.answerBook)