Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

addGroupingActivity() calls always initiate an empty array #160

Closed
brian-learningpool opened this issue Jan 15, 2020 · 2 comments
Closed

Comments

@brian-learningpool
Copy link
Contributor

brian-learningpool commented Jan 15, 2020

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

obj[part] = [];
.

Something like

if (!Array.isArray(obj[part])) {
  obj[part] = [];
}
brian-learningpool added a commit to brian-learningpool/xAPIWrapper that referenced this issue Jan 15, 2020

Verified

This commit was signed with the committer’s verified signature.
wileyj wileyj
This was overwriting any existing array items in calls such as addGroupingActivity().
@vbhayden
Copy link
Member

Not sure, I'll take a look at this in a bit.

@vbhayden
Copy link
Member

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.

FlorianTolk added a commit that referenced this issue Jan 16, 2020

Verified

This commit was signed with the committer’s verified signature.
wileyj wileyj
Resolves #160, corrects issue with _getobj()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants