-
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.
feat(GradingNodeService): Extract from NodeService and clean up code.
- Loading branch information
1 parent
0925c18
commit 67d92dd
Showing
6 changed files
with
82 additions
and
76 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
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,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<string> { | ||
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<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) { | ||
if (this.ProjectService.nodeHasWork(prevNodeId)) { | ||
return prevNodeId; | ||
} else { | ||
return this.getPrevNodeId(prevNodeId); | ||
} | ||
} else { | ||
return null; | ||
} | ||
} | ||
} |
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