From 7330922bfe514b923a31fb707c6fa6ea5806716a Mon Sep 17 00:00:00 2001 From: danielghost Date: Mon, 2 Dec 2024 13:12:04 +0000 Subject: [PATCH] New: added `getInteractionObject` to align with other questions and for data reporting (fixes #214). --- js/SliderModel.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/js/SliderModel.js b/js/SliderModel.js index 4dbb013..8580fa9 100644 --- a/js/SliderModel.js +++ b/js/SliderModel.js @@ -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 */