diff --git a/src/assets/wise5/classroomMonitor/classroomMonitorComponents/nodeProgress/nav-item/nav-item.component.spec.ts b/src/assets/wise5/classroomMonitor/classroomMonitorComponents/nodeProgress/nav-item/nav-item.component.spec.ts index 1a22fca8192..a9308772347 100644 --- a/src/assets/wise5/classroomMonitor/classroomMonitorComponents/nodeProgress/nav-item/nav-item.component.spec.ts +++ b/src/assets/wise5/classroomMonitor/classroomMonitorComponents/nodeProgress/nav-item/nav-item.component.spec.ts @@ -40,6 +40,9 @@ class MockTeacherProjectService { isGroupNode() {} nodeHasWork() {} getMaxScoreForNode() {} + getNodeById() { + return { constraints: [] }; + } getNode() { return new Node(); } @@ -121,7 +124,7 @@ function toggleLockNode() { }); describe('when there is no teacherRemovalConstraint', () => { it('should add constraint', () => { - const getNodeSpy = spyOn(projectService, 'getNode').and.returnValue(node1); + const getNodeSpy = spyOn(projectService, 'getNodeById').and.returnValue(node1); expect(node1.constraints.length).toEqual(0); lockNodeButton.click(); expect(getNodeSpy).toHaveBeenCalled(); @@ -141,7 +144,7 @@ function toggleLockNode() { Object({ name: 'teacherRemoval', params: Object({ periodId: periodId }) }) ] }); - const getNodeSpy = spyOn(projectService, 'getNode').and.returnValue(node1); + const getNodeSpy = spyOn(projectService, 'getNodeById').and.returnValue(node1); const dataService = TestBed.inject(TeacherDataService); const currentPeriodSpy = spyOn(dataService, 'getCurrentPeriod').and.returnValue({ periodId: periodId diff --git a/src/assets/wise5/classroomMonitor/classroomMonitorComponents/nodeProgress/nav-item/nav-item.component.ts b/src/assets/wise5/classroomMonitor/classroomMonitorComponents/nodeProgress/nav-item/nav-item.component.ts index cdd994ac3b8..a4f7cd6ef73 100644 --- a/src/assets/wise5/classroomMonitor/classroomMonitorComponents/nodeProgress/nav-item/nav-item.component.ts +++ b/src/assets/wise5/classroomMonitor/classroomMonitorComponents/nodeProgress/nav-item/nav-item.component.ts @@ -187,7 +187,7 @@ export class NavItemComponent implements OnInit { } isLocked(): boolean { - const constraints = this.projectService.getNode(this.nodeId).constraints; + const constraints = this.projectService.getNodeById(this.nodeId).constraints ?? []; return ( (this.isShowingAllPeriods() && this.isLockedForAll(constraints)) || (!this.isShowingAllPeriods() && @@ -218,7 +218,7 @@ export class NavItemComponent implements OnInit { } protected toggleLockNode(): void { - const node = this.projectService.getNode(this.nodeId); + const node = this.projectService.getNodeById(this.nodeId); const isLocked = this.isLocked(); if (isLocked) { this.unlockNode(node); @@ -270,7 +270,10 @@ export class NavItemComponent implements OnInit { } ] }; - node.addConstraint(lockConstraint); + if (node.constraints == null) { + node.constraints = []; + } + node.constraints.push(lockConstraint); } private unlockNodeForAllPeriods(node: Node): void { diff --git a/src/messages.xlf b/src/messages.xlf index a3bc1b72bbd..99d87d209b6 100644 --- a/src/messages.xlf +++ b/src/messages.xlf @@ -14218,7 +14218,7 @@ Click "Cancel" to keep the invalid JSON open so you can fix it.All Periods src/assets/wise5/classroomMonitor/classroomMonitorComponents/nodeProgress/nav-item/nav-item.component.ts - 371 + 374 src/assets/wise5/classroomMonitor/classroomMonitorComponents/select-period/select-period.component.ts @@ -14233,7 +14233,7 @@ Click "Cancel" to keep the invalid JSON open so you can fix it.Period: src/assets/wise5/classroomMonitor/classroomMonitorComponents/nodeProgress/nav-item/nav-item.component.ts - 372 + 375 src/assets/wise5/classroomMonitor/classroomMonitorComponents/select-period/select-period.component.ts @@ -14244,14 +14244,14 @@ Click "Cancel" to keep the invalid JSON open so you can fix it.Unlock for src/assets/wise5/classroomMonitor/classroomMonitorComponents/nodeProgress/nav-item/nav-item.component.ts - 377 + 380 Lock for src/assets/wise5/classroomMonitor/classroomMonitorComponents/nodeProgress/nav-item/nav-item.component.ts - 378 + 381