First and last name from LMS for SCORM via Javascript and from data entry for WEB output together in one storyline-file

May 11, 2023

Not a question, but a (hopefully) useful contribution to this lovely community...

Recently, I was trying to figure out a way to make one storyline-file that imports the name from an LMS when it's published as a SCORM-file, & splits it into first and last name for informal addressing of the user, but at the same time lets you fill in your own first and last name for when you publish as a WEB-file. You may ask why? Why on earth would you wanna do that? Well, it turns out our subscribers use the SCORM-output on the LMS, and our non-subscribers use the WEB-output on our website (without tracking, so without any credit points, ha!). And… to make it as lean as possible, I wanted to embody this function in just one storyline-file: less work for me > I like! ;)

I’m aware that this topic might overlap with other discussion, but I didn't find this solution anywhere as prefab as I will now share it with you. Maybe someone could benefit from it (I sure would have! :)).

In attachment you can find the storyline-file with the Javascript code for the LMS. There is also some JS-code in the last slide to generate the date of the certificate.

Here the 2 Javascript-codes used:

For splitting the name from the LMS into first and last name:

var player = GetPlayer();
var myName = lmsAPI.GetStudentName();
var array = myName.split(',');
var newName = array[1] + ' ' + array[0];
player.SetVar("var_fullname", newName);
var firstName = array[1];
player.SetVar("var_firstname", firstName);
var lastName = array[0];
player.SetVar("var_lastname", lastName);

For the system date:

var m_names = new Array("jan", "febr", "mrt", 
"apr", "mei", "juni", "juli", "aug", "sept", 
"okt", "nov", "dec");
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth();
var yyyy = today.getFullYear();
if(dd<10) { dd='0'+dd } 
var date= dd+' '+m_names[mm]+' '+yyyy;
var player = GetPlayer();
player.SetVar("var_systemdate",date);

And that’s all there is to it!

I tried to build it as simple as possible. If you find a way to simplifying this even more, let me know!

I attached: 

  • the storyline-file
  • the SCORM-output
  • the WEB-output

In retrospect, it’s quite simple but I needed a lot of time to find the javascript code to split the full name, a way to show a different pathway depending on being in the scorm or web-output, and at the same time make it as simple as possible. Hope this helps anyone who has encountered a related issue. Let me know if this was of any help for you!:) Or if you can build further on this file with some extra fancy Javascript: be my guest! Would be so nice to have like one storyline ‘reference’ file with all the Javascript you could use/need. #dreamingisallowed 😊

Kind regards!

Sofie from Belgium

Be the first to reply