Can Tin Can statements GET back into Storyline?

Jan 20, 2015

Hi everyone,

I'm Stanley Yip, Online Learning Designer at the Association of Independent Schools of NSW in Australia, nice to meet you all!

I'm wondering if someone can guide me on how to GET Tin Can statements back into Storyline, (to visually reflect saved progress).

Currently using SCORM Cloud and can see the Tin Can statements from my Storyline module being POSTed ok.

Also using TinCanJS on a standalone HTML file just to test GET the statements but no luck. Maybe my Endpoint, Username and Password not correct?

Thanks!

10 Replies
Andrew Downes

Hi Stanley, 

I'm really glad you asked this question!

Story.js (or xapi.js depending on your package/Storyline 2 update version) contains a JavaScript function called SendTinCanRequest, which looks to be what Storyline calls to make requests to the LRS. I'm guessing you can call this using Storyline triggers. (See http://www.articulate.com/support/storyline/javascript-best-practices-and-examples).

You could look at the parameters Storyline passes to this function, you should be able to work out enough to make your own calls. I don't think Storyline ever GETs Statements, but if you look at how PUT Statements and GET State are implemented. Or you could compare the parameter names to the Tin Can spec and pass something sensible and see what happens. To get you started, here's a list of the parameters and what i suggest trying first:

  • nMessageType - I can't work out what this is. Storyline sets this to 2 when GETing State and 3 when PUTing statements. TinCanJS doesn't use message type at all. I'd try using 2, 3 or null.
  • strMethod - should be GET for GET Statements. Storyline always uses IE Mode requests, so always uses POST. 
  • strData - the content of your request. For GET statements, this should be empty. Storyline always uses IE Mode requests, so would populate this with what's usually included as headers. 
  • strUrl - the full URL of the resource you're accessing including any query string parameters. See https://github.com/adlnet/xAPI-Spec/blob/master/xAPI.md#stmtapiget for a list of possible parameters. Don't forget "/statements" on the end of the url before the query string e.g. http://cloud.scorm.com/tc/L4U0TQ1QVK/sandbox/statements?format=canonical.  Storyline always uses IE Mode requests, so adds "?method=GET" on the end. 
  • arrHeaders - an array containing all your headers. You'll need to check the full spec for a list of required headers, but for a quick reference of headers I'd expect, see the normal syntax example in Appendix G. Accept-Encoding, Accept-Language and Content-Length will probably be filled in by the user's browser if you don't set them. 

If that's too complex, you could edit your package to include TinCanJS either in place or or simply alongside Storyline's code. TinCanJS will handle a lot of the above for you. 

You can see an example of GET statements in the prototypes, specifically the statement viewer, report sample and statement viewer e.g. here: https://github.com/RusticiSoftware/TinCan_Prototypes/blob/master/ReportSample/scripts/TinCanViewer.js#L75

Let me know if you have any questions and please update us on how you get on. Do be sure to test your courses in both Internet Explorer and another browser. 

It'd be brilliant to see people using this method to GET Statements from activities outside of Storyline to shape the learner's experience within the course. See my blog on better blended learning

Andrew

Steve Flowers

Hi Stanley - 

Are you trying to restore progress (similar to suspend data restore in SCORM) or draw in progress from other statements submitted outside of the context of your Storyline published file?

If the former, when launching an xAPI published story, restore of state, variables, and progress should be automatic. Is this not what you're seeing?

If the latter, Andrew's guidance is good advice and I'd love to see someone model retrieving statements outside of Storyline to shape the experience. This is a great use case and example of the power of xAPI.

Stephanie Harnett

Does anyone know how to get the Student Name when publishing to TinCan? I can do this with SCORM but not sure how to do the same with TinCan published content. 

var player = GetPlayer();

function findLMSAPI(win) {
if (win.hasOwnProperty("GetStudentID")) return win;
else if (win.parent == win) return null;
else return findLMSAPI(win.parent);
}
var lmsAPI = findLMSAPI(this);
var myName = lmsAPI.GetStudentName();
var nameArray = myName.split(',');
var firstName = nameArray[1];
var lastName = nameArray[0];
player.SetVar('first_name',firstName);
player.SetVar('last_name',lastName);

This discussion is closed. You can start a new discussion or contact Articulate Support.