Преглед на файлове

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

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)