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.
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.
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.
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.
@Matthew - I'm not aware of anybody having done this yet, but if you're trying it and running into problems, feel free to post the details here or email andrew.downes@tincanapi.com
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);
10 Replies
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:
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
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.
Thanks guys.
That's a really detailed answer Andrew, I appreciate your time.
I'm looking forward to playing with this and will post what I learn.
Hi Stanley,
Welcome to the community! Let us know if you need anything further.
Has anyone had any luck with the above explanation and actually have an example of it working?
@Matthew - I'm not aware of anybody having done this yet, but if you're trying it and running into problems, feel free to post the details here or email andrew.downes@tincanapi.com
Thanks for popping in to assist Andrew :)
Hi Stanley. Using TinCan JS requires initializing it with authentication credentials, which is not so hard. I attached a sample to another question:
https://community.articulate.com/discussions/articulate-storyline/how-to-send-tin-can-statements-with-javascript#reply-318334
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.
Actually Prakash offered some code that works for this purpose - https://community.articulate.com/discussions/articulate-storyline/getting-student-name-and-student-id-in-storyline-using-tincan
This discussion is closed. You can start a new discussion or contact Articulate Support.