From b398b084b5e4a83166ca23b0f1aa233823a27a6a Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Fri, 22 Apr 2022 08:40:17 +0200 Subject: [PATCH 1/2] MOBILE-3833 module: Fix summary not loaded if cannot view grades --- .../module-summary/module-summary.ts | 34 ++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/src/core/features/course/components/module-summary/module-summary.ts b/src/core/features/course/components/module-summary/module-summary.ts index 89c7ef570..0fed98fd1 100644 --- a/src/core/features/course/components/module-summary/module-summary.ts +++ b/src/core/features/course/components/module-summary/module-summary.ts @@ -174,21 +174,35 @@ export class CoreCourseModuleSummaryComponent implements OnInit, OnDestroy { this.componentId = this.module.id; this.externalUrl = this.module.url; this.courseId = this.courseId || this.module.course; - - this.modicon = await CoreCourseModuleDelegate.getModuleIconSrc(this.module.modname, this.module.modicon, this.module); this.moduleNameTranslated = CoreCourse.translateModuleName(this.module.modname || ''); this.blog = await AddonBlog.isPluginEnabled(); - await Promise.all([ - this.getPackageStatus(), - this.fetchGrades(), - this.fetchCourse(), - ]); + try { + await Promise.all([ + this.loadModIcon(), + this.getPackageStatus(), + this.fetchGrades(), + this.fetchCourse(), + ]); + } catch (error) { + CoreDomUtils.showErrorModal(error); + } this.loaded = true; } + /** + * Load the module icon. + */ + protected async loadModIcon(): Promise { + if (!this.module) { + return; + } + + this.modicon = await CoreCourseModuleDelegate.getModuleIconSrc(this.module.modname, this.module.modicon, this.module); + } + /** * Updage package status. * @@ -235,7 +249,11 @@ export class CoreCourseModuleSummaryComponent implements OnInit, OnDestroy { return; } - this.grades = await CoreGradesHelper.getModuleGrades(this.courseId, this.moduleId); + try { + this.grades = await CoreGradesHelper.getModuleGrades(this.courseId, this.moduleId); + } catch { + // Cannot get grades, don't display them. + } } /** From b0f090061b88d0eb4d064e6244325223977e0aaa Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Fri, 22 Apr 2022 09:42:34 +0200 Subject: [PATCH 2/2] MOBILE-3833 bbb: Improve error message when user not in group --- scripts/langindex.json | 1 + .../bigbluebuttonbn/components/index/index.ts | 22 +++++++++++++------ src/addons/mod/bigbluebuttonbn/lang.json | 3 ++- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/scripts/langindex.json b/scripts/langindex.json index 70cc0b1cc..fd706d2f8 100644 --- a/scripts/langindex.json +++ b/scripts/langindex.json @@ -461,6 +461,7 @@ "addon.mod_bigbluebuttonbn.view_message_session_started_at": "bigbluebuttonbn", "addon.mod_bigbluebuttonbn.view_message_viewer": "bigbluebuttonbn", "addon.mod_bigbluebuttonbn.view_message_viewers": "bigbluebuttonbn", + "addon.mod_bigbluebuttonbn.view_nojoin": "bigbluebuttonbn", "addon.mod_book.errorchapter": "book", "addon.mod_book.modulenameplural": "book", "addon.mod_book.navnexttitle": "book", diff --git a/src/addons/mod/bigbluebuttonbn/components/index/index.ts b/src/addons/mod/bigbluebuttonbn/components/index/index.ts index 33a5fe693..444de98c2 100644 --- a/src/addons/mod/bigbluebuttonbn/components/index/index.ts +++ b/src/addons/mod/bigbluebuttonbn/components/index/index.ts @@ -81,15 +81,23 @@ export class AddonModBBBIndexComponent extends CoreCourseModuleMainActivityCompo return; } - this.meetingInfo = await AddonModBBB.getMeetingInfo(this.bbb.id, this.groupId, { - cmId: this.module.id, - }); + try { + this.meetingInfo = await AddonModBBB.getMeetingInfo(this.bbb.id, this.groupId, { + cmId: this.module.id, + }); - if (this.meetingInfo.statusrunning && this.meetingInfo.userlimit > 0) { - const count = (this.meetingInfo.participantcount || 0) + (this.meetingInfo.moderatorcount || 0); - if (count === this.meetingInfo.userlimit) { - this.meetingInfo.statusmessage = Translate.instant('addon.mod_bigbluebuttonbn.userlimitreached'); + if (this.meetingInfo.statusrunning && this.meetingInfo.userlimit > 0) { + const count = (this.meetingInfo.participantcount || 0) + (this.meetingInfo.moderatorcount || 0); + if (count === this.meetingInfo.userlimit) { + this.meetingInfo.statusmessage = Translate.instant('addon.mod_bigbluebuttonbn.userlimitreached'); + } } + } catch (error) { + if (error && error.errorcode === 'restrictedcontextexception') { + error.message = Translate.instant('addon.mod_bigbluebuttonbn.view_nojoin'); + } + + throw error; } } diff --git a/src/addons/mod/bigbluebuttonbn/lang.json b/src/addons/mod/bigbluebuttonbn/lang.json index 959a678e0..380c2a357 100644 --- a/src/addons/mod/bigbluebuttonbn/lang.json +++ b/src/addons/mod/bigbluebuttonbn/lang.json @@ -14,5 +14,6 @@ "view_message_moderators": "moderators", "view_message_session_started_at": "This session started at", "view_message_viewer": "viewer", - "view_message_viewers": "viewers" + "view_message_viewers": "viewers", + "view_nojoin": "You do not have a role that is allowed to join this session." }