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

New: added getInteractionObject to align with other questions and for data reporting #215

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions js/SliderModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,24 @@ export default class SliderModel extends QuestionModel {
this.set('_score', score);
}

getInteractionObject() {
return {
correctResponsesPattern: this.getCorrectResponsesPattern()
}
}

getCorrectResponsesPattern() {
const correctAnswer = this.get('_correctAnswer');
if (correctAnswer) return [correctAnswer];
const correctRange = this.get('_correctRange');
if (!correctRange) return null;
const bottom = correctRange?._bottom ?? '';
const top = correctRange?._top ?? '';
Comment on lines +166 to +168
Copy link
Member

Choose a reason for hiding this comment

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

The ?. isn't necessary as both null and undefined are falsies, which would return on line 166.

return [
`${bottom}[:]${top}`
];
}

/**
* Used by adapt-contrib-spoor to get the user's answers in the format required by the cmi.interactions.n.student_response data field
*/
Expand Down
Loading