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

How to select / display statements for only one Activity, preferably by name

Open ben-git-hub opened this issue 8 years ago • 1 comments

After successfully retrieving statements based on Verb ID, I can display graphs on a dashboard grouped by 'object.definition.name.en-US' for all (e.g.) "passed" verbs.

My goal is to present a chart of live data for one course: object.definition.name.en-US = 'My Course' Then one bar / pie slice for each verb: Launched, Failed, Passed

I am struggling to reduce my dataset to just one Activity (preferably by name as per the groupBy value shown above).

Should filter by acitivity take place in dash.fetchAllStatements or in fetchDoneCallback function as a pre or post function? How would those filters be applied?

I have tried both but with no success.

Any pointers to reduce the dataset to a specific course would be really helpful.

ben-git-hub avatar Nov 21 '16 12:11 ben-git-hub

Nothing like raising an issue to focus you mind....

I have found a means of achieving this using pre processing within the dashboard settings:

function fetchDoneCallback() { var chart = dash.createBarChart({ container: '#targetnum', groupBy: 'verb.id', aggregate: ADL.count(), pre: function(data){ return data.where( 'object.definition.name.en-US = "My Course"' ); }, customize: function(chart) { chart.xAxis.rotateLabels(45); chart.xAxis.tickFormat(function(d) { return /[^\/]+$/.exec(d)[0]; }); } }); chart.draw(); }

BUT. This is heavy on my page load time as I am pulling back way more statements than I need from the LRS. I use this query to retrieve the last 12 days data:

var query = {'since': new Date(Date.now() - 1000*60*60*24*12).toISOString()};

So, my revised question is: How can I filter the dataset before I work on it, effectively moving the dashboard filter: 'object.definition.name.en-US = "My Course"' up into: var query = {'object.definition.name.en-US': 'My Course};

I tried that but the query failed.

Any thoughts on achieving a more performant approach to filtering would be really welcome.

ben-git-hub avatar Nov 21 '16 13:11 ben-git-hub