1 H5P._getLibraryPath = H5P.getLibraryPath;
2 H5P.getLibraryPath = function (library) {
3 if (H5PIntegration.moodleLibraryPaths) {
4 if (H5PIntegration.moodleLibraryPaths[library]) {
5 return H5PIntegration.moodleLibraryPaths[library];
8 return H5P._getLibraryPath(library);
10 H5P.findInstanceFromId = function (contentId) {
12 return H5P.instances[0];
14 if (H5P.instances !== undefined) {
15 for (var i = 0; i < H5P.instances.length; i++) {
16 if (H5P.instances[i].contentId === contentId) {
17 return H5P.instances[i];
23 H5P.getXAPIStatements = function (contentId, statement) {
25 var instance = H5P.findInstanceFromId(contentId);
29 if (instance.getXAPIData == undefined) {
34 var xAPIData = instance.getXAPIData();
36 if (xAPIData.statement != undefined) {
37 statements.push(xAPIData.statement);
39 if (xAPIData.children != undefined) {
40 statements = statements.concat(xAPIData.children.map(a => a.statement));
44 H5P.getMoodleComponent = function () {
45 if (H5PIntegration.moodleComponent) {
46 return H5PIntegration.moodleComponent;
52 * Set the actor. (Moved to overrides due to MDL-69467)
54 H5P.XAPIEvent.prototype.setActor = function () {
55 if (H5PIntegration.user !== undefined) {
56 this.data.statement.actor = {
57 'name': H5PIntegration.user.name,
60 if (H5PIntegration.user.id !== undefined) {
61 this.data.statement.actor.account = {
62 'name': H5PIntegration.user.id,
63 'homePage': H5PIntegration.siteUrl
65 } else if (H5PIntegration.user.mail !== undefined) {
66 this.data.statement.actor.mbox = 'mailto:' + H5PIntegration.user.mail;
71 if (localStorage.H5PUserUUID) {
72 uuid = localStorage.H5PUserUUID;
74 uuid = H5P.createUUID();
75 localStorage.H5PUserUUID = uuid;
79 // LocalStorage and Cookies are probably disabled. Do not track the user.
80 uuid = 'not-trackable-' + H5P.createUUID();
82 this.data.statement.actor = {
85 'homePage': H5PIntegration.siteUrl