Closed neboduus closed 6 years ago
After reading all the xApiWrapper library code, me and my collegue found the solution.
The problem is that you can not set the CONTEXT property of a statement if you didn't set some context parameters during the configuration of ADL object.
So in order to set the context property of a statement you have to set at least one of grouping
, registration
or activity_platform
during ADL configuration like so:
const configuration = {
'endpoint' : LRS_ApiUrl,
'auth' : 'Basic ' + btoa(LRS.key + ':' + LRS.secret),
'registration': this.ADL.ruuid(),
'activity_platform': `${this.organizationId}_organizationId`
};
this.ADL.XAPIWrapper.changeConfig(configuration);
As you can see I set only registration
and activity_platform
.
This is because of this lines of code in xapiwrapper.js
file:
XAPIWrapper.prototype.prepareStatement = function(stmt)
{
...........
if (this.lrs.grouping ||
this.lrs.registration ||
this.lrs.activity_platform) {
if (!stmt.context) {
stmt.context = {};
}
}
if (this.lrs.grouping) {
if (!stmt.context.contextActivities) {
stmt.context.contextActivities = {};
}
stmt.context.contextActivities.grouping = [{ id : this.lrs.grouping }];
}
...........
}
Here you can note that in order to set statement.context.contextActivities
you must set grouping
.
Hope this could help someone else!
When I will have some time I will update the documentation and make a pull request.
Bye!
Hi All! I don't know if this is an issue or just under engineering, but Statement.Context can not be set. If I look at xapistatement.js I can see just some context references, but any Context Object. Is this normal? How could I use Context on statements?
Thanks