I know you can have a user fill in a text box with their name and then later use that variable for personalization. What we would like to do is programmatically retrieve the user name from the LMS. Is there a way to set a variable with data from the LMS when the course is loaded instead of having the user enter their name?
Depends on how / where it's displayed. When the course launches, if the info is contained in the query string ?value=name, then it's pretty easy to grab.
If the info you want to grab appears in a parent window or frame consistently, it can be scraped with some creative javascript. Try this. You can retrieve your name from the title attribute of the user image in the upper right of the elearning heroes site by adding this to the developer's console:
Right-click the window and choose inspect (in Chrome) then click the console tab. Paste that line in there. The same concept applies to anything that appears in a page. You can scrape that data from a displayed page easily. Same concept applies to pages that aren't displayed. You can grab stuff from a page return and chisel little bits of data if the page address is reliable and the "address" of the information within the DOM is predictable.
Anything that appears in a page structure can be grabbed from Storyline as long as the user has access to the page.
var player = GetPlayer(); //might need to use lmsAPI=parent; on some LMS var myName = lmsAPI.GetStudentName(); var array = myName.split(','); var newName = array[1] + ' ' + array[0]; player.SetVar("newName", newName);
This is not working in HTML5 on Sakai. It does work in flash on Sakai.
I'd be curious to know if Sakai exposes student name as part of it's API... Not sure if this is an industry standard, and not sure if Sakai adheres to those industry standards.
Matthew Bibby gave me the answer. It works perfectly in Talensoft LMS.
Be aware that I only needed the firstname.
Here is his code to close my question.
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 name = lmsAPI.SCORM2004_GetStudentName(); var nameArray = name.split(','); var firstName = nameArray[1]; // var lastName = nameArray[0]; // var fullName = firstName + ' ' + lastName; var player = GetPlayer(); player.SetVar("Name",firstName);
I doubt you pay any attention to this 7 years later - but I just had to say thanks! I have been racking my head against this keyboard for hours...all I needed was the SCORM_ component to work with the LMS we are using. So excited!
I have unfortunately been unable to extract any information using many permutations of the code above from the LMS to my Articulate file. I am testing this with LearnDash.
If anyone has a .story file that works published as SCORM 2004 I would love to see it!
213 Replies
Speak with your IS team about it. It sounds like they would be in the best position to help you with this.
Hm, they're the ones asking me if it's possible to do this in Storyline :( Thanks for your input.
If they can give you some JavaScript that will grab the data you need from their system, then yes. I'll help you modify it to work with Storyline.
Thank you, Mr. Matthew Bibby!!! That would be fantastic. Let me see what they say and get back to you!
No worries Angela. Feel free to contact me directly if that's easier.
Hi Angela -
Depends on how / where it's displayed. When the course launches, if the info is contained in the query string ?value=name, then it's pretty easy to grab.
If the info you want to grab appears in a parent window or frame consistently, it can be scraped with some creative javascript. Try this. You can retrieve your name from the title attribute of the user image in the upper right of the elearning heroes site by adding this to the developer's console:
console.log(document.getElementsByClassName("user__img")[0].getAttribute("title"));
Right-click the window and choose inspect (in Chrome) then click the console tab. Paste that line in there. The same concept applies to anything that appears in a page. You can scrape that data from a displayed page easily. Same concept applies to pages that aren't displayed. You can grab stuff from a page return and chisel little bits of data if the page address is reliable and the "address" of the information within the DOM is predictable.
Anything that appears in a page structure can be grabbed from Storyline as long as the user has access to the page.
This .story worked for me in HTML5 from the storyline 360 latest version
This post was removed by the author
This post was removed by the author
This is not working in HTML5 on Sakai. It does work in flash on Sakai.
I'd be curious to know if Sakai exposes student name as part of it's API... Not sure if this is an industry standard, and not sure if Sakai adheres to those industry standards.
Kyle, see if this does the trick for you.
You'll need text variables in Storyline called
first_name
andlast_name
.If ever the "Works in all" portion doesn't work as is, try preceding it with the following script:
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);
… and the rest following "...GetPlayer() …"
Hello everybody,
I read every single message in this thread, and in some others.
But couldn't find what I am looking for :
My client LMS (Talentsoft) in SCORM 2004, can display cmi.learner_name as a variable.
I tried many many many syntaxes to grab this data, but I guess the only working one wasn't in my scope !
Can anymone help me ? what is the syntaxt to grab this value ?
thank you for the help
Philippe
Hello again,
Matthew Bibby gave me the answer. It works perfectly in Talensoft LMS.
Be aware that I only needed the firstname.
Here is his code to close my question.
Philippe
Steve,
I doubt you pay any attention to this 7 years later - but I just had to say thanks! I have been racking my head against this keyboard for hours...all I needed was the SCORM_ component to work with the LMS we are using.
So excited!
I have unfortunately been unable to extract any information using many permutations of the code above from the LMS to my Articulate file. I am testing this with LearnDash.
If anyone has a .story file that works published as SCORM 2004 I would love to see it!
Thanks
Hey can any one help,
any idea for custom description/track send to data on LMS through JS.
exammple question are attached
we need report Questions and what user select on lms
advanced thanks