Storyline Variables and SCORM

Oct 22, 2012

Is there an interface API in Storyline which might allow populating a Storyline variable with a value stored in JavaScript?  My particular example would be retrieving any of the: [Student name, Lesson Status] from the SCORM LMS and making it available to the course automatically.

I am OK writing the SCORM JavaScript to retrieve the values into a known global variable.  What I lack is a mechanism in Storyline to retrieve those values and insert in a Storyline variable.

54 Replies
Riccardo Scambia

Hi everybody!

Please, I have something in my mind that is not so clear...

how can I store a custom variable in LMS in order to retrieve it automatically when the student come back to the course?

I saw :  

var Player = getPlayer();

player.SetVar("newName", newName);

but isnt this code relative to Articulate only? I mean, this code is really setting an LMS variable or just a local and temporary variable?

thanks guys!!      

Sam Carter

Riccardo Scambia said:

but isnt this code relative to Articulate only? I mean, this code is really setting an LMS variable or just a local and temporary variable?


That code sets a Storyline variable which will be stored in the SCORM suspend_data on the LMS.  This allows the variable's value to persist when the student logs out and resumes the course later.  Not exactly right to call it an "LMS variable", there are SCORM variables like cmi.core.lesson_status and others.  suspend_data is considered course data persisted on the LMS more than an LMS variable.

If you want to do this, be sure that you declare the variable in Storyline.  The JavaScript snippet you wrote won't dynamically create the variable in Storyline.

Riccardo Scambia

Sam Clark said:

Riccardo Scambia said:

but isnt this code relative to Articulate only? I mean, this code is really setting an LMS variable or just a local and temporary variable?


That code sets a Storyline variable which will be stored in the SCORM suspend_data on the LMS.  This allows the variable's value to persist when the student logs out and resumes the course later.  Not exactly right to call it an "LMS variable", there are SCORM variables like cmi.core.lesson_status and others.  suspend_data is considered course data persisted on the LMS more than an LMS variable.

If you want to do this, be sure that you declare the variable in Storyline.  The JavaScript snippet you wrote won't dynamically create the variable in Storyline.


Ok, so if I set a var in Storyline with a default value and then I ll change that value during the course, the student will be able to retrieve that informations also after a logout, am i right? This system works fine everywhere or there are some known issues about that? I will use SABA as LMS..

And to change the variable value i need to use player.SetVar() or triggers instead?

Thank u very much!

Sam Carter

Riccardo Scambia said:

but isnt this code relative to Articulate only? I mean, this code is really setting an LMS variable or just a local and temporary 


Ok, so if I set a var in Storyline with a default value and then I ll change that value during the course, the student will be able to retrieve that informations also after a logout, am i right? This system works fine everywhere or there are some known issues about that? I will use SABA as LMS..

And to change the variable value i need to use player.SetVar() or triggers instead?

I think you've got it right. 

Any SCORM LMS should save and restore the suspend_data and along with that, the course will restore Storyline variable values.

Don't take anyone's word for it.  Run your own tests on http://cloud.scorm.com

Juanjo Haro

One really cool think that it will be great to have is the possibility to keep these variables even if the user choose "no resume" when returning to the course.

I mean. In my flash courses I have a menu and, with some icons, i indicate wich module is done and wich not. I put a question at the beginning of this menu "Would you like to return to last point where you left off?", if the user chooses Yes, the las module viewed is loaded and, in the menu, the icons sets to proper states BUT if the user chooses "no", he stays in the menu but the icins are set to the proper states (completed or not). This is possible by storing and array of "true,false,true... " in the suspend_data and recovering this array everytime the course is loaded (wich is not possible with Storyline)

In Storyline, if the user chooses NO resume, all the variables are erased and the states then reset.

Right now, a question comes to my mind, if the user chooses No resume, all the information about status in the course in the LMS is erased? I'm hopping not...

As i say, it will be great to have the possibility to let the user choose "no resume" and keep all these variables, and simple load the course in the first slide cause, actually if i'm not wrong, the only way to prevent that is "always resume".

Brenda Heilman

Phil Mayor said:

If you want the student name then try this

var player = GetPlayer();

var myName = lmsAPI.GetStudentName();

var array  = myName.split(',');
var newName = array[1] + '  ' + array[0];

player.SetVar("newName", newName);

//myName = player.GetVar('myName');

//player.SetVar("newName", newName);


Seriously, Phil, this is soooo awesome!  It worked perfectly in my PeopleSoft LMS.  I did a quick step-by-step on my blog to grab/insert either the first name, last name, or both for any others using PeopleSoft:  http://learnnd.blogspot.com/2013/05/grab-learners-name-from-peoplesoft-elm.html

Thank you, thank you!

Zio Fonta

hello,

is it possible with the same method to set SCORM variables like cmi.core.lesson_status using a trigger into Storyline? I would like to have a different cmi.core.lesson_id and cmi.core.lesson_status for each slide to set , so that the LMS can have information on each slide that has been wieved or not. Please let me know, i already posted another topic with no answer.

Sam Carter

Zio Fonta said:

hello,

is it possible with the same method to set SCORM variables like cmi.core.lesson_status using a trigger into Storyline? I would like to have a different cmi.core.lesson_id and cmi.core.lesson_status for each slide to set , so that the LMS can have information on each slide that has been wieved or not. Please let me know, i already posted another topic with no answer.


Lesson_ID is defined by the LMS, so if you wanted different (unique?) lesson_id for every page in a course, then each page would need to be a unique SCORM SCO.

Yes, you could capture the API via JavaScript and try to set a unique lesson_id, but the LMS API should return an error.  lesson_id should be read-only.

You could set lesson_status which is read-write without error, but Storyline may have some other value in mind and overwrite your value later.  Best to use Storyline methods to set lesson_status:  (1) pages viewed, or (2)quiz results.

This hasn't solved your problem, so maybe there's another approach that will.

Steve Flowers

Hi Zio -

As Sam points out, lesson_id is read only. This uniquely identifies the SCO. lesson_status can be written but it's 1 status for 1 SCO so this won't help your case. The data element that would best fit your needs would be SCORM interactions. These are a bit complicated. Here's an overview of just how complicated:

http://www.ostyn.com/standards/docs/SCORM_Interactions.pdf

The Tin Can API captures exactly what you're looking for out of the box. Not that this helps if you're still using a SCORM LMS

Zio Fonta

Thank you, i got the point. So, inside a single lesson, are there some parameters that can be passed to LMS somehow to track each slide viewed? For example reading the cookies that save the course progress? Or maybe is it possible to define several custom variables and pass them to LMS with a specific function? Thanx

Sinchu Raj

HI All ,

Can anyone help me for setting the storyline course completion? now i have two result page in  my course, and these two wont come for all the users so i need to mark my course complete when i come to any of these resul page(result page is tracking two different banks.)

I have planned to do this  in below way. for first result page i link with course lms tracking and another i need to manually write the javacript code to mark the course as completed once user pass the assessment. can someone help me how to write javascript  code for marking the course as completed? i am not sure this can be done in stopryline ?  ? ? ?

Gaurav Goel

This sample contains an example of WebObject sending SCORM variable to LMS. Published output has two javascript files. WebObject uses these two files.

1. story_content/custom.js: This file acts as bridge between Storyline variables and WebObject. WebObject uses custom.js file to communicate with LMS and also to update the Storyline variables on slide for display.

2. webobject/scripts/main.js: WebObject uses main.js for all its internal logics. 


// custom.js

// JavaScript Document

var findAPITries = 0;

var lmsAPI;

var gameScore = 0;

function findAPI(win){

while ((win.objLMS == null) && (win.parent != null) && (win.parent != win))

{

findAPITries++;

// Note: 7 is an arbitrary number, but should be more than sufficient

if (findAPITries > 7) 

{

alert("Error finding API -- too deeply nested.");

return null;

}

win = win.parent;

}

return win.objLMS;

}

function getAPI()

{

   var theAPI = findAPI(window);

   if ((theAPI == null) && (window.opener != null) && (typeof(window.opener) != "undefined"))

   {

      theAPI = findAPI(window.opener);

   }

   if (theAPI == null)

   {

    if (_Debug) // BMD added

      alert("Unable to find an API adapter");

   }

   return theAPI

}

function init(){

lmsAPI = getAPI();

}

function GetPlayer()

{

var player = parent.GetPlayer();

return player;

}

function setVariable(varName, varValue){

var player = GetPlayer();

player.SetVar(varName, varValue);

setScormScore();

}

function getVariable(varName){

var player = GetPlayer();

gameScore = player.GetVar(varName);

console.log("gameScore=" + gameScore);

console.log("cmi.core.score.raw=" + getScormScore());

}

function setScormScore(){

var blnResult;

blnResult = lmsAPI.SetScore(gameScore, 100, 0);

console.log("Returning " + blnResult);

return blnResult;

}

function getScormScore(){

var sLearnerScore = lmsAPI.GetScore();

return sLearnerScore;

}

init();

---------------------------------------------------------

// main.js

// JavaScript Document

function setGameScore(score){

gameScore = score;

setVariable("gameScore", gameScore);

}

function getGameScore(){

getVariable("gameScore");

}

Sarah Doyle

Hi there! 

Sorry to reopen a pretty old thread, but this discussion is the closest I've found to what I'm looking for.  Basically, I work for a provider of eLearning solutions to DoD agencies.  We just switched this year from using Lectora for rapid development to using Storyline and have been loving it, except that I can't seem to find an answer to one perplexing situation. 

In order to be compliant with our clients' SCORM requirements, we have to invoke and set a value for cmi.success_status and cmi.location at least once.

Using the LMS publish settings in Storyline, no matter what we select, neither of these seem to be triggered.  I found another thread that said "cmi.location" isn't required and therefore not used in Storyline....

In Lectora, it might not have been applied by default, but it was as simple as accessing a list of available SCORM variables and writing a value to it on the completion page... but I can't find a way to do that in Storyline.

I've really loved the way Storyline is designed - and I'm guessing I'm just missing something about how to accomplish this and make our courseware compliant.  Can anyone help?

Thank you so much!

-Sarah

Sarah Doyle

OK, update - I read a little more on the forums about cmi.success_status and realized that this really *has* to be used in Storyline and it must have been user error.     I started over with a very simple results slide and quiz setup, and sure enough, cmi.success_status did have a value set in run-time by the published lesson.

But I'm still drawing a blank on cmi.location.  Above, someone asked if they could use a trigger or JavaScript to write a value into a SCORM variable.  I understand the reasoning provided regarding why it wouldn't work well for the two cmi variables mentioned, but what about cmi.location since it seems to not be used by Storyline in the first place?

Thanks so much for any help!

Best,

-Sarah

Brian Caudill

Since you are able to add javascript to triggers what I did is just add console.log(window.lmsAPI) and console.log(window) and console.log(lmsAPI) and that will give you all the public methods for the objects in the console and you can navigate the object tree in the console and pick the ones you want to use in your code. That is the best documentation you are going to get I think. :)

Katherine Roberts

Hello all!  I am new to the site and came across some great info here.  I know this discussion is a couple of years old, but I am hoping to get some help on retrieving the student's name from the LMS.

Here is my problem....

When retrieving the learner's name from the LMS in Storyline (v1.0) from Skilport LMS with SCORM 2004, I get the following: undefined firstname lastname

Now, when using Captivate 8's built in user variable to call the Student Name, it displays correctly (in SCORM 2004).

I am not a java guru, but I've copied and pasted the code into the java script trigger exactly as written above:

var player = GetPlayer();

var myName = lmsAPI.GetStudentName();

var array  = myName.split(',');
var newName = array[1] + '  ' + array[0];

player.SetVar("newName", newName);

...and tried following this as well https://elearningenhanced.com/blog/2012/08/15/grabbing-student%E2%80%99s-name-lms-storyline

To make sure I hadn't really messed things up, I downloaded James' story file, published it, and uploaded it to our test LMS - it does the same thing as my script: undefined firstname lastname

Any clue why/how "undefined" is showing up in the results?  

Ashley Terwilliger-Pollard

Hi Casper,

This thread is a bit older so I'm not certain that Phil is subscribed, with that in mind you may want to message him directly using the "contact me" button on his profile. Additionally if it works in SCORM Cloud, you may want to reach out to the Moodle team to see if they have any additional info.