I have a certificate at the end of one of my SL360 courses that takes the user's name from the LMS and displays it on the certificate. To do this I execute the following javascript:
var myName = lmsAPI.GetStudentName(); var array = myName.split(','); var newName = array[1] + ' ' + array[0]; player.SetVar("newName", newName);
This is tested and works well in SCORM Cloud but it doesn't work in Moodle. I'd be grateful if anyone has any clues that might help.
I don't use Moodle but wonder your problem would be solved by using this: var myName = lmsAPI.GetStudentID(); instead if this: var myName = lmsAPI.GetStudentName();
I believe the thread linked below has the full answer to your question. It looks like when publishing html5 to Moodle, Moodle creates an Iframe to hold the content. This means StoryLine is no longer in the parent window. The code located here should resolve the issue: Link to Thread
The issue seems to have been introduced when I've published my old SL2 courses in SL360, possibly something to do with switching to HTML5 with Flash fallback during publish perhaps.
I found the same when switching to 360. Here is the code we are currently using.
I found the username came through around the wrong way so had to split it out.
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 last = array[0]; var first = array[1]; first = first.substring(1); var firstChar = first.charAt(0); var lastChar = last.charAt(0); var fandl = firstChar.concat(lastChar); var fullname = first.concat(" ",last); player.SetVar("Name", fullname); player.SetVar("Initials",fandl); player.SetVar("Firstname",first);
Does anyone know how to pass the username from the LMS to Storyline without using JS? I'm looking for a solution that would work in the Articulate Mobile Player.
8 Replies
I don't use Moodle but wonder your problem would be solved by using this: var myName = lmsAPI.GetStudentID();
instead if this: var myName = lmsAPI.GetStudentName();
I believe the thread linked below has the full answer to your question. It looks like when publishing html5 to Moodle, Moodle creates an Iframe to hold the content. This means StoryLine is no longer in the parent window. The code located here should resolve the issue:
Link to Thread
Thanks for the suggestion Owen,
The issue seems to have been introduced when I've published my old SL2 courses in SL360, possibly something to do with switching to HTML5 with Flash fallback during publish perhaps.
The info in the following thread has provided a solution that seems to work in Chrome, Firefox and IE: https://community.articulate.com/discussions/articulate-storyline/username-from-an-lms-on-both-flash-and-html5
It seems as though we've both found the same thread Owen! Thanks again for your help, it's much appreciated.
No problem. I knew I had viewed this issue previously, I just needed to carve out some time in my day to look for it. #SufferingFromMeetingBurnout
I found the same when switching to 360. Here is the code we are currently using.
I found the username came through around the wrong way so had to split it out.
Thanks for this Tristan, I'll give this a go too, it's always good to have a few different ways of doing something!
Does anyone know how to pass the username from the LMS to Storyline without using JS? I'm looking for a solution that would work in the Articulate Mobile Player.
This discussion is closed. You can start a new discussion or contact Articulate Support.