Skip to content

Commit

Permalink
New: added getInteractionObject to align with other questions and f…
Browse files Browse the repository at this point in the history
…or data reporting (fixes #214).
  • Loading branch information
danielghost committed Dec 2, 2024
1 parent 8ed096a commit 7330922
Showing 1 changed file with 18 additions and 0 deletions.
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 ?? '';
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

0 comments on commit 7330922

Please sign in to comment.