Adding a Storyline 360 variable to an xAPI sendStatement

Aug 05, 2021

My experience with adding JavaScript triggers to execute xAPI sendStatements in Storyline 360 has been limited to manually edited values in statements provided to me by our LMS and LRS provider.

After much searching and experimenting, I have found a way of reading the value of a Storyline 360 variable into an xAPI sendStatement.

I have a training module created in Storyline 360 where it is necessary to capture the learner's Sector and Role for conditional branching through customised content.

In the following example, I have added five Radio Buttons and grouped them into Button Set so that the user can select only one at any time. I've added Text labels to indicate each option.

Option screen

I've created a Storyline text variable called 'Sector'. When the learner selects a Radio button, the value of the Sector variable is updated.

Previously, I’ve used sendStatements like this when a user clicks on an object:

sendStatement("selected","", "Marketing","https://learn.mywebsite/course/view.php?id=2&section=1");

This results in an LRS record showing “Username selected Marketing”.

So far, so good, and suitable in many contexts. But what if the learner selects more than one button before submitting? There will be multiple LRS records to match. Not very helpful and confusing, as we'd have to find the most recent record to show the learner's final selection.

By using a single Storyline variable, the value of Sector will always be the last option selected by the learner. So how to use the value of a Storyline variable in an xAPI sendStatement? Many hours later, I found an answer that works.

I created a Submit button with the following JavaScript.


sendStatement("selected", "", GetPlayer().GetVar('Sector'), "https://learn.mywebsite/course/view.php?id=2&section=1");

Instead of manually editing each object trigger's selection name, e.g. "Marketing", etc., we can use the Storyline variable 'Sector' as shown attached to a single object, the Submit button.


Be the first to reply