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);