-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(GradingStepToolsComponent): extend StepToolsComponent for us…
…e in Teacher Tools (#2019)
- Loading branch information
1 parent
994bbd9
commit 00ea8b6
Showing
9 changed files
with
174 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
...onitor/classroomMonitorComponents/grading-step-tools/grading-step-tools.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { GradingStepToolsComponent } from './grading-step-tools.component'; | ||
import { ClassroomMonitorTestingModule } from '../../classroom-monitor-testing.module'; | ||
|
||
describe('GradingStepToolsComponent', () => { | ||
let component: GradingStepToolsComponent; | ||
let fixture: ComponentFixture<GradingStepToolsComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [GradingStepToolsComponent, ClassroomMonitorTestingModule] | ||
}).compileComponents(); | ||
|
||
fixture = TestBed.createComponent(GradingStepToolsComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
58 changes: 58 additions & 0 deletions
58
...roomMonitor/classroomMonitorComponents/grading-step-tools/grading-step-tools.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
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'; | ||
import { MatIconModule } from '@angular/material/icon'; | ||
import { MatSelectModule } from '@angular/material/select'; | ||
import { FlexLayoutModule } from '@angular/flex-layout'; | ||
import { MatTooltipModule } from '@angular/material/tooltip'; | ||
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, | ||
imports: [ | ||
CommonModule, | ||
FlexLayoutModule, | ||
FormsModule, | ||
MatButtonModule, | ||
MatFormFieldModule, | ||
MatIconModule, | ||
MatInputModule, | ||
MatSelectModule, | ||
MatTooltipModule, | ||
NodeIconComponent | ||
], | ||
selector: 'grading-step-tools', | ||
standalone: true, | ||
templateUrl: '../../../common/stepTools/step-tools.component.html', | ||
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) => { | ||
return this.isGroupNode(nodeId) || this.projectService.nodeHasWork(nodeId); | ||
}); | ||
this.nodeIds.shift(); // remove the 'group0' master root node from consideration | ||
} | ||
|
||
protected getNextNodeId(): Promise<any> { | ||
return Promise.resolve(this.nodeService.getNextNodeId(this.nodeId)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
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<string> { | ||
return super.getNextNodeId(currentId).then((nextNodeId: string) => { | ||
if (!nextNodeId) return null; | ||
return this.ProjectService.nodeHasWork(nextNodeId) | ||
? nextNodeId | ||
: this.getNextNodeId(nextNodeId); | ||
}); | ||
} | ||
|
||
/** | ||
* Go to the next node that captures work | ||
* @return a promise that will return the next node id | ||
*/ | ||
goToNextNode(): Promise<string> { | ||
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) return null; | ||
return this.ProjectService.nodeHasWork(prevNodeId) | ||
? prevNodeId | ||
: this.getPrevNodeId(prevNodeId); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.