MOBILE-4382 assign: Use granted extensions on remaining time

Similar to 9eb1e4d7c0
main
Pau Ferrer Ocaña 2023-07-19 14:03:16 +02:00
parent 6f5b68be64
commit 4ba3b560e4
1 changed files with 9 additions and 4 deletions

View File

@ -218,14 +218,19 @@ export class AddonModAssignSubmissionComponent implements OnInit, OnDestroy, Can
const time = CoreTimeUtils.timestamp(); const time = CoreTimeUtils.timestamp();
const timeLimitEnabled = this.assign.timelimit && submissionStarted; 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; const timeLimitEnabledBeforeDueDate = timeLimitEnabled && !dueDateReached;
if (this.userSubmission && this.userSubmission.status === AddonModAssignSubmissionStatusValues.SUBMITTED) { if (this.userSubmission && this.userSubmission.status === AddonModAssignSubmissionStatusValues.SUBMITTED) {
// Submitted, display the relevant early/late message. // Submitted, display the relevant early/late message.
const lateCalculation = this.userSubmission.timemodified - const lateCalculation = this.userSubmission.timemodified -
(timeLimitEnabledBeforeDueDate ? this.userSubmission.timecreated : 0); (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 earlyString = timeLimitEnabledBeforeDueDate ? 'submittedundertime' : 'submittedearly';
const lateString = timeLimitEnabledBeforeDueDate ? 'submittedovertime' : 'submittedlate'; const lateString = timeLimitEnabledBeforeDueDate ? 'submittedovertime' : 'submittedlate';
const onTime = lateCalculation <= lateThreshold; const onTime = lateCalculation <= lateThreshold;
@ -244,7 +249,7 @@ export class AddonModAssignSubmissionComponent implements OnInit, OnDestroy, Can
const submissionsEnabled = response.lastattempt?.submissionsenabled || response.gradingsummary?.submissionsenabled; const submissionsEnabled = response.lastattempt?.submissionsenabled || response.gradingsummary?.submissionsenabled;
this.timeRemaining = Translate.instant( this.timeRemaining = Translate.instant(
'addon.mod_assign.' + (submissionsEnabled ? 'overdue' : 'duedatereached'), 'addon.mod_assign.' + (submissionsEnabled ? 'overdue' : 'duedatereached'),
{ $a: CoreTime.formatTime(time - this.assign.duedate) }, { $a: CoreTime.formatTime(time - duedate) },
); );
this.timeRemainingClass = 'overdue'; this.timeRemainingClass = 'overdue';
this.timeLimitFinished = true; 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. // 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'; this.timeRemainingClass = 'timeremaining';
} }