Skip to content
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

Merged

Conversation

hirokiterashima
Copy link
Member

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)

  1. Returns false if PeerGroup member's ids are:
    • [1,2]
    • [1,2,3]
  2. Returns true if PeerGroup member's ids are:
    • [2]
    • [2,3]
    • [2,3,4]

Test

  • Add 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.
  • Existing Peer Chat steps with Dynamic Prompt, Question Bank work as before

Closes #1418

@hirokiterashima hirokiterashima added the enhancement New feature of any size or improvement (UI, performance, security) label Sep 16, 2023
@hirokiterashima hirokiterashima self-assigned this Sep 16, 2023
@hirokiterashima hirokiterashima marked this pull request as ready for review September 16, 2023 16:55
Copy link
Member

@geoffreykwan geoffreykwan left a 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.

  1. Create a Multiple Choice component that has the choices A, B, C.

  2. 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.

  1. Preview the project
  2. Go to the Multiple Choice step and submit B or C (if you choose A, the problem will not occur)
  3. 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

and Dynamic Prompt using Response here

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.

added on the stack after evaluating other tokens

#1418
@hirokiterashima
Copy link
Member Author

@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.

Copy link
Member

@geoffreykwan geoffreykwan left a 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.

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.

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();
});
});
});
});

Copy link
Member

@breity breity left a 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
@hirokiterashima
Copy link
Member Author

hirokiterashima commented Sep 19, 2023

@geoffreykwan and @breity I addressed those requested changes. PTAL.

Copy link
Member

@geoffreykwan geoffreykwan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

Copy link
Member

@breity breity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. 👍

@hirokiterashima hirokiterashima merged commit c226806 into develop Sep 20, 2023
4 of 5 checks passed
@hirokiterashima hirokiterashima deleted the issue-1418-isLowestWorkgroupIdInPeerGroup-token branch September 20, 2023 20:18
@hirokiterashima
Copy link
Member Author

🎉 This PR is included in version 5.114.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature of any size or improvement (UI, performance, security) released
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Feedback Rule new "isLowestWorkgroupIdInPeerGroup" token
3 participants