xAPI-Dashboard
xAPI-Dashboard copied to clipboard
having issue working with get more statements and adl.collection
I am facing issue processing more statements from XAPI. In my code below, I am using XAPI Wrapper and I am getting around 900 statements from lrs in rek, however, when I convert them into a collection and try to use the where clause, it does not give me any result.
Please Note: I can get the same thing done using fetchAllStatementes and it also works fine with getStatements (for only the first 100 records), however, I wish to do it manually using getMoreStatements.
Is there an example of merging statements using get more statements, creating a collection on top of it and then using the where query to filter the data?
My code: var stmt1 = JSON.stringify({ "mbox": actor.mbox , "name": actor.name });
var stmt2 = JSON.stringify({
"mbox": "mailto:[email protected]"
});
var stmtVerb = JSON.stringify({ "id": "http://adlnet.gov/expapi/verbs/started" });
var stmtCtx = JSON.stringify({ "contextActivities": { "grouping": [ { "id": competency.iri } ] } });
var search = ADL.XAPIWrapper.searchParams(); search['agent'] = stmt1; search['authority'] = stmt2; search['context'] = stmtCtx; var rek = [] ADL.XAPIWrapper.getStatements(search, null, function getmore(r){ var res = JSON.parse(r.response); $.each(res.statements, function(x,y){ rek.push(y) ; });
if (res.more && res.more !== ""){
ADL.XAPIWrapper.getStatements(search, res.more, getmore);
}
});
console.log(rek);
//var ret = ADL.XAPIWrapper.getStatements(search); //works fine //var statements = new ADL.Collection(ret.statements);
var stmt = new ADL.Collection(rek); var filtered_data = stmt.where('actor.name = "ccazabon"').exec(function(data){ console.log(data);//no output-empty array, however, matching data does exists }); var p = [{'name': 'Steven', 'age': 25, 'dob':{ 'mm': 'jan', 'dd': '18' }}, {'name': 'John', 'age': 35, 'dob':{ 'mm': 'feb', 'dd': '19' }}]; //console.log(p); var a = new ADL.Collection(p); //console.log(a); var d = a.where('dob.mm = "jan"').exec(function(data){console.log(data)});//works as expected
I think there is some issue with merging all the statements and creating the ADL.Collection, however, I am not getting any online help to resolve the same. Your help is greatly appreciated.