|
|
@@ -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)
|