From 5b0736f0e8b2a3be0b5617c02228606c5939f803 Mon Sep 17 00:00:00 2001 From: thomasmars Date: Thu, 24 Nov 2016 17:29:47 +0100 Subject: [PATCH] Added score to getXAPIData call HFP-255 --- js/questionset.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/js/questionset.js b/js/questionset.js index 476cb59..0fdd085 100644 --- a/js/questionset.js +++ b/js/questionset.js @@ -1132,7 +1132,7 @@ H5P.QuestionSet = function (options, contentId, contentData) { definition.interactionType = 'compound'; definition.type = 'http://adlnet.gov/expapi/activities/cmi.interaction'; definition.description = { - 'en-US': '' + 'en-US': '' }; return definition; @@ -1150,13 +1150,13 @@ H5P.QuestionSet = function (options, contentId, contentData) { * Get xAPI data from sub content types * * @param {Object} metaContentType - * @returns {array} + * @returns {array} */ var getXAPIDataFromChildren = function(metaContentType) { return metaContentType.getQuestions().map(function(question) { return question.getXAPIData(); }); - } + }; /** * Get xAPI data. @@ -1166,11 +1166,16 @@ H5P.QuestionSet = function (options, contentId, contentData) { */ this.getXAPIData = function(){ var xAPIEvent = this.createXAPIEventTemplate('answered'); - addQuestionToXAPI(xAPIEvent); - var childrenData = getXAPIDataFromChildren(this); + addQuestionToXAPI(xAPIEvent); + xAPIEvent.setScoredResult(this.getScore(), + this.getMaxScore(), + this, + true, + this.getScore() === this.getMaxScore() + ); return { statement: xAPIEvent.data.statement, - children: childrenData + children: getXAPIDataFromChildren(this) } }; };