how to send Tin Can statements with javascript

Feb 10, 2014

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
Norm Cousineau

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/

 

Job Vlaming

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

Alex Lapthorne

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.

Erez Goren

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?

Erez Goren

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!

Erez Goren

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.

Erez Goren

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

Norm Cousineau

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.

Erez Goren

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

Norm Cousineau

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.

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