From a96e5cc7b9e8bb0afdc01e85da0bb59fd02f8f85 Mon Sep 17 00:00:00 2001 From: Svein-Tore Griff With Date: Wed, 18 Feb 2015 09:07:19 +0100 Subject: [PATCH] Make the xAPI integration work for stuff that aren't content types --- js/h5p-x-api-event.js | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/js/h5p-x-api-event.js b/js/h5p-x-api-event.js index e6fba9b..db87477 100644 --- a/js/h5p-x-api-event.js +++ b/js/h5p-x-api-event.js @@ -78,15 +78,21 @@ H5P.XAPIEvent.prototype.getVerb = function(full) { * @param {object} instance - the H5P instance */ H5P.XAPIEvent.prototype.setObject = function(instance) { - this.data.statement.object = { - // TODO: Correct this. contentId might be vid, and this can't be Drupal - // specific - 'id': H5PIntegration.getContentUrl(instance.contentId), - 'objectType': 'Activity', - 'extensions': { - 'http://h5p.org/x-api/h5p-local-content-id': instance.contentId - } - }; + if (instance.contentId) { + this.data.statement.object = { + 'id': H5PIntegration.getContentUrl(instance.contentId), + 'objectType': 'Activity', + 'extensions': { + 'http://h5p.org/x-api/h5p-local-content-id': instance.contentId + } + }; + } + else { + // Not triggered by an H5P content type... + this.data.statement.object = { + 'objectType': 'Activity' + }; + } }; /**