-
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(QuestionBank): Display based on matched feedback rule (#910)
- Loading branch information
1 parent
42fd777
commit 933c0f3
Showing
18 changed files
with
221 additions
and
61 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
37 changes: 37 additions & 0 deletions
37
src/assets/wise5/components/common/ReferenceComponentRules.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,37 @@ | ||
import { ReferenceComponent } from '../../../../app/domain/referenceComponent'; | ||
import { FeedbackRule } from './feedbackRule/FeedbackRule'; | ||
|
||
export abstract class ReferenceComponentRules { | ||
enabled: boolean; | ||
peerGroupingTag?: string; | ||
referenceComponent: ReferenceComponent; | ||
rules: FeedbackRule[]; | ||
|
||
constructor(jsonObject: any = {}) { | ||
for (const key of Object.keys(jsonObject)) { | ||
if (jsonObject[key] != null) { | ||
this[key] = jsonObject[key]; | ||
} | ||
} | ||
} | ||
|
||
getPeerGroupingTag(): string { | ||
return this.peerGroupingTag; | ||
} | ||
|
||
getReferenceNodeId(): string { | ||
return this.referenceComponent.nodeId; | ||
} | ||
|
||
getReferenceComponentId(): string { | ||
return this.referenceComponent.componentId; | ||
} | ||
|
||
getRules(): FeedbackRule[] { | ||
return this.rules; | ||
} | ||
|
||
isPeerGroupingTagSpecified(): boolean { | ||
return this.peerGroupingTag != null && this.peerGroupingTag !== ''; | ||
} | ||
} |
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
6 changes: 6 additions & 0 deletions
6
src/assets/wise5/components/peerChat/peer-chat-question-bank/QuestionBank.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,6 @@ | ||
import { ReferenceComponentRules } from '../../common/ReferenceComponentRules'; | ||
import { QuestionBankRule } from './QuestionBankRule'; | ||
|
||
export class QuestionBank extends ReferenceComponentRules { | ||
rules: QuestionBankRule[]; | ||
} |
13 changes: 13 additions & 0 deletions
13
src/assets/wise5/components/peerChat/peer-chat-question-bank/QuestionBankContent.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,13 @@ | ||
import { QuestionBank } from './QuestionBank'; | ||
|
||
export class QuestionBankContent { | ||
componentId: string; | ||
nodeId: string; | ||
questionBank: QuestionBank; | ||
|
||
constructor(nodeId: string, componentId: string, questionBank: QuestionBank) { | ||
this.nodeId = nodeId; | ||
this.componentId = componentId; | ||
this.questionBank = questionBank; | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
src/assets/wise5/components/peerChat/peer-chat-question-bank/QuestionBankRule.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,5 @@ | ||
import { FeedbackRule } from '../../common/feedbackRule/FeedbackRule'; | ||
|
||
export class QuestionBankRule extends FeedbackRule { | ||
questions: string[]; | ||
} |
12 changes: 12 additions & 0 deletions
12
...se5/components/peerChat/peer-chat-question-bank/peer-chat-question-bank.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
87 changes: 84 additions & 3 deletions
87
...ts/wise5/components/peerChat/peer-chat-question-bank/peer-chat-question-bank.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 |
---|---|---|
@@ -1,17 +1,98 @@ | ||
import { Component, Input, OnInit } from '@angular/core'; | ||
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; | ||
import { Observable } from 'rxjs'; | ||
import { PeerGroupService } from '../../../services/peerGroupService'; | ||
import { ProjectService } from '../../../services/projectService'; | ||
import { OpenResponseContent } from '../../openResponse/OpenResponseContent'; | ||
import { QuestionBank } from './QuestionBank'; | ||
import { Component as WISEComponent } from '../../../common/Component'; | ||
import { PeerGroupStudentData } from '../../../../../app/domain/peerGroupStudentData'; | ||
import { CRaterResponse } from '../../common/cRater/CRaterResponse'; | ||
import { FeedbackRuleEvaluator } from '../../common/feedbackRule/FeedbackRuleEvaluator'; | ||
import { FeedbackRuleComponent } from '../../feedbackRule/FeedbackRuleComponent'; | ||
import { QuestionBankRule } from './QuestionBankRule'; | ||
import { concatMap, map } from 'rxjs/operators'; | ||
import { PeerGroup } from '../PeerGroup'; | ||
import { QuestionBankContent } from './QuestionBankContent'; | ||
|
||
@Component({ | ||
selector: 'peer-chat-question-bank', | ||
templateUrl: './peer-chat-question-bank.component.html', | ||
styleUrls: ['./peer-chat-question-bank.component.scss'] | ||
}) | ||
export class PeerChatQuestionBankComponent implements OnInit { | ||
@Input() | ||
@Input() content: QuestionBankContent; | ||
@Input() displayedQuestionBankRule: QuestionBankRule; | ||
@Output() displayedQuestionBankRuleChange = new EventEmitter<QuestionBankRule>(); | ||
questions: string[]; | ||
|
||
constructor() { } | ||
constructor(private peerGroupService: PeerGroupService, private projectService: ProjectService) {} | ||
|
||
ngOnInit(): void { | ||
if (this.displayedQuestionBankRule != null) { | ||
this.questions = this.displayedQuestionBankRule.questions; | ||
} else { | ||
const referenceComponent = this.getReferenceComponent(this.content.questionBank); | ||
if (referenceComponent.content.type === 'OpenResponse') { | ||
this.evaluate(referenceComponent); | ||
} | ||
} | ||
} | ||
|
||
private getReferenceComponent(questionBank: QuestionBank): WISEComponent { | ||
const nodeId = questionBank.getReferenceNodeId(); | ||
const componentId = questionBank.getReferenceComponentId(); | ||
return new WISEComponent(this.projectService.getComponent(nodeId, componentId), nodeId); | ||
} | ||
|
||
private evaluate(referenceComponent: WISEComponent): void { | ||
if (this.content.questionBank.isPeerGroupingTagSpecified()) { | ||
this.evaluatePeerGroup(referenceComponent); | ||
} | ||
} | ||
|
||
private evaluatePeerGroup(referenceComponent: WISEComponent): void { | ||
this.getPeerGroupData( | ||
this.content.questionBank.getPeerGroupingTag(), | ||
this.content.nodeId, | ||
this.content.componentId | ||
).subscribe((peerGroupStudentData: PeerGroupStudentData[]) => { | ||
const cRaterResponses = peerGroupStudentData.map((peerMemberData: PeerGroupStudentData) => { | ||
return new CRaterResponse({ | ||
ideas: peerMemberData.annotation.data.ideas, | ||
scores: peerMemberData.annotation.data.scores, | ||
submitCounter: peerMemberData.studentWork.studentData.submitCounter | ||
}); | ||
}); | ||
const feedbackRuleEvaluator = new FeedbackRuleEvaluator( | ||
new FeedbackRuleComponent( | ||
this.content.questionBank.getRules(), | ||
(referenceComponent.content as OpenResponseContent).maxSubmitCount, | ||
false | ||
) | ||
); | ||
const feedbackRule: QuestionBankRule = feedbackRuleEvaluator.getFeedbackRule( | ||
cRaterResponses | ||
) as QuestionBankRule; | ||
this.questions = feedbackRule.questions; | ||
this.displayedQuestionBankRuleChange.emit(feedbackRule); | ||
}); | ||
} | ||
|
||
private getPeerGroupData( | ||
peerGroupingTag: string, | ||
nodeId: string, | ||
componentId: string | ||
): Observable<PeerGroupStudentData[]> { | ||
return this.peerGroupService.retrievePeerGroup(peerGroupingTag).pipe( | ||
concatMap((peerGroup: PeerGroup) => { | ||
return this.peerGroupService | ||
.retrieveQuestionBankStudentData(peerGroup.id, nodeId, componentId) | ||
.pipe( | ||
map((peerGroupStudentData: PeerGroupStudentData[]) => { | ||
return peerGroupStudentData; | ||
}) | ||
); | ||
}) | ||
); | ||
} | ||
} |
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
39 changes: 2 additions & 37 deletions
39
src/assets/wise5/directives/dynamic-prompt/DynamicPrompt.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 |
---|---|---|
@@ -1,41 +1,6 @@ | ||
import { FeedbackRule } from '../../components/common/feedbackRule/FeedbackRule'; | ||
import { ReferenceComponentRules } from '../../components/common/ReferenceComponentRules'; | ||
|
||
export class DynamicPrompt { | ||
enabled: boolean; | ||
peerGroupingTag?: string; | ||
export class DynamicPrompt extends ReferenceComponentRules { | ||
postPrompt?: string; | ||
prePrompt?: string; | ||
referenceComponent: { | ||
componentId: string; | ||
nodeId: string; | ||
}; | ||
rules: FeedbackRule[]; | ||
|
||
constructor(jsonObject: any = {}) { | ||
for (const key of Object.keys(jsonObject)) { | ||
if (jsonObject[key] != null) { | ||
this[key] = jsonObject[key]; | ||
} | ||
} | ||
} | ||
|
||
getReferenceNodeId(): string { | ||
return this.referenceComponent.nodeId; | ||
} | ||
|
||
getReferenceComponentId(): string { | ||
return this.referenceComponent.componentId; | ||
} | ||
|
||
getRules(): FeedbackRule[] { | ||
return this.rules; | ||
} | ||
|
||
getPeerGroupingTag(): string { | ||
return this.peerGroupingTag; | ||
} | ||
|
||
isPeerGroupingTagSpecified(): boolean { | ||
return this.peerGroupingTag != null && this.peerGroupingTag !== ''; | ||
} | ||
} |
Oops, something went wrong.