Skip to content

Commit

Permalink
HFP-1779 Build xAPIObject with base information only once
Browse files Browse the repository at this point in the history
  • Loading branch information
otacke committed Mar 14, 2018
1 parent f3581ac commit 0585bbb
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions scripts/x-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ H5P.VideoXAPI = (function ($) {
var volumeChangedAt = 0;
var sessionID = H5P.createUUID();
var currentTime = 0;

var xAPIBase;

/**
* Generate common xAPI statement elements (Video Profile).
Expand Down Expand Up @@ -405,8 +405,13 @@ H5P.VideoXAPI = (function ($) {
* @returns {Object} 'Object' portion of JSON xAPI statement
*/
var getXAPIObject = function () {
if (xAPIBase !== undefined) {
return xAPIBase;
}

var event = new H5P.XAPIEvent();
event.setObject(videoInstance);

var xAPIObject = event.data.statement.object;

// Add definition type (required by xAPI Video Profile).
Expand All @@ -422,7 +427,7 @@ H5P.VideoXAPI = (function ($) {
};
}
}

xAPIBase = xAPIObject;
return xAPIObject;
};
}
Expand Down

0 comments on commit 0585bbb

Please sign in to comment.