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?
- CandiceBoult-b4Community Member
Thanks for the fast reply Matthew. You can tell I'm very new to javascript.
The problem I am getting is that at the start of the name it says 'undefined'. I tried a code from another thread on here to only show the first name and that worked fine (pasted below), but for things like certificates etc it would be nice to have the full name pull through.
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();
// remove last name from array
var array = myName.split(' ');
var newName = array[0];
player.SetVar("newName", newName);ar("newName", newName);
I'm using the most up to date version of storyline 360, and exporting the to scorm 1.2.
Thank you
- CandiceBoult-b4Community Member
I have attached the storyline file I was working with. Please don't laugh at the slide I made, I just wanted to show others in my team what I had learnt so it was the most basic thing ever.
I have added a couple of slides that have screenshots of what I can see when it is used on the LMS and also the details stored on the back end of the LMS.
Let me know if you need any more info. I really appreciate you looking at this.
- CandiceBoult-b4Community Member
The screenshots are in the file, I included everything in one place to try and make it easier.
- DavidSweeney1Community Member
Matthew,
I am hoping you might be able to help me on this as I have a very similar issue to Candice above. I had this working for me for a year or so - retrieving both first and last names. However we upgraded our LMS and I am not sure if it is linked but I started to see "undefined" inserted before the full name. Going on your suggestion above, that the LMS might be storing the name in an unusual way, I updated the line in the code from:
var newName = array[1] + ' ' + array[0];
to
var newName = array[0];
and this worked, i.e. it retrieved the full name and the "undefined" was not included.
My question is, have you seen this more frequently now or do I need to investigate why the LMS is storing the name in this way? We use Moodle.
Regards,
David
- RobertWebbe-404Community Member
I have the same issue as Julian Rose, I like to retrieve the users first and last name but must publish my courses to xAPI. As Julian mentioned, that's not working. Is there someone who understands javascript and get it to work via scormdriver.js? When I review this file via Notepad, I see var strFirstName; and var strLastName; but don't know how get that working.