addGroupingActivity() calls always initiate an empty array
Closed this issue · 2 comments
brian-learningpool commented
I noticed that the first statement was lost while trying to add two grouped items to my xAPI statement via addGroupingActivity()
method. Is this by design or a bug?
I think maybe _getobj()
requires a check before returning an empty array on
xAPIWrapper/src/xapistatement.js
Line 12 in c7bc09f
Something like
if (!Array.isArray(obj[part])) {
obj[part] = [];
}
vbhayden commented
Not sure, I'll take a look at this in a bit.
vbhayden commented
Yeah, this does look like a mistake. Just going into a console, you can see the behavior isn't correct:
statement.addGroupingActivity("A"); statement.addGroupingActivity("B");
console.log(statement.context.contextActivities.grouping.length)
>> 1
Go ahead and submit that change for a PR and I'll move it through.