From 03370c95006e6ea175d721270ef93b08a642b2b2 Mon Sep 17 00:00:00 2001 From: Svein-Tore Griff With Date: Fri, 10 Jul 2015 12:58:02 +0200 Subject: [PATCH] Add info about the library being used to the xAPI statements --- js/h5p-x-api-event.js | 11 +++++++++++ js/h5p.js | 9 +++++++++ 2 files changed, 20 insertions(+) diff --git a/js/h5p-x-api-event.js b/js/h5p-x-api-event.js index a973dee..acaed22 100644 --- a/js/h5p-x-api-event.js +++ b/js/h5p-x-api-event.js @@ -131,6 +131,17 @@ H5P.XAPIEvent.prototype.setContext = function (instance) { } }; } + if (instance.libraryInfo) { + if (this.data.statement.context === undefined) { + this.data.statement.context = {"contextActivities":{}}; + } + this.data.statement.context.contextActivities.category = [ + { + "id": "http://h5p.org/libraries/" + instance.libraryInfo.versionedNameNoSpaces, + "objectType": "Activity" + } + ]; + } }; /** diff --git a/js/h5p.js b/js/h5p.js index f217a5f..a57fe64 100644 --- a/js/h5p.js +++ b/js/h5p.js @@ -748,6 +748,15 @@ H5P.newRunnable = function (library, contentId, $attachTo, skipResize, extras) { if (instance.parent === undefined && extras && extras.parent) { instance.parent = extras.parent; } + if (instance.libraryInfo === undefined) { + instance.libraryInfo = { + versionedName: library.library, + versionedNameNoSpaces: machineName + '-' + versionSplit[0] + '.' + versionSplit[1], + machineName: machineName, + majorVersion: versionSplit[0], + minorVersion: versionSplit[1] + }; + } if ($attachTo !== undefined) { instance.attach($attachTo);