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?
40 Replies
- NishaMakan-3a6fCommunity Member
Hi. I have a Storyline SCORM package embedded in an iframe on my LMS course page. I'm wanting to include the learners name in the Storyline file however the name is not showing up as the embedded course doesn't seem to talk to the LMS. I am getting a course saying it is unable to talk to the LMS API.
I tested the course by running it like a normal eLearning course which launches from the training course page in a new window - in this instance the names are appearing in the module, so I know the Execute Javascript code is working correctly.
Does anyone have any advice on how I could get this to work in my iframe version? The LMS I am using is Totara.
- k1967hHayesCommunity Member
This code is working for me on Totara - sadly I can't advise on it as I either found it within this thread or a previous discussion:
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);var lmsAPI = findLMSAPI(this);
var StudentID = lmsAPI.Getstudent_id();
player.SetVar("StudentID", StudentID); - k1967hHayesCommunity Member
Mr Bibby - you are simply a legend! Brilliant.
- GregMellang1Community Member
Matthew, your code works flawlessly in PeopleSoft Enterprise Learning Management (ELM).
A lot cleaner than what I used in Captivate for the past few years. Thanks so much for sharing.
- RyanKrugerCommunity Member
Any chance I can call on anyone to help me identify how I get similar functionality in Litmos LMS publishing as SCORM 1.2 - beyond the learner name, I'd like to collect another profile attribute as well... I'm using:
var player = GetPlayer();function findLMSAPI(win) {
if (win.hasOwnProperty("GetStudentID")) return win;
else if (win.parent == win) return null;
else return findLMSAPI(win.parent);
}
var lmsAPI = findLMSAPI(this);
var myName = lmsAPI.GetStudentName();
var array = myName.split(',');
var LMSName = array[1] + ' ' + array[0];
player.SetVar("name", LMSName);
This successfully writes the learner's first and last name to the eLearning displayed from Litmos.
What I'd like to get now is a custom field from the learner's profile in Litmos. According to our admin, this particular field is called "CustomField2".
- RyanKrugerCommunity Member
Sounds like this may need to be an http javascript call using our specific LMS' API. Has anyone tried this?
- JoeFrancisCommunity Member
Quite a while ago, Sam Coulson replied to a request surrounding retrieving data from an LMS. He included the list of variables LMSAPI.js includes. These are industry-standard variables and functions, originally used by AICC-compliant LMS' and courses.
IF your LMS exposes one or more of these variables to eLearning courses, you MAY get a response when you query the LMS through them and/or attempt to write data using them. As Sam says in his message, "this is advanced coder territory, reverse-engineer with caution."
Speaking from experience, I was able to Get and Set several status' from (oddly enough) an older LMS, which I was unable to then replicate on a newer LMS, including LanguagePreference, Audio, and SpeedPreference. Other functions and variables, including student demographic data, are non-existent, probably because they aren't key data points and each LMS treats them a little differently.
- CandiceBoult-b4Community Member
I know this is an old thread but I'm hoping someone can help me here. I'm very much a beginner.
I have used the code below (from earlier in this thread) and it works great. The student ID bit isn't working for me, it just shows on the LMS as 'undefined', which is fine because I don't want the ID, I only want the name but have no idea how to amend the code to remove the ID bit.
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);Any help would be really appreciated. Thanks :)
- 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.
Related Content
- 8 months ago
- 8 months ago