diff --git a/src/assets/wise5/classroomMonitor/classroomMonitorComponents/peer-group/peer-group-dialog/peer-group-dialog.component.ts b/src/assets/wise5/classroomMonitor/classroomMonitorComponents/peer-group/peer-group-dialog/peer-group-dialog.component.ts index 36d6678f913..d15dd944976 100644 --- a/src/assets/wise5/classroomMonitor/classroomMonitorComponents/peer-group/peer-group-dialog/peer-group-dialog.component.ts +++ b/src/assets/wise5/classroomMonitor/classroomMonitorComponents/peer-group/peer-group-dialog/peer-group-dialog.component.ts @@ -7,38 +7,38 @@ import { TeacherProjectService } from '../../../../services/teacherProjectServic @Component({ selector: 'peer-group-dialog', templateUrl: './peer-group-dialog.component.html', - styleUrls: ['./peer-group-dialog.component.scss'] + styleUrl: './peer-group-dialog.component.scss' }) export class PeerGroupDialogComponent implements OnInit { - currentPeriodChangedSubscription: Subscription; - peerGroupingName: string; - periods: any[]; + private currentPeriodChangedSubscription: Subscription; + protected peerGroupingName: string; + protected periods: any[]; constructor( + private dataService: TeacherDataService, @Inject(MAT_DIALOG_DATA) public peerGroupingTag: string, - private teacherDataService: TeacherDataService, - private teacherProjectService: TeacherProjectService + private projectService: TeacherProjectService ) {} - ngOnInit() { - this.setPeriods(this.teacherDataService.getCurrentPeriodId()); - this.peerGroupingName = this.teacherProjectService.getPeerGrouping(this.peerGroupingTag).name; - this.subscribeToPeriodChanged(); - } - - subscribeToPeriodChanged(): void { - this.currentPeriodChangedSubscription = this.teacherDataService.currentPeriodChanged$.subscribe( + ngOnInit(): void { + this.setPeriods(this.dataService.getCurrentPeriodId()); + this.peerGroupingName = this.projectService.getPeerGrouping(this.peerGroupingTag).name; + this.currentPeriodChangedSubscription = this.dataService.currentPeriodChanged$.subscribe( ({ currentPeriod }) => { this.setPeriods(currentPeriod.periodId); } ); } - setPeriods(periodId: number): void { - this.periods = this.teacherDataService.getVisiblePeriodsById(periodId); + ngOnDestroy(): void { + this.currentPeriodChangedSubscription.unsubscribe(); } - ngOnDestroy() { - this.currentPeriodChangedSubscription.unsubscribe(); + private setPeriods(periodId: number): void { + const allPeriods = this.dataService.getPeriods(); + this.periods = + periodId === -1 + ? allPeriods.slice(1) + : [allPeriods.find((period) => period.periodId === periodId)]; } } diff --git a/src/assets/wise5/services/teacherDataService.ts b/src/assets/wise5/services/teacherDataService.ts index f40c7706836..a29de7f1dd2 100644 --- a/src/assets/wise5/services/teacherDataService.ts +++ b/src/assets/wise5/services/teacherDataService.ts @@ -578,14 +578,6 @@ export class TeacherDataService extends DataService { this.periods = periods; } - getVisiblePeriodsById(currentPeriodId: number): any { - if (currentPeriodId === -1) { - return this.getPeriods().slice(1); - } else { - return [this.getPeriodById(currentPeriodId)]; - } - } - setCurrentWorkgroup(workgroup) { this.currentWorkgroup = workgroup; this.broadcastCurrentWorkgroupChanged({ currentWorkgroup: this.currentWorkgroup }); @@ -613,10 +605,6 @@ export class TeacherDataService extends DataService { ); } - private getPeriodById(periodId: number): any { - return this.getPeriods().find((period) => period.periodId === periodId); - } - isWorkgroupShown(workgroup): boolean { return ( this.isWorkgroupInCurrentPeriod(workgroup) &&