Skip to content
Snippets Groups Projects
Commit 560ed8c5 authored by Thomas Marstrander's avatar Thomas Marstrander
Browse files

JI-1059 Add queueing failed xAPI results requests

Update library submodule
parent 39eba915
No related branches found
No related tags found
No related merge requests found
Subproject commit 39d27ab9bb1bb228dc1a69afab3ea50ff65f52e2 Subproject commit 687f886e3d9054b87a9298184f1c2f5ba908d43c
...@@ -58,6 +58,28 @@ ...@@ -58,6 +58,28 @@
return instance; return instance;
} }
function getIframe(contentId) {
let iFrames;
// No content id given.
if (!contentId) {
iFrames = document.getElementsByClassName('h5p-iframe');
// Assume first iframe.
return iFrames[0];
}
// Locate iFrames.
iFrames = document.getElementsByClassName('h5p-iframe');
for (let i = 0; i < iFrames.length; i++) {
// Search through each iframe for content.
if (findInstanceInArray(iFrames[i].contentWindow.H5P.instances, contentId)) {
return iFrames[i];
}
}
return null;
}
/** /**
* Get xAPI data for content type and send off. * Get xAPI data for content type and send off.
* *
...@@ -88,7 +110,17 @@ ...@@ -88,7 +110,17 @@
console.error('Storing xAPI results failed with error message:', data); console.error('Storing xAPI results failed with error message:', data);
} }
}).fail(function () { }).fail(function () {
H5P.offlineRequestQueue.add(H5PIntegration.ajax.xAPIResult, data); // Let H5P iframe know that we want to queue the request for late transmission
const iframe = getIframe(contentId);
if (!iframe) {
return;
}
iframe.contentWindow.postMessage( {
url: H5PIntegration.ajax.xAPIResult,
data: data,
context: 'h5p',
action: 'queueRequest',
});
}); });
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment