Forum Discussion
Getting student name from the LMS and using it in Articulate
In the LMS we are about to use, we can get the student name since the SCORM runtime variable for it is "cmi.core.student_name". However, how do I get it as a variable in Articulate at run time?
- nathanleavittCommunity Member
The lmsAPI.GetStudentName(); method no longer works for me when I publish to HTML5 only. Here's the code that I use for HTML5:
//This trigger is set to execute when the timeline starts. In order for it to work, this slide requires a variable "newName".
//Get User Name embedded into file from LMS
var myName = SCORM_GetStudentName();//SCORM has last name, first and we are switching it around to first last.
var array = myName.split(',');
var newName = array[1] + ' ' + array[0];//Set the variable
var player = GetPlayer();
player.SetVar("newName", newName);FYI, we’ve found that although the lms.js file is still included in the published HTML5 zip package, it’s not actually used and all its functions and variables aren’t used in our LMS. I’m not sure if that has something to do with our LMS (Saba Cloud) or something else. Regardless, that’s why the lmsAPI variable is undefined in our LMS. Instead I used the SCORM_GetStudentName(); function from SCORMFunctions.js.
- SueAshbyCommunity Member
Thank you so much for this. Even though this was published so long ago, it helped me this morning when my js snippet stopped working. For some reason var myName = lmsAPI.GetStudentName(); was working in my Storyline file for quite some time and then stopped. I suspect that Moodle was updated or something. Anyway. I changed lmsAPI to SCORM_ and now it works and retrieves the student's first name. I am eternally grateful!
- MichaelAnder569Community Member
Create a javascript trigger and use some code like this:
var player = GetPlayer();
player.SetVar("NameOfYourStorylineVariable", variableValue);Let us know if you need more help than this. There is more sample code here: https://articulate.com/support/article/javascript-best-practices-and-examples
- LewisEigen1Community Member
Thanks so much. I think that will do it for me. Much appreciated.
- MarciaDoughertyCommunity Member
- JulianRose-c8fdCommunity Member
It might seem fairly obvious (retrospectively), but to note the methods here will not work when publishing a storyline to LMS / LRS with Report to an LMS = xAPI. Presumably the same is true with CMI5.
When you publish to xAPI the result is "undefined", similar to results others have reported using older LMS systems.
They do work fine when Report to an LMS = SCORM 1.2 or 2004 accordingly.
When publishing to xAPI we still get scormdriver.js in the output ../lib/.
There are snippets of code that look like they are to do with xAPI or CMI5. Is this still work in progress?
So now I must look for xAPI "equivalent" methods... maybe more javascript...post and get... - Jürgen_Schoene_Community Member
for xAPI it is not possible with scormdriver.js (there is no connection from course to LMS)
have a look in this video
https://www.youtube.com/watch?v=OGYTxy-ru4E&t=422s
the user name (if there is one) is encoded in the start url of the course
the details dependes on the LMS you use - probably for security reasons there is no name transmitted at all, but only a anonymous ID
- MichaelAnder569Community Member
Excellent Matthew. I should have refreshed the page before replying. I've use parts of your demos in my work. Keep up the great work!
- LewisEigenCommunity Member
Thanks Matthew. I appreciate the help.
- MarciaDoughertyCommunity Member
Matthew, I don't know if you have any other suggestions. I have been trying to get the JavaScript trigger to work using the script you provided, but with no luck. When I run it live in the LMS I am not getting an error, just nothing is being returned. Not sure what I am missing. Would it matter if I am using a demo version of 360? Are some features disabled?
- MarciaDoughertyCommunity Member
Hi Matthew,
Thanks for the quick response. The script you gave me did not do the job, but the link to the discussion did. I am publishing to SCORM 1.2 and using HTML5 with Flash. This is what worked for me. Thanks everyone.
var player = GetPlayer();
function findLMSAPI(win) {
// look in this window
if (win.hasOwnProperty("GetStudentID")) return win;// all done if no parent
else if (win.parent == win) return null;// climb up to parent window & look there
else return findLMSAPI(win.parent);
}
var lmsAPI = findLMSAPI(this);
var myName = lmsAPI.GetStudentName();
var array = myName.split(',');
var newName = array[1] + ' ' + array[0];
player.SetVar("newName", newName);Thanks,
Marcia
-----------------------------------------
The information contained in this email is confidential and is intended solely for the use of the person identified and intended as the recipient. If you are not the intended recipient, any disclosure, copying, distribution, or taking of any action in reliance on the contents is prohibited. If you receive this message in error, contact the sender immediately and delete it from your computer. Personal e-mails are restricted by PSECU policy. As such, PSECU specifically disclaims any responsibility or liability for any personal information or opinions of the author expressed in this email.- AaronMaxAbramowCommunity Member
Publishing Using HTML5 on Cornerstone LMS, This code was sort of working but giving me a duplicated name...
By modifying it slightly I was able to get rid of the duplication and have the full name display.I was hoping to separate the first and last name, but (after 22 attempts) I've decide to settle with it working this way.
The on-slide reference display variable is: %newName%
and the JS code was as follows:
var player = GetPlayer();
function findLMSAPI(win) {
// look in this window
if (win.hasOwnProperty("GetStudentID")) return win;
// all done if no parent
else if (win.parent == win) return null;
// climb up to parent window & look there
else return findLMSAPI(win.parent);
}
var lmsAPI = findLMSAPI(this);
var myName = lmsAPI.GetStudentName();
var array = myName.split(',');
var newName = array[0];
player.SetVar("newName", newName);
Thanks for the starting point!
- ThomasAlbrig879Community Member
Do you have a sample course I could look at please? I found TRAINEE.FIRST.NAME and TRAINEE.LAST.NAME in our Email settings on CSOD but I am not sure how to make it work.
- ClaudiusMitter-Community Member
works also in SABA Cloud
- KayodeArowoloCommunity Member
This JS is already giving me a headache. This might be a very simple fix for someone. All I need is to pull a student's name from Blackboard and insert it in a completion certificate slide that I have created. Please see the attached certificate with the script I'm using (created by Matthew Bibby). I am using Storyline 3. Any help will be greatly appreciated.