Use title from metadata object when creating xAPI stmt
parent
8c374be79d
commit
e74fb6009a
|
@ -133,9 +133,10 @@ H5P.XAPIEvent.prototype.setObject = function (instance) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (H5PIntegration && H5PIntegration.contents && H5PIntegration.contents['cid-' + instance.contentId].title) {
|
var content = H5P.getContentForInstance(instance.contentId);
|
||||||
|
if (content && content.metadata && content.metadata.title) {
|
||||||
this.data.statement.object.definition.name = {
|
this.data.statement.object.definition.name = {
|
||||||
"en-US": H5P.createTitle(H5PIntegration.contents['cid-' + instance.contentId].title)
|
"en-US": H5P.createTitle(content.metadata.title)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -150,7 +151,6 @@ H5P.XAPIEvent.prototype.setObject = function (instance) {
|
||||||
*/
|
*/
|
||||||
H5P.XAPIEvent.prototype.setContext = function (instance) {
|
H5P.XAPIEvent.prototype.setContext = function (instance) {
|
||||||
if (instance.parent && (instance.parent.contentId || instance.parent.subContentId)) {
|
if (instance.parent && (instance.parent.contentId || instance.parent.subContentId)) {
|
||||||
var parentId = instance.parent.subContentId === undefined ? instance.parent.contentId : instance.parent.subContentId;
|
|
||||||
this.data.statement.context = {
|
this.data.statement.context = {
|
||||||
"contextActivities": {
|
"contextActivities": {
|
||||||
"parent": [
|
"parent": [
|
||||||
|
|
14
js/h5p.js
14
js/h5p.js
|
@ -2140,6 +2140,20 @@ H5P.createTitle = function (rawTitle, maxLength) {
|
||||||
contentUserDataAjax(contentId, dataId, subContentId, undefined, null);
|
contentUserDataAjax(contentId, dataId, subContentId, undefined, null);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function for getting content for a certain ID
|
||||||
|
*
|
||||||
|
* @param {number} contentId
|
||||||
|
* @return {Object}
|
||||||
|
*/
|
||||||
|
H5P.getContentForInstance = function (contentId) {
|
||||||
|
var key = 'cid-' + contentId;
|
||||||
|
var exists = H5PIntegration && H5PIntegration.contents &&
|
||||||
|
H5PIntegration.contents[key];
|
||||||
|
|
||||||
|
return exists ? H5PIntegration.contents[key] : undefined;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepares the content parameters for storing in the clipboard.
|
* Prepares the content parameters for storing in the clipboard.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue