Added score to getXAPIData call

HFP-255
pull/10/head
thomasmars 2016-11-24 17:29:47 +01:00
parent 29d122be50
commit 5b0736f0e8
1 changed files with 11 additions and 6 deletions

View File

@ -1132,7 +1132,7 @@ H5P.QuestionSet = function (options, contentId, contentData) {
definition.interactionType = 'compound'; definition.interactionType = 'compound';
definition.type = 'http://adlnet.gov/expapi/activities/cmi.interaction'; definition.type = 'http://adlnet.gov/expapi/activities/cmi.interaction';
definition.description = { definition.description = {
'en-US': '' 'en-US': ''
}; };
return definition; return definition;
@ -1150,13 +1150,13 @@ H5P.QuestionSet = function (options, contentId, contentData) {
* Get xAPI data from sub content types * Get xAPI data from sub content types
* *
* @param {Object} metaContentType * @param {Object} metaContentType
* @returns {array} * @returns {array}
*/ */
var getXAPIDataFromChildren = function(metaContentType) { var getXAPIDataFromChildren = function(metaContentType) {
return metaContentType.getQuestions().map(function(question) { return metaContentType.getQuestions().map(function(question) {
return question.getXAPIData(); return question.getXAPIData();
}); });
} };
/** /**
* Get xAPI data. * Get xAPI data.
@ -1166,11 +1166,16 @@ H5P.QuestionSet = function (options, contentId, contentData) {
*/ */
this.getXAPIData = function(){ this.getXAPIData = function(){
var xAPIEvent = this.createXAPIEventTemplate('answered'); var xAPIEvent = this.createXAPIEventTemplate('answered');
addQuestionToXAPI(xAPIEvent); addQuestionToXAPI(xAPIEvent);
var childrenData = getXAPIDataFromChildren(this); xAPIEvent.setScoredResult(this.getScore(),
this.getMaxScore(),
this,
true,
this.getScore() === this.getMaxScore()
);
return { return {
statement: xAPIEvent.data.statement, statement: xAPIEvent.data.statement,
children: childrenData children: getXAPIDataFromChildren(this)
} }
}; };
}; };