-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(FeedbackRule): isLowestWorkgroupIdInPeerGroup token #1420
feat(FeedbackRule): isLowestWorkgroupIdInPeerGroup token #1420
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I use isLowestWorkgroupIdInPeerGroup() by itself in an expression it works properly.
I get an error when I use isLowestWorkgroupIdInPeerGroup() with &&. Here is how to reproduce the error.
-
Create a Multiple Choice component that has the choices A, B, C.
-
Author Peer Chat that references the Multiple Choice component and Dynamic Prompt rules using && like these below
Prompt Rule 1
Expression: isLowestWorkgroupIdInPeerGroup() && myChoiceChosen("your-choice-id-for-a")
Prompt: You are the lowest workgroup id and chose A.
Prompt Rule 2
Expression: isLowestWorkgroupIdInPeerGroup() && myChoiceChosen("your-choice-id-for-b")
Prompt: You are the lowest workgroup id and chose B.
Prompt Rule 3
Expression: isLowestWorkgroupIdInPeerGroup() && myChoiceChosen("your-choice-id-for-c")
Prompt: You are the lowest workgroup id and chose C.
- Preview the project
- Go to the Multiple Choice step and submit B or C (if you choose A, the problem will not occur)
- Go to the Peer Chat step and you will not see any Dynamic Prompt and you will see this error in the console
ERROR TypeError: response.getDetectedIdeaNames is not a function
at IdeaTermEvaluator.evaluate (IdeaTermEvaluator.ts:18:45)
at FeedbackRuleEvaluatorMultipleStudents.ts:56:24
at Array.some (<anonymous>)
at FeedbackRuleEvaluatorMultipleStudents.evaluateTerm (FeedbackRuleEvaluatorMultipleStudents.ts:55:22)
at FeedbackRuleEvaluatorMultipleStudents.satisfiesSpecificRule (FeedbackRuleEvaluator.ts:95:19)
at FeedbackRuleEvaluatorMultipleStudents.satisfiesRule (FeedbackRuleEvaluator.ts:39:14)
at FeedbackRuleEvaluator.ts:31:30
at Array.find (<anonymous>)
at FeedbackRuleEvaluatorMultipleStudents.getFeedbackRule (FeedbackRuleEvaluator.ts:31:10)
If I use the same expressions for a Question Bank, the Question Bank works properly and does not throw an error.
I think it may have to do with Question Bank using CRaterResponse here
Line 82 in f9d2169
return new CRaterResponse({ |
and Dynamic Prompt using Response here
WISE-Client/src/assets/wise5/directives/dynamic-prompt/DynamicPromptMultipleChoiceEvaluator.ts
Line 10 in f9d2169
return new Response({ |
A Response object does not have the getDetectedIdeaNames() function which is what is throwing the error when IdeaTermEvaluator.evaluate() gets called.
When TermEvaluatorFactory.getTermEvaluator() is passed "false", it returns the IdeaTermEvaluator but maybe we should create a BooleanTermEvaluator and return that instead of having IdeaTermEvaluator handle booleans.
WISE-Client/src/assets/wise5/components/common/feedbackRule/TermEvaluator/TermEvaluatorFactory.ts
Line 33 in f9d2169
evaluator = new IdeaTermEvaluator(term); |
added on the stack after evaluating other tokens #1418
@geoffreykwan good catch and suggestion. I created BooleanTermEvaluator and moved the testing of "true" and "false" string tokens there. This seems to fix the issue you found. PTAL. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functionality works well.
This should be multiple tests.
WISE-Client/src/assets/wise5/components/common/feedbackRule/TermEvaluator/IdeaTermEvaluator.spec.ts
Lines 5 to 16 in c79835e
describe('IdeaTermEvaluator', () => { | |
describe('evaluate()', () => { | |
const response_with_no_ideas = new CRaterResponse(); | |
const response_with_2_ideas = new CRaterResponse(); | |
response_with_2_ideas.ideas = [new CRaterIdea('1', true), new CRaterIdea('2', true)]; | |
it('returns true iff idea term is found in the response', () => { | |
const evaluator_idea1 = new IdeaTermEvaluator('1'); | |
expect(evaluator_idea1.evaluate(response_with_no_ideas)).toBeFalse(); | |
expect(evaluator_idea1.evaluate(response_with_2_ideas)).toBeTrue(); | |
}); | |
}); | |
}); |
This should be multiple tests and include the new tokens like isLowestWorkgroupIdInPeerGroupTerm and isBooleanTerm.
Lines 8 to 29 in c79835e
describe('TermEvaluatorFactory', () => { | |
const factory = new TermEvaluatorFactory(null, null); | |
describe('getTermEvaluator()', () => { | |
it('should return correct evaluator', () => { | |
[ | |
{ | |
term: 'myChoiceChosen("choice1")', | |
instanceType: MyChoiceChosenTermEvaluator | |
}, | |
{ term: 'hasKIScore(3)', instanceType: HasKIScoreTermEvaluator }, | |
{ term: 'ideaCountMoreThan(1)', instanceType: IdeaCountTermEvaluator }, | |
{ term: 'ideaCountEquals(3)', instanceType: IdeaCountTermEvaluator }, | |
{ term: 'ideaCountLessThan(2)', instanceType: IdeaCountTermEvaluator }, | |
{ term: 'isSubmitNumber(2)', instanceType: IsSubmitNumberEvaluator }, | |
{ term: 'isSubmitNumber(23)', instanceType: IsSubmitNumberEvaluator }, | |
{ term: '2', instanceType: IdeaTermEvaluator } | |
].forEach(({ term, instanceType }) => { | |
expect(factory.getTermEvaluator(term) instanceof instanceType).toBeTrue(); | |
}); | |
}); | |
}); | |
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functionality works well.
I agree that we should add test cases for the new tokens to TermEvaluatorFactory.spec.ts
.
Looks like accumulatedIdeaCountMoreThan
, accumulatedIdeaCountLessThan
, accumulatedIdeaCountEquals
are also missing (not related to this PR).
Add tests for new tokens in TermEvaluatorFactory #1418
@geoffreykwan and @breity I addressed those requested changes. PTAL. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. 👍
🎉 This PR is included in version 5.114.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Changes
Add support for
isLowestWorkgroupIdInPeerGroup
token that returns true when the student's workgroup id is lower than all the other student's workgroup id's in the same PeerGroup. This token should only be used in Dynamic Prompt and Question Bank activities, and the activities must specify a Peer Grouping.Examples (my workgroup id = 2)
Test
isLowestWorkgroupIdInPeerGroup
in the FeedbackRule expression for Dynamic Prompt, Question Bank with (remember to specify PeerGrouping) and make sure that the rule is matched if the student's workgroup ID is the lowest in the PeerGroup. If should not match otherwise.!isLowestWorkgroupIdInPeerGroup
should match if your workgroup ID is not the lowest in the PeerGroup.Closes #1418