-
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.
- Loading branch information
1 parent
442336e
commit 10b4dff
Showing
5 changed files
with
182 additions
and
173 deletions.
There are no files selected for viewing
78 changes: 78 additions & 0 deletions
78
src/assets/wise5/directives/dynamic-prompt/DynamicPromptEvaluator.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,78 @@ | ||
import { Observable, concatMap, map } from 'rxjs'; | ||
import { Component } from '../../common/Component'; | ||
import { PeerGroupStudentData } from '../../../../app/domain/peerGroupStudentData'; | ||
import { PeerGroup } from '../../components/peerChat/PeerGroup'; | ||
import { DynamicPromptComponent } from './dynamic-prompt.component'; | ||
import { FeedbackRuleEvaluator } from '../../components/common/feedbackRule/FeedbackRuleEvaluator'; | ||
import { Response } from '../../components/common/feedbackRule/Response'; | ||
import { FeedbackRuleEvaluatorMultipleStudents } from '../../components/common/feedbackRule/FeedbackRuleEvaluatorMultipleStudents'; | ||
import { FeedbackRuleComponent } from '../../components/feedbackRule/FeedbackRuleComponent'; | ||
import { FeedbackRule } from '../../components/common/feedbackRule/FeedbackRule'; | ||
|
||
export abstract class DynamicPromptEvaluator { | ||
constructor(protected component: DynamicPromptComponent) {} | ||
|
||
evaluate(referenceComponent: Component): void { | ||
if (this.component.dynamicPrompt.isPeerGroupingTagSpecified()) { | ||
this.evaluatePeerGroup(referenceComponent); | ||
} else { | ||
this.evaluatePersonal(referenceComponent); | ||
} | ||
} | ||
|
||
protected getFeedbackRuleEvaluator( | ||
referenceComponent: Component | ||
): FeedbackRuleEvaluator<Response[]> { | ||
const evaluator = this.component.dynamicPrompt.isPeerGroupingTagSpecified() | ||
? new FeedbackRuleEvaluatorMultipleStudents( | ||
new FeedbackRuleComponent( | ||
this.component.dynamicPrompt.getRules(), | ||
referenceComponent.content.maxSubmitCount, | ||
false | ||
), | ||
this.component.constraintService | ||
) | ||
: new FeedbackRuleEvaluator( | ||
new FeedbackRuleComponent( | ||
this.component.dynamicPrompt.getRules(), | ||
referenceComponent.content.maxSubmitCount, | ||
false | ||
), | ||
this.component.constraintService | ||
); | ||
evaluator.setReferenceComponent(referenceComponent); | ||
return evaluator; | ||
} | ||
|
||
protected getPeerGroupData(): Observable<PeerGroupStudentData[]> { | ||
return this.component.peerGroupService | ||
.retrievePeerGroup(this.component.dynamicPrompt.getPeerGroupingTag()) | ||
.pipe( | ||
concatMap((peerGroup: PeerGroup) => { | ||
return this.component.peerGroupService | ||
.retrieveDynamicPromptStudentData( | ||
peerGroup.id, | ||
this.component.nodeId, | ||
this.component.componentId | ||
) | ||
.pipe( | ||
map((peerGroupStudentData: PeerGroupStudentData[]) => { | ||
return peerGroupStudentData; | ||
}) | ||
); | ||
}) | ||
); | ||
} | ||
|
||
protected getSubmitCounter(componentState: any): number { | ||
return componentState.studentData.submitCounter; | ||
} | ||
|
||
protected setPromptAndEmitRule(feedbackRule: FeedbackRule): void { | ||
this.component.prompt = feedbackRule.prompt; | ||
this.component.dynamicPromptChanged.emit(feedbackRule); // TODO: change to two-way binding variable | ||
} | ||
|
||
abstract evaluatePeerGroup(referenceComponent: Component): void; | ||
abstract evaluatePersonal(referenceComponent: Component): void; | ||
} |
32 changes: 32 additions & 0 deletions
32
src/assets/wise5/directives/dynamic-prompt/DynamicPromptMultipleChoiceEvaluator.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,32 @@ | ||
import { PeerGroupStudentData } from '../../../../app/domain/peerGroupStudentData'; | ||
import { Component } from '../../common/Component'; | ||
import { Response } from '../../components/common/feedbackRule/Response'; | ||
import { DynamicPromptEvaluator } from './DynamicPromptEvaluator'; | ||
|
||
export class DynamicPromptMultipleChoiceEvaluator extends DynamicPromptEvaluator { | ||
evaluatePeerGroup(referenceComponent: Component): void { | ||
this.getPeerGroupData().subscribe((peerGroupStudentData: PeerGroupStudentData[]) => { | ||
const responses = peerGroupStudentData.map((peerMemberData: PeerGroupStudentData) => { | ||
return new Response({ | ||
submitCounter: this.getSubmitCounter(peerMemberData.studentWork) | ||
}); | ||
}); | ||
const feedbackRuleEvaluator = this.getFeedbackRuleEvaluator(referenceComponent); | ||
this.setPromptAndEmitRule(feedbackRuleEvaluator.getFeedbackRule(responses)); | ||
}); | ||
} | ||
|
||
evaluatePersonal(referenceComponent: Component): void { | ||
const feedbackRuleEvaluator = this.getFeedbackRuleEvaluator(referenceComponent); | ||
const nodeId = this.component.dynamicPrompt.getReferenceNodeId(); | ||
const componentId = referenceComponent.content.id; | ||
const latestComponentState = this.component.dataService.getLatestComponentStateByNodeIdAndComponentId( | ||
nodeId, | ||
componentId | ||
); | ||
const response = new Response({ | ||
submitCounter: this.getSubmitCounter(latestComponentState) | ||
}); | ||
this.setPromptAndEmitRule(feedbackRuleEvaluator.getFeedbackRule([response])); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
src/assets/wise5/directives/dynamic-prompt/DynamicPromptOpenResponseEvaluator.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,44 @@ | ||
import { PeerGroupStudentData } from '../../../../app/domain/peerGroupStudentData'; | ||
import { Component } from '../../common/Component'; | ||
import { CRaterResponse } from '../../components/common/cRater/CRaterResponse'; | ||
import { DynamicPromptEvaluator } from './DynamicPromptEvaluator'; | ||
|
||
export class DynamicPromptOpenResponseEvaluator extends DynamicPromptEvaluator { | ||
evaluatePeerGroup(referenceComponent: Component): void { | ||
this.getPeerGroupData().subscribe((peerGroupStudentData: PeerGroupStudentData[]) => { | ||
const cRaterResponses = peerGroupStudentData.map((peerMemberData: PeerGroupStudentData) => { | ||
return new CRaterResponse({ | ||
ideas: peerMemberData.annotation.data.ideas, | ||
scores: peerMemberData.annotation.data.scores, | ||
submitCounter: this.getSubmitCounter(peerMemberData.studentWork) | ||
}); | ||
}); | ||
const feedbackRuleEvaluator = this.getFeedbackRuleEvaluator(referenceComponent); | ||
this.setPromptAndEmitRule(feedbackRuleEvaluator.getFeedbackRule(cRaterResponses)); | ||
}); | ||
} | ||
|
||
evaluatePersonal(referenceComponent: Component): void { | ||
const nodeId = this.component.dynamicPrompt.getReferenceNodeId(); | ||
const componentId = referenceComponent.content.id; | ||
const latestComponentState = this.component.dataService.getLatestComponentStateByNodeIdAndComponentId( | ||
nodeId, | ||
componentId | ||
); | ||
const latestAutoScoreAnnotation = this.component.annotationService.getLatestScoreAnnotation( | ||
nodeId, | ||
componentId, | ||
this.component.configService.getWorkgroupId(), | ||
'autoScore' | ||
); | ||
if (latestComponentState != null && latestAutoScoreAnnotation != null) { | ||
const cRaterResponse = new CRaterResponse({ | ||
ideas: latestAutoScoreAnnotation.data.ideas, | ||
scores: latestAutoScoreAnnotation.data.scores, | ||
submitCounter: this.getSubmitCounter(latestComponentState) | ||
}); | ||
const feedbackRuleEvaluator = this.getFeedbackRuleEvaluator(referenceComponent); | ||
this.setPromptAndEmitRule(feedbackRuleEvaluator.getFeedbackRule([cRaterResponse])); | ||
} | ||
} | ||
} |
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.