From 87a07217fc44db421587e5ef5658ed5aaa8ac4ba Mon Sep 17 00:00:00 2001 From: Alfonso Salces Date: Wed, 15 Feb 2023 11:05:22 +0100 Subject: [PATCH] MOBILE-4251 Feedback: Avoid displaying the preview button to students --- scripts/langindex.json | 1 + .../components/index/addon-mod-feedback-index.html | 2 +- src/addons/mod/feedback/pages/form/form.ts | 8 ++++++++ src/core/lang.json | 1 + 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/scripts/langindex.json b/scripts/langindex.json index bc5b434d3..ca500a630 100644 --- a/scripts/langindex.json +++ b/scripts/langindex.json @@ -2105,6 +2105,7 @@ "core.nopasswordchangeforced": "local_moodlemobileapp", "core.nopermissionerror": "local_moodlemobileapp", "core.nopermissions": "error", + "core.nopermissiontoaccesspage": "error", "core.noresults": "moodle", "core.noselection": "form", "core.notapplicable": "local_moodlemobileapp", diff --git a/src/addons/mod/feedback/components/index/addon-mod-feedback-index.html b/src/addons/mod/feedback/components/index/addon-mod-feedback-index.html index d416650ca..ae34749c5 100644 --- a/src/addons/mod/feedback/components/index/addon-mod-feedback-index.html +++ b/src/addons/mod/feedback/components/index/addon-mod-feedback-index.html @@ -36,7 +36,7 @@
+ *ngIf="access && !access.isempty && (access.canedititems || access.canviewreports)"> {{ 'addon.mod_feedback.preview' | translate }} diff --git a/src/addons/mod/feedback/pages/form/form.ts b/src/addons/mod/feedback/pages/form/form.ts index 3ff6d0e44..256d46ce9 100644 --- a/src/addons/mod/feedback/pages/form/form.ts +++ b/src/addons/mod/feedback/pages/form/form.ts @@ -109,6 +109,14 @@ export class AddonModFeedbackFormPage implements OnInit, OnDestroy, CanLeave { await this.fetchData(); + if (!this.access || this.access.isempty || (!this.access.canedititems && !this.access.canviewreports)) { + CoreDomUtils.showErrorModal(Translate.instant('core.nopermissiontoaccesspage')); + + CoreNavigator.back(); + + return; + } + if (!this.feedback) { return; } diff --git a/src/core/lang.json b/src/core/lang.json index c87f175ed..278dae7e1 100644 --- a/src/core/lang.json +++ b/src/core/lang.json @@ -214,6 +214,7 @@ "nopasswordchangeforced": "You cannot proceed without changing your password.", "nopermissionerror": "Sorry, but you do not currently have permissions to do that", "nopermissions": "Sorry, but you do not currently have permissions to do that ({{$a}}).", + "nopermissiontoaccesspage": "You don't have permission to access this page.", "noresults": "No results", "noselection": "No selection", "notapplicable": "n/a",