Fix xAPI statement structure to follow the standard better
parent
b79a5b61b8
commit
e14c24cc07
|
@ -81,25 +81,21 @@ H5P.XAPIEvent.prototype.setObject = function(instance) {
|
||||||
this.data.statement.object = {
|
this.data.statement.object = {
|
||||||
'id': this.getContentXAPIId(instance),
|
'id': this.getContentXAPIId(instance),
|
||||||
'objectType': 'Activity',
|
'objectType': 'Activity',
|
||||||
|
'definition': {
|
||||||
'extensions': {
|
'extensions': {
|
||||||
'http://h5p.org/x-api/h5p-local-content-id': instance.contentId
|
'http://h5p.org/x-api/h5p-local-content-id': instance.contentId
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
if (instance.h5pUUID) {
|
if (instance.h5pUUID) {
|
||||||
this.data.statement.object.extensions['http://h5p.org/x-api/h5p-uuid'] = instance.h5pUUID;
|
this.data.statement.object.extensions['http://h5p.org/x-api/h5p-uuid'] = instance.h5pUUID;
|
||||||
}
|
}
|
||||||
if (typeof instance.getH5PTitle === 'function') {
|
if (typeof instance.getH5PTitle === 'function') {
|
||||||
this.data.statement.object.description = {
|
this.data.statement.object.definition.name = {
|
||||||
"en-US": instance.getH5PTitle()
|
"en-US": instance.getH5PTitle()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
// Not triggered by an H5P content type...
|
|
||||||
this.data.statement.object = {
|
|
||||||
'objectType': 'Activity'
|
|
||||||
};
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -111,12 +107,14 @@ H5P.XAPIEvent.prototype.setContext = function(instance) {
|
||||||
if (instance.parent && instance.parent.contentId || instance.parent.uuid) {
|
if (instance.parent && instance.parent.contentId || instance.parent.uuid) {
|
||||||
var parentId = instance.parent.uuid === undefined ? instance.parent.contentId : instance.parent.uuid;
|
var parentId = instance.parent.uuid === undefined ? instance.parent.contentId : instance.parent.uuid;
|
||||||
this.data.statement.context = {
|
this.data.statement.context = {
|
||||||
|
"contextActivities": {
|
||||||
"parent": [
|
"parent": [
|
||||||
{
|
{
|
||||||
"id": getContentXAPIId(instance.parent),
|
"id": this.getContentXAPIId(instance.parent),
|
||||||
"objectType": "Activity"
|
"objectType": "Activity"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -39,9 +39,12 @@ H5P.EventDispatcher.prototype.createXAPIEventTemplate = function(verb, extra) {
|
||||||
event.data.statement[i] = extra[i];
|
event.data.statement[i] = extra[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!('object' in event)) {
|
if (!('object' in event.data.statement)) {
|
||||||
event.setObject(this);
|
event.setObject(this);
|
||||||
}
|
}
|
||||||
|
if (!('context' in event.data.statement)) {
|
||||||
|
event.setContext(this);
|
||||||
|
}
|
||||||
return event;
|
return event;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue