From f76290cddee0b9c7ba1f180821927fd36aa1b4b0 Mon Sep 17 00:00:00 2001 From: Frode Petterson Date: Fri, 20 Feb 2015 11:41:09 +0100 Subject: [PATCH] Made user results work in new embed. --- js/h5p-event-dispatcher.js | 4 ++-- js/h5p-x-api-event.js | 7 +++---- js/h5p-x-api.js | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/js/h5p-event-dispatcher.js b/js/h5p-event-dispatcher.js index 204fda9..3df9495 100644 --- a/js/h5p-event-dispatcher.js +++ b/js/h5p-event-dispatcher.js @@ -11,7 +11,7 @@ H5P.Event = function(type, data) { }; H5P.EventDispatcher = (function () { - + /** * The base of the event system. * Inherit this class if you want your H5P to dispatch events. @@ -152,4 +152,4 @@ H5P.EventDispatcher = (function () { } return EventDispatcher; -})(); \ No newline at end of file +})(); diff --git a/js/h5p-x-api-event.js b/js/h5p-x-api-event.js index 346bf64..5e1a025 100644 --- a/js/h5p-x-api-event.js +++ b/js/h5p-x-api-event.js @@ -79,7 +79,7 @@ H5P.XAPIEvent.prototype.getVerb = function(full) { H5P.XAPIEvent.prototype.setObject = function(instance) { if (instance.contentId) { this.data.statement.object = { - 'id': H5PIntegration.getContentUrl(instance.contentId), + 'id': H5P.contentDatas['cid-' + instance.contentId].url, 'objectType': 'Activity', 'extensions': { 'http://h5p.org/x-api/h5p-local-content-id': instance.contentId @@ -98,10 +98,9 @@ H5P.XAPIEvent.prototype.setObject = function(instance) { * Helper function to set the actor, email and name will be added automatically */ H5P.XAPIEvent.prototype.setActor = function() { - var user = H5PIntegration.getUser(); this.data.statement.actor = { - 'name': user.name, - 'mbox': 'mailto:' + user.mail, + 'name': H5P.user.name, + 'mbox': 'mailto:' + H5P.user.mail, 'objectType': 'Agent' }; }; diff --git a/js/h5p-x-api.js b/js/h5p-x-api.js index 37a593b..e4f4edb 100644 --- a/js/h5p-x-api.js +++ b/js/h5p-x-api.js @@ -3,7 +3,7 @@ var H5P = H5P || {}; // Create object where external code may register and listen for H5P Events H5P.externalDispatcher = new H5P.EventDispatcher(); -if (window.top !== window.self && window.top.H5P !== undefined && window.top.H5P.externalDispatcher !== undefined) { +if (H5P.isFramed && H5P.externalEmbed === false) { H5P.externalDispatcher.on('xAPI', window.top.H5P.externalDispatcher.trigger); }