From 3a2bb0a2fd4ec5502fe63adee8ccb316f07e4f9b Mon Sep 17 00:00:00 2001 From: Svein-Tore Griff With Date: Fri, 27 Nov 2015 20:49:49 +0100 Subject: [PATCH] Trigger attempted event the first time a user sees a question - HFJ-1397 --- js/h5p-x-api.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/js/h5p-x-api.js b/js/h5p-x-api.js index 08908bf..9fc6758 100644 --- a/js/h5p-x-api.js +++ b/js/h5p-x-api.js @@ -93,7 +93,13 @@ H5P.EventDispatcher.prototype.triggerXAPIScored = function (score, maxScore, ver }; H5P.EventDispatcher.prototype.setActivityStarted = function() { - this.activityStartTime = Date.now(); + if (this.activityStartTime === undefined) { + // Don't trigger xAPI events in the editor + if (H5PIntegration.contents['cid-' + this.contentId] !== undefined) { + this.triggerXAPI('attempted'); + } + this.activityStartTime = Date.now(); + } }; /** @@ -108,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