how to send Tin Can statements with javascript
Feb 10, 2014
By
Job Vlaming
Hi,
I've managed to use javascript in Storyline to report score and completion in Scorm 2004. I had no prior knowledge of javascript, but managed it with help from these forums.
Now, I'm fiddling around with Tin Can courses. Storyline reports the basic information fine. But I'm looking to see if I can use the API to send more specific, lesson-related data or statements.
So I'm wondering: Is it possible to send Tin Can statements using the 'execute javascript'-trigger?
If so, does anyone have an example of some javascript that does that?
Thanks!
Ayoub
48 Replies
Yes you can do that. Here is the link to the the JavaScript client library for Tin Can API:
http://rusticisoftware.github.io/TinCanJS/
However from my experience there's a bit of a learning curve. Not sure where you are at with TinCan experience, but it requires knowing how to construct statements and sending them to an endpoint. You could create an account on SCORM Cloud, which provides end points, and it's free to start.
Regarding learning how to construct statements, search for "deep dive" on the the Tin Can Blog at http://tincanapi.com/blog/
Thanks Norm for popping in here - you're all over the forums today! ;-)
Hi Ashley...well I know how busy you are so just trying to help...ha ha.
I've never really done much contributing, so thought I'd give it a shot while between projects.
A friendly, helping hand is always appreciated. :-)
Looking forward to seeing more!
Hi Ayoub,
I've been experimenting lots with this lately, and have a solution for you. Is this something you are still trying to achieve?
Hi Alex,
If you're able to share what you've set up I'm sure it'll help other users who may come across this thread and are trying to accomplish the same. Thanks in advance for being able to share!
Hi Alex,
Yes, I'm still interested! Are you sharing or selling?
I'm happy to share some of my findings. Though I'm still getting my head round some of the finer points of TinCan API. What specifically is it you're trying to achieve?
Hi Alex,
As I said, I know very little javascript. I'm looking for a basic generic script which I can use to trigger sending a basic statement.
Something like 'current user completed part 1 with score 50'
'Current user' 'verb' 'object' with 'score'
Can you help me with that?
Thanks in advance, Ayoub
Ayoub,
Is this something that can't be done using Storyline's built in tincan reporting?
Below is some code I use to add the verb 'Mastered' on a trigger:
var tincan = new TinCan();
tincan.sendStatement(
{
verb: {
id: "http://adlnet.gov/expapi/verbs/mastered"
},
object: {
id: "https://titan-learning.com/gb_xapi_content/test1/"
}
}
);
If you change the verb to whichever you want, and change the ID to the activity ID, that should work for you.
Thanks for your response, Alex, and I hope that is going to do the trick for Ayoub! :)
Thanks, Alex! I appreciate this very much and I'll give it a try.
Hello,
I've been trying to get my head around TCAPI/javascript for tracking purposes for a while and can't seem to get anywhere with it. We are currently constructing a course in Storyline 2 and uploading to TalentLMS, which offers reports that are not specific enough for us.
Our goal is to be able to track (as a start) wether or not certain markers were clicked.
Any help on how this can go about would be greatly appreciated.
Also, I imagine these reports won't show up on the LMS reports section, so where do you guys access your xAPI tracking data?
The solution I outlined for Ayoub should work for your needs as well. xAPI tracking data is stored in an LRS. Have you connected an LRS to your LMS?
Again, my understanding is disproportionate to the time I've spent researching. Do I need an external LRS? Talent LMS does claim to offer one built in and I have been provided with a 'Tincan LRS endpoint'
Where exactly was that code embedded? and how did you know where to find the object?
Thanks a bunch for your help!
If you have a Tincan LRS endpoint, I assume that would work fine. The object ID should be possible to find in your LMS (sadly every LMS is different and I'm not familiar with TalentLMS, so I can't help you there). The code is embedded in your course, as an additional trigger where you want to track the markers.
Hey Alex, thanks again for your help.
As far as I know, any object ID is relevant to the whole unit (courseware uploaded as a tincan package).
I read the Tincan.xml(SL output) and saw all the different activities that were defined, but still can't figure out how I can add an activity ( I did manage to get an understanding of the anatomy of a TC statement, but not how I can create an additional activity.
Do you need to create an activity? Couildn't you just manually trigger statments and use the statements for your tracking?
Or are you asking how to you send those statements? Which would be by using execute javascript triggers in SL.
Hello Alex,
I constructed a simple unit consisting of one slide. On that slide there's a marker which shows an additional layer. When that layer's timeline starts, the javascript you provided above will execute.
In addition, I created an exit button and changed the exit behavior in Storyline's configuration.js accordingly, but I still can't see it on my LRS feed. Any thoughts?
Thanks for your help
Ah, try adding <script src="tincan-min.js"></script> into the head of story.html and add tincan-min.js into the file package.
As Alex points out the TinCan JavaScript library (tincan-min.js) needs to be included. Also, you will need to initialize the library with authentication credentials (that's easy). Without authentication, you cannot send statements. Attached is a sample Storyline course that sends my own customized statements to the LRS.
This is how to initialize the library with auth credentials:
var tincan = new TinCan ({url: window.location.href});
Courses launched from a TinCan compliant LMS will include an auth token (and other info) in the launch url. TinCan.js can use that info to construct an object through which you can send statements.
Hey,
A couple of things are still unclear about that:
-'Courses launched from a TC tompliant LMS will include an auth token in the launch url'. Am I missing something? The course needs to be uploaded to the LMS to have a url - therefore pretty much impossible to include that url in one of the files in it's package...
-'var tincan = new TinCan ({url: window.location.href});'
I assume this line should be embedded in the Tincan-min.js ? should it replace anything or just be added in?
-should the tincan.js be included in the root folder of the SL output, or inside the 'content' folder?
I'm in contact with my LMS provider to get those credentials, so far they have said the following:
"If you want to access(retrieve) the contents of the LRS directly through your TinCan module,this is not possible.
TinCan modules can only send data to the TalentLMS TinCan endpoint, not pull data.
The LRS contents are only available inside your TalentLMS domain, throught the reports/timeline options."
Does that collide with your suggested method?
Just want to say I really appreciate your help, and I really feel close to a solution.
Thanks,
Erez
HI Erez. The sample file contains an explanation. (On the first slide there is a trigger (JS) with notes). It's a bit long to include here.
Briefly:
var tincan = new TinCan ({url: window.location.href}); >>>> this is in the JS trigger. When the course launches from the LMS, that code grabs the current url. You don't need to know it ahead of time.
Publish the course for TinCan. Then edit story.html to include tin-can-min.js (which is part of the previous attachment.) So add this before closing</head> tag:
<script src="tincan-min.js"></script>
And copy file tin-can-min.js to the same level as story.html.
The note from the LMS provider indicates you cannot get statements from the LMS, but you can send them. So if you don't need to retrieve anything, and only need to send statements, no problem.
Do you have easy access to the reports? If not, you can use SCORM Cloud (free) to test, making sure everything is perfect before deploying course. Contact me by email if you need a hand with that.
Hi Erez,
I also wanted to share this helpful article on testing and troubleshooting your content if loaded to SCORM Cloud.
Hey Norm,
Again, I can't thank you enough for your help.
I have uploaded the test file you gave me and still I'm only getting these basic reports and not the different layers.
I believe I did everything correctly. Any thoughts?
This discussion is closed. You can start a new discussion or contact Articulate Support.