From 4ba3b560e4b3629d6269c3f06f2d74c4239619e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Wed, 19 Jul 2023 14:03:16 +0200 Subject: [PATCH] MOBILE-4382 assign: Use granted extensions on remaining time Similar to https://github.com/moodle/moodle/commit/9eb1e4d7c0bd05341ef8aa2df38195ffa56fba53 --- .../mod/assign/components/submission/submission.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/addons/mod/assign/components/submission/submission.ts b/src/addons/mod/assign/components/submission/submission.ts index c045ff47a..0164e3c32 100644 --- a/src/addons/mod/assign/components/submission/submission.ts +++ b/src/addons/mod/assign/components/submission/submission.ts @@ -218,14 +218,19 @@ export class AddonModAssignSubmissionComponent implements OnInit, OnDestroy, Can const time = CoreTimeUtils.timestamp(); const timeLimitEnabled = this.assign.timelimit && submissionStarted; - const dueDateReached = this.assign.duedate > 0 && this.assign.duedate - time <= 0; + + // Define duedate as latest between due date and extension - which is a possibility... + const extensionDuedate = response.lastattempt?.extensionduedate; + const duedate = extensionDuedate ? Math.max(this.assign.duedate, extensionDuedate) : this.assign.duedate; + const dueDateReached = duedate > 0 && duedate - time <= 0; + const timeLimitEnabledBeforeDueDate = timeLimitEnabled && !dueDateReached; if (this.userSubmission && this.userSubmission.status === AddonModAssignSubmissionStatusValues.SUBMITTED) { // Submitted, display the relevant early/late message. const lateCalculation = this.userSubmission.timemodified - (timeLimitEnabledBeforeDueDate ? this.userSubmission.timecreated : 0); - const lateThreshold = timeLimitEnabledBeforeDueDate ? this.assign.timelimit || 0 : this.assign.duedate; + const lateThreshold = timeLimitEnabledBeforeDueDate ? this.assign.timelimit || 0 : duedate; const earlyString = timeLimitEnabledBeforeDueDate ? 'submittedundertime' : 'submittedearly'; const lateString = timeLimitEnabledBeforeDueDate ? 'submittedovertime' : 'submittedlate'; const onTime = lateCalculation <= lateThreshold; @@ -244,7 +249,7 @@ export class AddonModAssignSubmissionComponent implements OnInit, OnDestroy, Can const submissionsEnabled = response.lastattempt?.submissionsenabled || response.gradingsummary?.submissionsenabled; this.timeRemaining = Translate.instant( 'addon.mod_assign.' + (submissionsEnabled ? 'overdue' : 'duedatereached'), - { $a: CoreTime.formatTime(time - this.assign.duedate) }, + { $a: CoreTime.formatTime(time - duedate) }, ); this.timeRemainingClass = 'overdue'; this.timeLimitFinished = true; @@ -262,7 +267,7 @@ export class AddonModAssignSubmissionComponent implements OnInit, OnDestroy, Can } // Assignment is not overdue, and no submission has been made. Just display the due date. - this.timeRemaining = CoreTime.formatTime(this.assign.duedate - time); + this.timeRemaining = CoreTime.formatTime(duedate - time); this.timeRemainingClass = 'timeremaining'; }