From 6c2888526001790c890b16b01aa2572ffe13fba5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Tue, 5 Dec 2023 12:02:40 +0100 Subject: [PATCH] MOBILE-3947 assign: Do not require submission statement if empty --- src/addons/mod/assign/components/submission/submission.ts | 6 ++++++ src/addons/mod/assign/pages/edit/edit.ts | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/addons/mod/assign/components/submission/submission.ts b/src/addons/mod/assign/components/submission/submission.ts index 4bf833519..9cd46da9f 100644 --- a/src/addons/mod/assign/components/submission/submission.ts +++ b/src/addons/mod/assign/components/submission/submission.ts @@ -1124,9 +1124,15 @@ export class AddonModAssignSubmissionComponent implements OnInit, OnDestroy, Can return []; } + // Receved submission statement should not be undefined. It would mean that the WS is not returning the value. const submissionStatementMissing = !!this.assign.requiresubmissionstatement && this.assign.submissionstatement === undefined; + // If received submission statement is empty, then it's not required. + if(!this.assign.submissionstatement && this.assign.submissionstatement !== undefined) { + this.assign.requiresubmissionstatement = 0; + } + this.canSubmit = !this.isSubmittedForGrading && !this.submittedOffline && (lastAttempt.cansubmit || (this.hasOffline && AddonModAssign.canSubmitOffline(this.assign, submissionStatus))); diff --git a/src/addons/mod/assign/pages/edit/edit.ts b/src/addons/mod/assign/pages/edit/edit.ts index b7677e451..1618d3918 100644 --- a/src/addons/mod/assign/pages/edit/edit.ts +++ b/src/addons/mod/assign/pages/edit/edit.ts @@ -205,6 +205,12 @@ export class AddonModAssignEditPage implements OnInit, OnDestroy, CanLeave { this.introAttachments = submissionStatus.assignmentdata?.attachments?.intro ?? this.assign.introattachments; this.allowOffline = true; // If offline isn't allowed we shouldn't have reached this point. + + // If received submission statement is empty, then it's not required. + if(!this.assign.submissionstatement && this.assign.submissionstatement !== undefined) { + this.assign.requiresubmissionstatement = 0; + } + // Only show submission statement if we are editing our own submission. if (this.assign.requiresubmissionstatement && !this.assign.submissiondrafts && this.userId == currentUserId) { this.submissionStatement = this.assign.submissionstatement;