diff --git a/scripts/langindex.json b/scripts/langindex.json index d9f55134b..5a800908f 100644 --- a/scripts/langindex.json +++ b/scripts/langindex.json @@ -433,9 +433,12 @@ "addon.mod_assign_submission_file.pluginname": "assignsubmission_file", "addon.mod_assign_submission_onlinetext.pluginname": "assignsubmission_onlinetext", "addon.mod_assign_submission_onlinetext.wordlimitexceeded": "assignsubmission_onlinetext", + "addon.mod_bigbluebuttonbn.end_session_confirm": "bigbluebuttonbn", + "addon.mod_bigbluebuttonbn.end_session_confirm_title": "bigbluebuttonbn", "addon.mod_bigbluebuttonbn.mod_form_field_closingtime": "bigbluebuttonbn", "addon.mod_bigbluebuttonbn.mod_form_field_openingtime": "bigbluebuttonbn", "addon.mod_bigbluebuttonbn.userlimitreached": "bigbluebuttonbn", + "addon.mod_bigbluebuttonbn.view_conference_action_end": "bigbluebuttonbn", "addon.mod_bigbluebuttonbn.view_conference_action_join": "bigbluebuttonbn", "addon.mod_bigbluebuttonbn.view_error_unable_join_student": "bigbluebuttonbn", "addon.mod_bigbluebuttonbn.view_groups_selection_warning": "bigbluebuttonbn", diff --git a/src/addons/mod/bigbluebuttonbn/components/index/index.html b/src/addons/mod/bigbluebuttonbn/components/index/index.html index 88ae1dc38..dcc1e84e1 100644 --- a/src/addons/mod/bigbluebuttonbn/components/index/index.html +++ b/src/addons/mod/bigbluebuttonbn/components/index/index.html @@ -120,6 +120,11 @@ {{ 'addon.mod_bigbluebuttonbn.view_conference_action_join' | translate }} + + {{ 'addon.mod_bigbluebuttonbn.view_conference_action_end' | translate }} + + diff --git a/src/addons/mod/bigbluebuttonbn/components/index/index.ts b/src/addons/mod/bigbluebuttonbn/components/index/index.ts index 3f62eea6e..b47e7b356 100644 --- a/src/addons/mod/bigbluebuttonbn/components/index/index.ts +++ b/src/addons/mod/bigbluebuttonbn/components/index/index.ts @@ -45,6 +45,7 @@ export class AddonModBBBIndexComponent extends CoreCourseModuleMainActivityCompo @Optional() courseContentsPage?: CoreCourseContentsPage, ) { super('AddonModBBBIndexComponent', content, courseContentsPage); + (window).ths = this; } /** @@ -118,9 +119,15 @@ export class AddonModBBBIndexComponent extends CoreCourseModuleMainActivityCompo return; } - await AddonModBBB.invalidateAllGroupsMeetingInfo(this.bbb.id); + this.loaded = false; - await this.fetchMeetingInfo(); + try { + await AddonModBBB.invalidateAllGroupsMeetingInfo(this.bbb.id); + + await this.fetchMeetingInfo(); + } finally { + this.loaded = true; + } } /** @@ -177,4 +184,38 @@ export class AddonModBBBIndexComponent extends CoreCourseModuleMainActivityCompo } } + /** + * End the meeting. + * + * @return Promise resolved when done. + */ + async endMeeting(): Promise { + if (!this.bbb) { + return; + } + + try { + await CoreDomUtils.showConfirm( + Translate.instant('addon.mod_bigbluebuttonbn.end_session_confirm'), + Translate.instant('addon.mod_bigbluebuttonbn.end_session_confirm_title'), + Translate.instant('core.yes'), + ); + } catch { + // User canceled. + return; + } + + const modal = await CoreDomUtils.showModalLoading(); + + try { + await AddonModBBB.endMeeting(this.bbb.id, this.groupId); + + this.updateMeetingInfo(); + } catch (error) { + CoreDomUtils.showErrorModal(error); + } finally { + modal.dismiss(); + } + } + } diff --git a/src/addons/mod/bigbluebuttonbn/lang.json b/src/addons/mod/bigbluebuttonbn/lang.json index ccc84da16..dba17cf44 100644 --- a/src/addons/mod/bigbluebuttonbn/lang.json +++ b/src/addons/mod/bigbluebuttonbn/lang.json @@ -1,7 +1,10 @@ { + "end_session_confirm": "Are you sure you want to end the virtual classroom session?", + "end_session_confirm_title": "Really end session?", "mod_form_field_closingtime": "Join closed", "mod_form_field_openingtime": "Join open", "userlimitreached": "The number of users allowed in a meeting has been reached.", + "view_conference_action_end": "End session", "view_conference_action_join": "Join session", "view_error_unable_join_student": "Unable to connect to the BigBlueButton server. Please contact your Teacher or the Administrator.", "view_groups_selection_warning": "There is a conference room for each group and you have access to more than one. Be sure to select the correct one.", diff --git a/src/addons/mod/bigbluebuttonbn/services/bigbluebuttonbn.ts b/src/addons/mod/bigbluebuttonbn/services/bigbluebuttonbn.ts index 74c672d55..4889b310d 100644 --- a/src/addons/mod/bigbluebuttonbn/services/bigbluebuttonbn.ts +++ b/src/addons/mod/bigbluebuttonbn/services/bigbluebuttonbn.ts @@ -32,6 +32,29 @@ export class AddonModBBBService { static readonly COMPONENT = 'mmaModBigBlueButtonBN'; + /** + * End a meeting. + * + * @param id BBB ID. + * @param groupId Group ID, 0 means that the function will determine the user group. + * @param siteId Site ID. If not defined, current site. + * @return Promise resolved when done. + */ + async endMeeting( + id: number, + groupId: number = 0, + siteId?: string, + ): Promise { + const site = await CoreSites.getSite(siteId); + + const params: AddonModBBBEndMeetingWSParams = { + bigbluebuttonbnid: id, + groupid: groupId, + }; + + await site.write('mod_bigbluebuttonbn_end_meeting', params); + } + /** * Get a BBB activity. * @@ -349,3 +372,11 @@ export type AddonModBBBGetJoinUrlWSResponse = { export type AddonModBBBViewBigBlueButtonBNWSParams = { bigbluebuttonbnid: number; // Bigbluebuttonbn instance id. }; + +/** + * Params of mod_bigbluebuttonbn_end_meeting WS. + */ +export type AddonModBBBEndMeetingWSParams = { + bigbluebuttonbnid: number; // Bigbluebuttonbn instance id. + groupid?: number; // Bigbluebuttonbn group id. +};