Hello, I want to pull the username (ID) from our LMS (Totara) and have it show in Articulate Storyline 360. I've managed to find (and get working) JS for firstname and surname, but I don't know how to change this so it pulls the username. The username isn't a combination of firstname and surname so I can't just combine the existing JS unfortunately. It's a unique value which sits in the Username field of Totara.
If the username is stored in the LMS Student ID field, then you can retrieve it using lmsAPI.GetStudentID();. This calls to the SCORM and AICC data element cmi.core.student_id. If your LMS is using a custom field to store that information, then it will be considerably more difficult to retrieve it.
This list of functions available in the LMSAPI.js file is still relevant, and as the author states, reverse-engineer with caution.
Thank you both, but I don't know what I'm doing with JS and need an idiot's guide. I've used this JS to get Student Name:
var lmsAPI = parent; var name = lmsAPI.GetStudentName(); var nameArray = name.split(", "); var firstName = nameArray[1]; var lastName = nameArray[0]; var player = GetPlayer(); player.SetVar('first_name',firstName); player.SetVar('last_name',lastName);
But I don't know how to change it to get StudentID instead. I tried changing var name to say GetStudentID and then changed player.SetVar to 'student_ID'.studentID and then set up a variable called studentID but nothing happened. Can you tell I really have no idea what I'm doing!
It really depends on if the ID you need to call is part of the scorm data model or a custom field. Do you know what StudentID gives you in the console? What errors do you get?
Using your existing code, add the following 2 lines to the bottom:
var lmsStudent_ID = lmsAPI.GetStudentID(); player.SetVar("lmsStudent_ID", lmsStudent_ID);
In Storyline, create a new variable called lmsStudent_ID. Open a slide, and from the Insert menu, select Text | Reference. Insert your new variable lmsStudent_ID. Publish your file, upload it to your LMS, and launch it.
And you might want to add some console.logs or alerts at key points. To see whether you'r code is running fine...or at some point your have errors.
console.log("LMSApi is available "+LMSApi);
console.log("name is: "+name);
or with alerts... alert("test1");
alert("name is: "+name);
But as said if you dont know Javascript and just copy/paste...well either start learning javascript or share a Storyline file...else you can make hundreds of mistakes. From typos to copying and pasting garbage...
8 Replies
If the username is stored in the LMS Student ID field, then you can retrieve it using lmsAPI.GetStudentID();. This calls to the SCORM and AICC data element cmi.core.student_id. If your LMS is using a custom field to store that information, then it will be considerably more difficult to retrieve it.
This list of functions available in the LMSAPI.js file is still relevant, and as the author states, reverse-engineer with caution.
https://community.articulate.com/discussions/articulate-storyline/help-with-javascript-and-pulling-data-from-an-lms
On most LMS's i work on ( Moodle, TalentLMS, Canvas, Blackboard ) this works well...
var lmsAPI = findLMSAPI(this);
myName = lmsAPI.GetStudentName();
Thank you both, but I don't know what I'm doing with JS and need an idiot's guide. I've used this JS to get Student Name:
var lmsAPI = parent;
var name = lmsAPI.GetStudentName();
var nameArray = name.split(", ");
var firstName = nameArray[1];
var lastName = nameArray[0];
var player = GetPlayer();
player.SetVar('first_name',firstName);
player.SetVar('last_name',lastName);
But I don't know how to change it to get StudentID instead. I tried changing var name to say GetStudentID and then changed player.SetVar to 'student_ID'.studentID and then set up a variable called studentID but nothing happened. Can you tell I really have no idea what I'm doing!
Is anyone able to help? I've not been successful at all with this and have no idea what to do
It really depends on if the ID you need to call is part of the scorm data model or a custom field. Do you know what StudentID gives you in the console? What errors do you get?
Sent from my iPhone
Do share a story. Then we can check... and update..and jou can try on your Lms
Using your existing code, add the following 2 lines to the bottom:
var lmsStudent_ID = lmsAPI.GetStudentID();
player.SetVar("lmsStudent_ID", lmsStudent_ID);
In Storyline, create a new variable called
lmsStudent_ID
. Open a slide, and from the Insert menu, select Text | Reference. Insert your new variablelmsStudent_ID
. Publish your file, upload it to your LMS, and launch it.And you might want to add some console.logs or alerts at key points. To see whether you'r code is running fine...or at some point your have errors.
console.log("LMSApi is available "+LMSApi);
console.log("name is: "+name);
or with alerts...
alert("test1");
alert("name is: "+name);
But as said if you dont know Javascript and just copy/paste...well either start learning javascript or share a Storyline file...else you can make hundreds of mistakes. From typos to copying and pasting garbage...