From 56a4414a386f47444c72234e4d349fa22dad88c8 Mon Sep 17 00:00:00 2001 From: Martin Schuhmacher <55735359+MartinSchuhmacher@users.noreply.github.com> Date: Mon, 11 Nov 2024 07:42:36 +0100 Subject: [PATCH] BC-8362 - RoomMember groups are shown in class administration and during sync of courses with groups (#5333) * allow more group types in filtering for class groups * specifying which groups can be chosen for course synch --- .../modules/group/domain/group-aggregate.scope.spec.ts | 9 +++++++++ .../src/modules/group/domain/group-aggregate.scope.ts | 9 +++++++++ apps/server/src/modules/group/uc/class-group.uc.spec.ts | 4 ++-- apps/server/src/modules/group/uc/class-group.uc.ts | 4 ++-- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/apps/server/src/modules/group/domain/group-aggregate.scope.spec.ts b/apps/server/src/modules/group/domain/group-aggregate.scope.spec.ts index bd37cd922fd..8c9a565b4ca 100644 --- a/apps/server/src/modules/group/domain/group-aggregate.scope.spec.ts +++ b/apps/server/src/modules/group/domain/group-aggregate.scope.spec.ts @@ -99,6 +99,15 @@ describe(GroupAggregateScope.name, () => { const result = new GroupAggregateScope().byAvailableForSync(true).build(); expect(result).toEqual([ + { + $match: { + $or: [ + { type: { $eq: GroupTypes.CLASS } }, + { type: { $eq: GroupTypes.COURSE } }, + { type: { $eq: GroupTypes.OTHER } }, + ], + }, + }, { $lookup: { from: 'courses', diff --git a/apps/server/src/modules/group/domain/group-aggregate.scope.ts b/apps/server/src/modules/group/domain/group-aggregate.scope.ts index 684836e34a6..1e2ffe9203a 100644 --- a/apps/server/src/modules/group/domain/group-aggregate.scope.ts +++ b/apps/server/src/modules/group/domain/group-aggregate.scope.ts @@ -29,6 +29,15 @@ export class GroupAggregateScope extends MongoDbScope { byAvailableForSync(value: boolean | undefined): this { if (value) { this.pipeline.push( + { + $match: { + $or: [ + { type: { $eq: GroupTypes.CLASS } }, + { type: { $eq: GroupTypes.COURSE } }, + { type: { $eq: GroupTypes.OTHER } }, + ], + }, + }, { $lookup: { from: 'courses', diff --git a/apps/server/src/modules/group/uc/class-group.uc.spec.ts b/apps/server/src/modules/group/uc/class-group.uc.spec.ts index 1dd1f18dc5d..b19e866c704 100644 --- a/apps/server/src/modules/group/uc/class-group.uc.spec.ts +++ b/apps/server/src/modules/group/uc/class-group.uc.spec.ts @@ -414,7 +414,7 @@ describe('ClassGroupUc', () => { expect(groupService.findGroups).toHaveBeenCalledWith<[GroupFilter]>({ userId: teacherUser.id, - groupTypes: [GroupTypes.CLASS], + groupTypes: [GroupTypes.CLASS, GroupTypes.COURSE, GroupTypes.OTHER], }); }); }); @@ -777,7 +777,7 @@ describe('ClassGroupUc', () => { expect(groupService.findGroups).toHaveBeenCalledWith<[GroupFilter]>({ schoolId: teacherUser.school.id, - groupTypes: [GroupTypes.CLASS], + groupTypes: [GroupTypes.CLASS, GroupTypes.COURSE, GroupTypes.OTHER], }); }); }); diff --git a/apps/server/src/modules/group/uc/class-group.uc.ts b/apps/server/src/modules/group/uc/class-group.uc.ts index bede2d7441b..77ce030d3df 100644 --- a/apps/server/src/modules/group/uc/class-group.uc.ts +++ b/apps/server/src/modules/group/uc/class-group.uc.ts @@ -217,7 +217,7 @@ export class ClassGroupUc { } private async findGroupsForSchool(schoolId: EntityId): Promise { - const filter: GroupFilter = { schoolId, groupTypes: [GroupTypes.CLASS] }; + const filter: GroupFilter = { schoolId, groupTypes: [GroupTypes.CLASS, GroupTypes.COURSE, GroupTypes.OTHER] }; const groups: Page = await this.groupService.findGroups(filter); @@ -227,7 +227,7 @@ export class ClassGroupUc { } private async findGroupsForUser(userId: EntityId): Promise { - const filter: GroupFilter = { userId, groupTypes: [GroupTypes.CLASS] }; + const filter: GroupFilter = { userId, groupTypes: [GroupTypes.CLASS, GroupTypes.COURSE, GroupTypes.OTHER] }; const groups: Page = await this.groupService.findGroups(filter);