diff --git a/src/app/teacher/classroom-monitor.module.ts b/src/app/teacher/classroom-monitor.module.ts index 1c396bef785..5d4e5bf2d52 100644 --- a/src/app/teacher/classroom-monitor.module.ts +++ b/src/app/teacher/classroom-monitor.module.ts @@ -35,6 +35,7 @@ import { PreviewComponentComponent } from '../../assets/wise5/authoringTool/comp import { ComponentGradingComponent } from '../../assets/wise5/classroomMonitor/classroomMonitorComponents/component-grading.component'; import { SelectPeriodComponent } from '../../assets/wise5/classroomMonitor/classroomMonitorComponents/select-period/select-period.component'; import { GradingStepToolsComponent } from '../../assets/wise5/classroomMonitor/classroomMonitorComponents/grading-step-tools/grading-step-tools.component'; +import { GradingNodeService } from '../../assets/wise5/services/gradingNodeService'; @NgModule({ declarations: [ @@ -76,6 +77,7 @@ import { GradingStepToolsComponent } from '../../assets/wise5/classroomMonitor/c StepInfoComponent, StudentTeacherCommonModule, TeacherSummaryDisplayComponent - ] + ], + providers: [GradingNodeService] }) export class ClassroomMonitorModule {} diff --git a/src/assets/wise5/classroomMonitor/classroom-monitor-testing.module.ts b/src/assets/wise5/classroomMonitor/classroom-monitor-testing.module.ts index 4c43087a0c2..bc446eec3cc 100644 --- a/src/assets/wise5/classroomMonitor/classroom-monitor-testing.module.ts +++ b/src/assets/wise5/classroomMonitor/classroom-monitor-testing.module.ts @@ -14,6 +14,7 @@ import { MilestoneReportService } from '../services/milestoneReportService'; import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http'; import { TeacherPauseScreenService } from '../services/teacherPauseScreenService'; import { RunStatusService } from '../services/runStatusService'; +import { GradingNodeService } from '../services/gradingNodeService'; @NgModule({ imports: [ @@ -24,6 +25,7 @@ import { RunStatusService } from '../services/runStatusService'; ], providers: [ ClassroomStatusService, + GradingNodeService, MilestoneService, MilestoneReportService, TeacherDataService, diff --git a/src/assets/wise5/classroomMonitor/classroomMonitorComponents/grading-step-tools/grading-step-tools.component.ts b/src/assets/wise5/classroomMonitor/classroomMonitorComponents/grading-step-tools/grading-step-tools.component.ts index 6f1541ef966..5094d56d5a3 100644 --- a/src/assets/wise5/classroomMonitor/classroomMonitorComponents/grading-step-tools/grading-step-tools.component.ts +++ b/src/assets/wise5/classroomMonitor/classroomMonitorComponents/grading-step-tools/grading-step-tools.component.ts @@ -1,4 +1,5 @@ import { Component, ViewEncapsulation } from '@angular/core'; +import { Directionality } from '@angular/cdk/bidi'; import { StepToolsComponent } from '../../../common/stepTools/step-tools.component'; import { MatButtonModule } from '@angular/material/button'; import { MatFormFieldModule } from '@angular/material/form-field'; @@ -10,6 +11,9 @@ import { CommonModule } from '@angular/common'; import { FormsModule } from '@angular/forms'; import { MatInputModule } from '@angular/material/input'; import { NodeIconComponent } from '../../../vle/node-icon/node-icon.component'; +import { TeacherDataService } from '../../../services/teacherDataService'; +import { GradingNodeService } from '../../../services/gradingNodeService'; +import { TeacherProjectService } from '../../../services/teacherProjectService'; @Component({ encapsulation: ViewEncapsulation.None, @@ -31,6 +35,15 @@ import { NodeIconComponent } from '../../../vle/node-icon/node-icon.component'; styleUrl: '../../../common/stepTools/step-tools.component.scss' }) export class GradingStepToolsComponent extends StepToolsComponent { + constructor( + protected dataService: TeacherDataService, + protected dir: Directionality, + protected nodeService: GradingNodeService, + protected projectService: TeacherProjectService + ) { + super(dataService, dir, nodeService, projectService); + } + protected calculateNodeIds(): void { this.nodeIds = Object.keys(this.projectService.idToOrder); this.nodeIds = this.nodeIds.filter((nodeId) => { @@ -39,22 +52,7 @@ export class GradingStepToolsComponent extends StepToolsComponent { this.nodeIds.shift(); // remove the 'group0' master root node from consideration } - protected getPrevNodeId(): string { - return this.nodeService.getPrevNodeIdWithWork(this.nodeId); - } - protected getNextNodeId(): Promise { - return Promise.resolve(this.nodeService.getNextNodeIdWithWork(this.nodeId)); - } - - protected goToPrevNode(): void { - this.nodeService.goToPrevNodeWithWork(); - this.nodeId = this.dataService.getCurrentNodeId(); - } - - protected goToNextNode(): void { - this.nodeService.goToNextNodeWithWork().then((nodeId: string) => { - this.nodeId = nodeId; - }); + return Promise.resolve(this.nodeService.getNextNodeId(this.nodeId)); } } diff --git a/src/assets/wise5/common/stepTools/step-tools.component.ts b/src/assets/wise5/common/stepTools/step-tools.component.ts index 9553d525130..8866450e69a 100644 --- a/src/assets/wise5/common/stepTools/step-tools.component.ts +++ b/src/assets/wise5/common/stepTools/step-tools.component.ts @@ -44,7 +44,7 @@ export class StepToolsComponent { constructor( protected dataService: TeacherDataService, - private dir: Directionality, + protected dir: Directionality, protected nodeService: NodeService, protected projectService: TeacherProjectService ) {} diff --git a/src/assets/wise5/services/gradingNodeService.ts b/src/assets/wise5/services/gradingNodeService.ts new file mode 100644 index 00000000000..58065447bd2 --- /dev/null +++ b/src/assets/wise5/services/gradingNodeService.ts @@ -0,0 +1,62 @@ +import { Injectable } from '@angular/core'; +import { TeacherNodeService } from './teacherNodeService'; + +@Injectable() +export class GradingNodeService extends TeacherNodeService { + /** + * Get the next node id in the project sequence that captures student work + * @param currentId (optional) + * @returns next node id + */ + getNextNodeId(currentId = null): Promise { + return super.getNextNodeId(currentId).then((nextNodeId: string) => { + if (nextNodeId) { + if (this.ProjectService.nodeHasWork(nextNodeId)) { + return nextNodeId; + } else { + return this.getNextNodeId(nextNodeId); + } + } else { + return null; + } + }); + } + + /** + * Go to the next node that captures work + * @return a promise that will return the next node id + */ + goToNextNode(): Promise { + return this.getNextNodeId().then((nextNodeId: string) => { + if (nextNodeId) { + this.setCurrentNode(nextNodeId); + } + return nextNodeId; + }); + } + + /** + * Go to the previous node that captures work + */ + goToPrevNode(): void { + this.setCurrentNode(this.getPrevNodeId()); + } + + /** + * Get the previous node id in the project sequence that captures student work + * @param currentId (optional) + * @returns next node id + */ + getPrevNodeId(currentId = null) { + const prevNodeId = super.getPrevNodeId(currentId); + if (prevNodeId) { + if (this.ProjectService.nodeHasWork(prevNodeId)) { + return prevNodeId; + } else { + return this.getPrevNodeId(prevNodeId); + } + } else { + return null; + } + } +} diff --git a/src/assets/wise5/services/nodeService.ts b/src/assets/wise5/services/nodeService.ts index 9db1712ccbd..9ae6d4037a8 100644 --- a/src/assets/wise5/services/nodeService.ts +++ b/src/assets/wise5/services/nodeService.ts @@ -48,38 +48,6 @@ export class NodeService { return null; } - /** - * Go to the next node that captures work - * @return a promise that will return the next node id - */ - goToNextNodeWithWork(): Promise { - return this.getNextNodeIdWithWork().then((nextNodeId: string) => { - if (nextNodeId) { - this.setCurrentNode(nextNodeId); - } - return nextNodeId; - }); - } - - /** - * Get the next node id in the project sequence that captures student work - * @param currentId (optional) - * @returns next node id - */ - getNextNodeIdWithWork(currentId = null) { - return this.getNextNodeId(currentId).then((nextNodeId: string) => { - if (nextNodeId) { - if (this.ProjectService.nodeHasWork(nextNodeId)) { - return nextNodeId; - } else { - return this.getNextNodeIdWithWork(nextNodeId); - } - } else { - return null; - } - }); - } - goToPrevNode() { const prevNodeId = this.getPrevNodeId(); this.setCurrentNode(prevNodeId); @@ -131,32 +99,6 @@ export class NodeService { return prevNodeId; } - /** - * Go to the previous node that captures work - */ - goToPrevNodeWithWork() { - const prevNodeId = this.getPrevNodeIdWithWork(); - this.setCurrentNode(prevNodeId); - } - - /** - * Get the previous node id in the project sequence that captures student work - * @param currentId (optional) - * @returns next node id - */ - getPrevNodeIdWithWork(currentId = null) { - const prevNodeId = this.getPrevNodeId(currentId); - if (prevNodeId) { - if (this.ProjectService.nodeHasWork(prevNodeId)) { - return prevNodeId; - } else { - return this.getPrevNodeIdWithWork(prevNodeId); - } - } else { - return null; - } - } - /** * Close the current node (and open the current node's parent group) */