From e6ec257c6da2a05530ddad4185fac5d92e3b2770 Mon Sep 17 00:00:00 2001 From: Paal Joergensen Date: Wed, 16 Dec 2015 15:42:26 +0100 Subject: [PATCH] Made setActivityStarted a little more robust [HFJ-1474] --- js/h5p-x-api.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/h5p-x-api.js b/js/h5p-x-api.js index 9fc6758..272c058 100644 --- a/js/h5p-x-api.js +++ b/js/h5p-x-api.js @@ -95,7 +95,7 @@ H5P.EventDispatcher.prototype.triggerXAPIScored = function (score, maxScore, ver H5P.EventDispatcher.prototype.setActivityStarted = function() { if (this.activityStartTime === undefined) { // Don't trigger xAPI events in the editor - if (H5PIntegration.contents['cid-' + this.contentId] !== undefined) { + if (this.contentId !== undefined && H5PIntegration.contents !== undefined && H5PIntegration.contents['cid-' + this.contentId] !== undefined) { this.triggerXAPI('attempted'); } this.activityStartTime = Date.now(); @@ -114,4 +114,4 @@ H5P.xAPICompletedListener = function (event) { var contentId = event.getVerifiedStatementValue(['object', 'definition', 'extensions', 'http://h5p.org/x-api/h5p-local-content-id']); H5P.setFinished(contentId, score, maxScore); } -}; \ No newline at end of file +};