2

I have added a Tin Can course to my LMS and I am successfully able to upload and playback the course so that my statements are being written to the Initial Application Realm LRS. So far so good.

Now I want to be able to retrieve from the LRS a list of all statements that have been written so that I can iterate through these and check for course completion for the signed in user. My statements are being written to the following endpoint:

https://cloud.scorm.com/tc/7QLMQA89WV/

I have tried to query the statements by using the .NET library and the following code:

//Initialize the TinCan Remote LRS for retrieving completion statistics
LRS = new RemoteLRS("https://cloud.scorm.com/tc/7QLMQA89WV/", "<username>", "<pw>");
Version = TinCan.TCAPIVersion.V101;

//Create the TinCan statement to query completed activities for the logged in user
var query = new StatementsQuery();
query.agent = new TinCan.Agent();
query.agent.mbox = "mailto:jpmcfeely@hsl-data.com";
query.verbId = new Uri("http://adlnet.gov/expapi/verbs/completed");
query.activityId = new Uri("http://tincanapi.com/GolfExample_TCAPI"); 

This however is returning a list of all statements regardless of verb or activity that have been used. Could there possibly be a bug in the query filter as when using SCORM Cloud I can see the TCAPI query string and when entering the URI of the Verb or Activity here it filters appropriately.

As a means of testing that the statements was being output correctly I also have the following on my view, not sure if this is the best way to get a human readable version of the statement, but I have this output for each statement within my List

<p>@statement.actor.name @statement.verb.display.ToJObject().GetValue("und") '@statement.target.ToJObject(Model.Version)["definition"]["name"]["en-US"]'</p>
Jay
  • 3,012
  • 14
  • 48
  • 99

2 Answers2

3

+1 to Andrew's suggestion for using the library. The reason you are getting the results you are getting is because you are missing the 'X-Experience-API-Version' header which the library adds to all requests appropriately. The lack of a header means the LRS is interpreting the request as a 0.9 version request and unless you've stored statements using that version none will be returned (statements are not down converted).

I know you know where the library is, but for SO's posterity:

http://rusticisoftware.github.io/TinCanJS/

Also note that this will only return the LRS' first page of statements, you'll then need to handle the 'more' URL returned by the LRS to fetch the next page, recursively. TinCanJS provides a simple method for doing that as well.

Brian J. Miller
  • 2,169
  • 1
  • 12
  • 12
  • Using the .NET Library I have been able to get a list of statements but the activityId and verbId filters are not being applied, I have list of 9 statements over the 2 example course (GOLF & Tetris) and on setting the query.activityID to the URI of either activity does not filter the list and returns all statements, the same thing is happening for verbId as I have tried to set this to completed to return only completion statements but again all statements are returned, could this be a bug of the filter system as when using cloud.scorm and applying filter it works how I would expect – Jay Jun 10 '14 at 10:37
  • Anyone following along, there were a couple of bugs that have been resolved in release 0.0.3.0 and 0.0.4.0. – Brian J. Miller Jun 10 '14 at 17:14
0

I recommend using the TinCanJS library. I'll update with a link later, but you should be able yo find it and instructions on Google.

Andrew Downes
  • 547
  • 7
  • 13
  • I am already using .NET Andrew and so have decided to stick with that and then save any of the data to ViewModel variables for calling on the views. I am able to return a list of statements now but the filter of the query does not seem to be applied. Please see updated question – Jay Jun 10 '14 at 10:41