Refactor completed listener to use more of the new xAPI api functions

semantics-font
Svein-Tore Griff With 2015-03-22 20:38:57 +01:00
parent eb02a5942d
commit 9d38f83886
1 changed files with 5 additions and 8 deletions

View File

@ -66,13 +66,10 @@ H5P.EventDispatcher.prototype.triggerXAPICompleted = function(score, maxScore) {
* @param {function} event - xAPI event * @param {function} event - xAPI event
*/ */
H5P.xAPICompletedListener = function(event) { H5P.xAPICompletedListener = function(event) {
var statement = event.data.statement; if (event.getVerb() === 'completed' && !event.getVerifiedStatementValue(['context', 'contextActivities', 'parent'])) {
if ('verb' in statement) { var score = event.getScore();
if (statement.verb.id === 'http://adlnet.gov/expapi/verbs/completed') { var maxScore = event.getMaxScore();
var score = statement.result.score.raw; var contentId = event.getVerifiedStatementValue(['object', 'definition', 'extensions', 'http://h5p.org/x-api/h5p-local-content-id']);
var maxScore = statement.result.score.max;
var contentId = statement.object.definition.extensions['http://h5p.org/x-api/h5p-local-content-id'];
H5P.setFinished(contentId, score, maxScore); H5P.setFinished(contentId, score, maxScore);
} }
}
}; };