Is your LMS dated and only supporting SCORM 1.2 and 2004 and not xAPI?

If you’re reading this, then chances are you already know how little learning data is captured when using SCORM.

So how can capture xAPI data in an LMS that only supports SCORM?

This can be achieved using a little bit of JavaScript. For the purpose of this discussion, I’m going to be using Storyline 360 as the Authoring tool, SCORM Cloud as the SCORM testing environment (LMS) and Learning Locker as the Learning Record Store.

I originally came across an article my Melissa Melloway https://www.linkedin.com/pulse/send-xapi-statements-from-storyline-5-short-videos-milloway-msit/ that led me down the path to implementing this solution.

So, let’s get started!

We’ll create a simple Storyline file that simply navigates from page to page and open a link or two.

storyline_simple_project-1024x614 My LMS only supports SCORM – How do I use xAPI?
Storyline simple project

Make sure you label the slides as we’ll use this in the JavaScript to send to the LRS.

Next we’re going to add a trigger for each xAPI statement we want to send to the LRS on the JavaScript trigger

add_trigger-1024x618 My LMS only supports SCORM – How do I use xAPI?
Storyline adding a JavaScript Trigger

And add the following code:

xapistatement(verb,shortdesc,longdesc);

This is the JavaScript that will generate and send the xAPIstatements to the LRS. Don’t forget to include the semicolon at the end, it won’t work without it!

Let’s break down the code that we’re going to be using:

xapistatement  – this is the name of the JavaScript function that will be called. The function takes parameters. In this case, the three parameters are verb,shortdesc and longdesc.

verb

The verb is the part of the xAPI statement that is the what of the experience. There are a predefined set of verbs in the JavaScript file xapi_adl.js. You can add more to this by locating the definition in a verb registry like  https://registry.tincanapi.com/or http://xapi.vocab.pub/datasets/adl/

The list that is in the xapi_adl.js and include the following verbs:

When adding the verb in the statement, make sure you wrap it in single quotes.

So, to add the first part:

xapistatement('viewed',shortdesc,longdesc);

shortdesc

This is the short description of what the experience is and make sure you wrap it in single quotes. For example, ‘YouTube Video’.

So now we would have:

xapistatement('viewed','xAPI Introduction YouTube Video',longdesc);

longdesc

This will provide more details on experience. If we look a tour example, this may include a URL to the video and a description of what the video is and make sure you wrap it in single quotes. For example, ‘’ExperienceAPI (aka Tin Can API Demystified. https://www.youtube.com/watch?v=y42MSS1DJqc&t=2s’

So, our final code that we’ll add will look like:

xapistatement('viewed','xAPI Introduction YouTube Video','Experience API (aka Tin Can API Demystified. https://www.youtube.com/watch?v=y42MSS1DJqc&t=2s');
js_trigger My LMS only supports SCORM – How do I use xAPI?
Trigger code for sending the xAPI statement

You can add as many of these as you want to either one trigger or multiple triggers. If adding to one trigger, simply add another xapistatement function code after the semicolon. 

Something to keep in mind, triggers are fired in a sequential order, so be aware of the order of the triggers. For example, you don’t want to put an exit verb before a complete verb, when the actions are actually the other way around.

trigger_order My LMS only supports SCORM – How do I use xAPI?
Trigger order in Storyline is important!

Once you have all the statements in your Storyline project, go ahead and publish the project, and then open the folder location. We now need to add a couple of JavaScript files and modify a some of the files to make sure we are calling the xapistatement function.

We need to add 2 files to the story_content folder. These are the xapi_adl.js and the xapi_scorm.js files (there’s a link at the end to all the files).

In the story_content folder, modify xapi_scorm.js to point to your LRS. You will also need to add the authkey from your LRS. Depending on your LRS, the authkey may be setup as a single string or as a base64(username:password). If you’re going to need this, your authkey may look like: “Basic ” + toBase64(‘username:password’); Check with your LRS as to which one to use.

var authkey = 'From Your LRS';
var lrs = 'https://link.to.your.lrs.xapi';

Now that we have the xapi_scorm.js file set up (and you’ve saved it!), we need to modify some of the core Storyline HTML files to link and use the new JavaScript files.

In the SCORM root folder, modify the following files:

index_lms_html5.html

AFTER the lone of code <script src=”lms/API.js”charset=”utf-8″></script> add the following lines in this order:

&amp;amp;amp;amp;lt;script src="story_content/xapi_adl.js"&amp;amp;amp;amp;gt;&amp;amp;amp;amp;lt;/script&amp;amp;amp;amp;gt;
&amp;amp;amp;amp;lt;script src="story_content/xapi_scorm.js"&amp;amp;amp;amp;gt;&amp;amp;amp;amp;lt;/script&amp;amp;amp;amp;gt;  

Now we need to modify the imsmanifest.xml. This is the file that SCORM uses and sets the the files that will be used as part of the SCORM package. We need to include the 2 files we added to the story_content folder.

Open and locate the line where the code is <file href=”story_content/story.js” />

Directly after this line, insert the following lines of code:

&amp;amp;amp;amp;lt;file href="story_content/xapi_adl.js" /&amp;amp;amp;amp;gt;
&amp;amp;amp;amp;lt;file href="story_content/xapi_scorm.js" /&amp;amp;amp;amp;gt;

Save all the files.

Next, we need to zip up the folder where all the SCORM files are. Go to the root folder of the published SCORM files, highlight all the files and right click and compress.

Upload this file to your LMS in the normal manner you would any SCORM package. Run through the SCORM course as a student. If all is correct,your xAPI statements should be being sent to the LRS.

Below are the results as seen in the browser console, LRS and SCORM report.

Some things to note:

Watch for the copying and pasting of the code. I find if you copy and paste into Notepad or something similar, it strips the characters that may break JavaScript.

In addition, the email address and name in the Actor part of the statement is set to Test User as a back up if the SCORM package can’t pick up the student name.

console-1024x263 My LMS only supports SCORM – How do I use xAPI?
xAPI object in the Browser Console (Chrome)
learninglocker-e1555040531397-898x1024 My LMS only supports SCORM – How do I use xAPI?
scome_cloud-1024x816 My LMS only supports SCORM – How do I use xAPI?
SCORM results in SCORM Cloud

Click here to download the files.

4 Responses

Leave a Reply

Your email address will not be published. Required fields are marked *

© The Digital Learning Guy | xapi.com.au
ABN 364 4183 4283