Skip to content

Commit

Permalink
fix(Manage Students): Student can end up in multiple workgroups (#1438)
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffreykwan authored Oct 3, 2023
1 parent 10f3da5 commit c0f3fb1
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 52 deletions.
28 changes: 8 additions & 20 deletions src/app/services/updateWorkgroupService.ts
Original file line number Diff line number Diff line change
@@ -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<any> {
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
}
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.`);
}
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,26 +88,26 @@ export class ManageTeamComponent {

private moveUser(event: CdkDragDrop<string[]>): 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.`);
}
});
}
}
24 changes: 19 additions & 5 deletions src/messages.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -12805,11 +12805,18 @@ Click &quot;Cancel&quot; to keep the invalid JSON open so you can fix it.</sourc
<context context-type="linenumber">47,49</context>
</context-group>
</trans-unit>
<trans-unit id="1914329737918937216" datatype="html">
<source>New team <x id="PH" equiv-text="newWorkgroupId"/> has been created.</source>
<trans-unit id="4783835659219359159" datatype="html">
<source>New Team <x id="PH" equiv-text="newWorkgroupId"/> has been created.</source>
<context-group purpose="location">
<context context-type="sourcefile">src/assets/wise5/classroomMonitor/classroomMonitorComponents/manageStudents/add-team-dialog/add-team-dialog.component.ts</context>
<context context-type="linenumber">81</context>
<context context-type="linenumber">82</context>
</context-group>
</trans-unit>
<trans-unit id="545651489407570329" datatype="html">
<source>Error: Could not create team.</source>
<context-group purpose="location">
<context context-type="sourcefile">src/assets/wise5/classroomMonitor/classroomMonitorComponents/manageStudents/add-team-dialog/add-team-dialog.component.ts</context>
<context context-type="linenumber">87</context>
</context-group>
</trans-unit>
<trans-unit id="6babfd035bd01c83b35e9440bd51b8b3b45e15d6" datatype="html">
Expand Down Expand Up @@ -13009,10 +13016,17 @@ Click &quot;Cancel&quot; to keep the invalid JSON open so you can fix it.</sourc
</context-group>
</trans-unit>
<trans-unit id="513458985182639179" datatype="html">
<source>Moved student to Team <x id="PH" equiv-text="this.team.workgroupId"/>.</source>
<source>Moved student to Team <x id="PH" equiv-text="workgroupId"/>.</source>
<context-group purpose="location">
<context context-type="sourcefile">src/assets/wise5/classroomMonitor/classroomMonitorComponents/manageStudents/manage-team/manage-team.component.ts</context>
<context context-type="linenumber">110</context>
<context context-type="linenumber">106</context>
</context-group>
</trans-unit>
<trans-unit id="784919496056996013" datatype="html">
<source>Error: Could not move student.</source>
<context-group purpose="location">
<context context-type="sourcefile">src/assets/wise5/classroomMonitor/classroomMonitorComponents/manageStudents/manage-team/manage-team.component.ts</context>
<context context-type="linenumber">109</context>
</context-group>
</trans-unit>
<trans-unit id="9b83b532c3f74e3d6e25a6ba749eef54324bea48" datatype="html">
Expand Down

0 comments on commit c0f3fb1

Please sign in to comment.