From c0f3fb1c3e38a1c409899f3fa024e1d50718b2c8 Mon Sep 17 00:00:00 2001 From: Geoffrey Kwan Date: Tue, 3 Oct 2023 18:04:38 -0400 Subject: [PATCH] fix(Manage Students): Student can end up in multiple workgroups (#1438) --- src/app/services/updateWorkgroupService.ts | 28 ++++--------- .../add-team-dialog.component.ts | 19 +++++---- .../manage-team/manage-team.component.ts | 40 +++++++++---------- src/messages.xlf | 24 ++++++++--- 4 files changed, 59 insertions(+), 52 deletions(-) diff --git a/src/app/services/updateWorkgroupService.ts b/src/app/services/updateWorkgroupService.ts index ac1d38e3efc..bd4cbcf0e69 100644 --- a/src/app/services/updateWorkgroupService.ts +++ b/src/app/services/updateWorkgroupService.ts @@ -1,35 +1,23 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { ConfigService } from '../../assets/wise5/services/configService'; -import { TeacherDataService } from '../../assets/wise5/services/teacherDataService'; +import { Observable } from 'rxjs'; @Injectable() export class UpdateWorkgroupService { - constructor( - private ConfigService: ConfigService, - private TeacherDataService: TeacherDataService, - private http: HttpClient - ) {} + constructor(private configService: ConfigService, private http: HttpClient) {} /** - * Move student between workgroups, or to/from workgroup and unassigned students + * Move student to a workgroup * @param userId Student User ID - * @param workgroupIdFrom Workgroup ID to move student from. -1 if student is not in a workgroup - * @param workgroupIdTo Workgroup ID to move student to. -1 if moving student to unassigned - * @param periodId Period ID the student is in. + * @param workgroupIdTo Workgroup ID to move student to + * @return Observable of move student response */ - moveMember( - userId: number, - workgroupIdFrom: number = -1, - workgroupIdTo: number = -1, - periodId: number = this.TeacherDataService.getCurrentPeriodId() - ) { + moveMember(userId: number, workgroupIdTo: number): Observable { return this.http.post( - `/api/teacher/run/${this.ConfigService.getRunId()}/workgroup/move-user/${userId}`, + `/api/teacher/run/${this.configService.getRunId()}/workgroup/move-user/${userId}`, { - workgroupIdFrom: workgroupIdFrom, - workgroupIdTo: workgroupIdTo, - periodId: periodId + workgroupIdTo: workgroupIdTo } ); } diff --git a/src/assets/wise5/classroomMonitor/classroomMonitorComponents/manageStudents/add-team-dialog/add-team-dialog.component.ts b/src/assets/wise5/classroomMonitor/classroomMonitorComponents/manageStudents/add-team-dialog/add-team-dialog.component.ts index 563c3f730b4..2e2dcde6c7f 100644 --- a/src/assets/wise5/classroomMonitor/classroomMonitorComponents/manageStudents/add-team-dialog/add-team-dialog.component.ts +++ b/src/assets/wise5/classroomMonitor/classroomMonitorComponents/manageStudents/add-team-dialog/add-team-dialog.component.ts @@ -74,13 +74,18 @@ export class AddTeamDialogComponent { this.period.periodId, this.initialTeamMembers.map((member) => member.id) ) - .subscribe((newWorkgroupId: number) => { - this.configService.retrieveConfig( - `/api/config/classroomMonitor/${this.configService.getRunId()}` - ); - this.snackBar.open($localize`New team ${newWorkgroupId} has been created.`); - this.isProcessing = false; - this.dialog.closeAll(); + .subscribe({ + next: (newWorkgroupId: number) => { + this.configService.retrieveConfig( + `/api/config/classroomMonitor/${this.configService.getRunId()}` + ); + this.snackBar.open($localize`New Team ${newWorkgroupId} has been created.`); + this.isProcessing = false; + this.dialog.closeAll(); + }, + error: () => { + this.snackBar.open($localize`Error: Could not create team.`); + } }); } diff --git a/src/assets/wise5/classroomMonitor/classroomMonitorComponents/manageStudents/manage-team/manage-team.component.ts b/src/assets/wise5/classroomMonitor/classroomMonitorComponents/manageStudents/manage-team/manage-team.component.ts index 1b8b89abbf5..74230f4ecff 100644 --- a/src/assets/wise5/classroomMonitor/classroomMonitorComponents/manageStudents/manage-team/manage-team.component.ts +++ b/src/assets/wise5/classroomMonitor/classroomMonitorComponents/manageStudents/manage-team/manage-team.component.ts @@ -88,26 +88,26 @@ export class ManageTeamComponent { private moveUser(event: CdkDragDrop): void { this.updateWorkgroupService - .moveMember( - event.item.data.user.id, - event.item.data.workgroupId, - this.team.workgroupId, - this.team.periodId - ) - .subscribe(() => { - const previousIndex = event.previousContainer.data.findIndex( - (user) => user === event.item.data.user - ); - transferArrayItem( - event.previousContainer.data, - event.container.data, - previousIndex, - event.currentIndex - ); - this.configService.retrieveConfig( - `/api/config/classroomMonitor/${this.configService.getRunId()}` - ); - this.snackBar.open($localize`Moved student to Team ${this.team.workgroupId}.`); + .moveMember(event.item.data.user.id, this.team.workgroupId) + .subscribe({ + next: (workgroupId: number) => { + const previousIndex = event.previousContainer.data.findIndex( + (user) => user === event.item.data.user + ); + transferArrayItem( + event.previousContainer.data, + event.container.data, + previousIndex, + event.currentIndex + ); + this.configService.retrieveConfig( + `/api/config/classroomMonitor/${this.configService.getRunId()}` + ); + this.snackBar.open($localize`Moved student to Team ${workgroupId}.`); + }, + error: () => { + this.snackBar.open($localize`Error: Could not move student.`); + } }); } } diff --git a/src/messages.xlf b/src/messages.xlf index 9a628324a43..c5525d9c17e 100644 --- a/src/messages.xlf +++ b/src/messages.xlf @@ -12805,11 +12805,18 @@ Click "Cancel" to keep the invalid JSON open so you can fix it.47,49 - - New team has been created. + + New Team has been created. src/assets/wise5/classroomMonitor/classroomMonitorComponents/manageStudents/add-team-dialog/add-team-dialog.component.ts - 81 + 82 + + + + Error: Could not create team. + + src/assets/wise5/classroomMonitor/classroomMonitorComponents/manageStudents/add-team-dialog/add-team-dialog.component.ts + 87 @@ -13009,10 +13016,17 @@ Click "Cancel" to keep the invalid JSON open so you can fix it. - Moved student to Team . + Moved student to Team . src/assets/wise5/classroomMonitor/classroomMonitorComponents/manageStudents/manage-team/manage-team.component.ts - 110 + 106 + + + + Error: Could not move student. + + src/assets/wise5/classroomMonitor/classroomMonitorComponents/manageStudents/manage-team/manage-team.component.ts + 109