From 7a8f894c85ec617b499ea9b11b42b3cb8ed507b6 Mon Sep 17 00:00:00 2001 From: Thomas Marstrander Date: Tue, 10 Sep 2019 13:42:18 +0200 Subject: [PATCH] JI-1285 Set empty XAPIEvent object when instance has no contentId Content types view always expect to have a contentId when they are displayed. This is no the case if they are displayed in the editor as part of a preview. The fix is to set an empty object with definition for the xAPI event, so all the content types that rely on this does not have to be rewritten. This means that content types that are being previewed will send xAPI completed events, but since there are no scripts that catch these events in the editor, this is not a problem. --- js/h5p-x-api-event.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/js/h5p-x-api-event.js b/js/h5p-x-api-event.js index 04a0353..d2b68be 100644 --- a/js/h5p-x-api-event.js +++ b/js/h5p-x-api-event.js @@ -141,6 +141,12 @@ H5P.XAPIEvent.prototype.setObject = function (instance) { } } } + else { + // Empty object + this.data.statement.object = { + definition: {} + }; + } }; /**