From 9c2116c33b2d9a5f0b004482ce32c9437f9f37dd Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Thu, 24 Mar 2022 16:08:16 +0100 Subject: [PATCH] MOBILE-3833 data: Hide All participants with visible groups --- src/addons/mod/data/components/index/index.ts | 6 ++++++ src/addons/mod/data/pages/edit/edit.ts | 6 ++++++ src/addons/mod/data/pages/entry/entry.ts | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/src/addons/mod/data/components/index/index.ts b/src/addons/mod/data/components/index/index.ts index 4708f24c7..bb4b1b8dc 100644 --- a/src/addons/mod/data/components/index/index.ts +++ b/src/addons/mod/data/components/index/index.ts @@ -218,6 +218,12 @@ export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComp } this.groupInfo = await CoreGroups.getActivityGroupInfo(this.database.coursemodule); + if (this.groupInfo.visibleGroups && this.groupInfo.groups?.length) { + // There is a bug in Moodle with All participants and visible groups (MOBILE-3597). Remove it. + this.groupInfo.groups = this.groupInfo.groups.filter(group => group.id !== 0); + this.groupInfo.defaultGroupId = this.groupInfo.groups[0].id; + } + this.selectedGroup = CoreGroups.validateGroupId(this.selectedGroup, this.groupInfo); this.access = await AddonModData.getDatabaseAccessInformation(this.database.id, { diff --git a/src/addons/mod/data/pages/edit/edit.ts b/src/addons/mod/data/pages/edit/edit.ts index 208d9de72..52abfab1e 100644 --- a/src/addons/mod/data/pages/edit/edit.ts +++ b/src/addons/mod/data/pages/edit/edit.ts @@ -174,6 +174,12 @@ export class AddonModDataEditPage implements OnInit { if (refresh) { this.groupInfo = await CoreGroups.getActivityGroupInfo(this.database.coursemodule); + if (this.groupInfo.visibleGroups && this.groupInfo.groups?.length) { + // There is a bug in Moodle with All participants and visible groups (MOBILE-3597). Remove it. + this.groupInfo.groups = this.groupInfo.groups.filter(group => group.id !== 0); + this.groupInfo.defaultGroupId = this.groupInfo.groups[0].id; + } + this.selectedGroup = CoreGroups.validateGroupId(this.selectedGroup, this.groupInfo); this.initialSelectedGroup = this.selectedGroup; } diff --git a/src/addons/mod/data/pages/entry/entry.ts b/src/addons/mod/data/pages/entry/entry.ts index 648726a62..6bc442857 100644 --- a/src/addons/mod/data/pages/entry/entry.ts +++ b/src/addons/mod/data/pages/entry/entry.ts @@ -174,6 +174,12 @@ export class AddonModDataEntryPage implements OnInit, OnDestroy { this.access = await AddonModData.getDatabaseAccessInformation(this.database.id, { cmId: this.moduleId }); this.groupInfo = await CoreGroups.getActivityGroupInfo(this.database.coursemodule); + if (this.groupInfo.visibleGroups && this.groupInfo.groups?.length) { + // There is a bug in Moodle with All participants and visible groups (MOBILE-3597). Remove it. + this.groupInfo.groups = this.groupInfo.groups.filter(group => group.id !== 0); + this.groupInfo.defaultGroupId = this.groupInfo.groups[0].id; + } + this.selectedGroup = CoreGroups.validateGroupId(this.selectedGroup, this.groupInfo); const actions = AddonModDataHelper.getActions(this.database, this.access, this.entry!);