xAPI-Dashboard icon indicating copy to clipboard operation
xAPI-Dashboard copied to clipboard

Question: how to keep the best try for each actor

Open jbajou opened this issue 8 years ago • 0 comments

I guys,

I'm having troubles using the ADLCollection and achieving what I want. Here is the thing: I instantiate the collection with some statements returned by an AJAX query to a LRS (I have only statements about the wanted activity, and the 'experienced' verb).

var statements = new ADL.Collection(data);

In these statements, I have multiple statements by actor (each actor tried multiple times the activity... or not), and I would like to keep their best shot at it. I start by grouping statements by actor. Then i get their max result.score.raw, and then I'm stuck:

statements.groupBy('actor.account.name').max('result.score.raw');
statements.exec(function (data) {
	console.log(data);
});

How can I keep only the best try (i.e. the greatest result.score.raw) for each Actor ?

Thanks for your help

jbajou avatar Jan 17 '17 13:01 jbajou