Help with JavaScript and pulling data from an LMS
Jul 31, 2012
I know virtually nothing about writing JavaScript but was hoping for a little love from the group. I was interested in an earlier post about retrieving learner names from an LMS using JavaScript (http://community.articulate.com/forums/t/15117.aspx) and wanted to try to extend that to trying to retrieve other data like the Department ID or Job Code.
I got the JS from Phil for the learner name and it works great:
var player = GetPlayer();
var myName = lmsAPI.GetStudentName();
var array = myName.split(',');
var newName = array[1] + ' ' + array[0];
player.SetVar("newName", newName);
//myName = player.GetVar('myName');
//player.SetVar("newName", newName);
How would I modify this for a field called "DeptID" in the LMS?
Thanks to all,
Brett
42 Replies
Ashley,
Please explain why Articulate defers support of the scripting language, which it intentionally baked into Storyline, to the community at large. This is not a plug-in like the old Macromedia XTRAS which enhanced the functionality of Director, but were supported by the 3rd party company from which they originated. Javascript is part of the Storyline codebase, and it comes as part of the tool.
While a huge repository of Javascript programming conventions does exist, if the development tool we are writing the Javascript in does not execute the code properly, no amount of work-arounds will fix the fact that the development tool, Storyline, is broken.
What kind of problem are you having with code not being executed properly? I have not experienced that, except were I had an error in my code.
Articulate can't troubleshoot or write javascript code for users, there are just too many possibilities there, and the staff would all have to be javascript experts.
Storyline does not accurately retrieve the Lesson_Status (Status) from the LMS. What is does retrieve, it transposes from the AICC-defined standard values (Passed, Completed, Failed, Incomplete, Browsed, Not Attempted) to numerals (1-6). However, it is not retrieving the same thing the built-in debugger is.
You would be incorrect in asserting that Articulate cannot troubleshoot Javascript code for the users, because Articulate baked the Javascript into Storyline's codebase. While there isn't an expectation of the staff to assist in writing code, expectation that the code written would execute IS warranted. If I query the LMS from within the course about the student's completion status, and the response continues to be "Incomplete" (even though the debugger shows a status of "Passed"), then that is something Articulate needs to acknowledge, own, and correct.
I thought you were referring to custom code not being executed. This sounds like something that would warrant opening a support case, to have a higher-level tech assist you, unless someone here is familiar with calling that data from LMS.
Can you share some sample code? I'd be happy to test it on our LMS to see if I get a similar result.
Hi, Erik -
There's a lot going on in this thread and some helpful answers to a few of the questions. Is there something specific you're looking to have answered?
Joseph -
The returned numbers within GetStatus() are, I assume, intended as an internal abstraction rather than broken as you're asserting here. The values you want are there if you walk up the chain. You can go up one level to the source in the API and grab the values you want from the LMS.
Call this to retrieve the string value from the LMS.
SCORM_CallLMSGetValue("cmi.core.lesson_status")
This will return the normalized values passed, failed, completed, incomplete, not attempted. --Unless your LMS returns single letter values. If yours doesn't and you need the single letter value, a substring operation will get you what you need.
The LMS products I've used return the normalized values.
"If I query the LMS from within the course about the student's completion status, and the response continues to be "Incomplete" (even though the debugger shows a status of "Passed")"
I'm not able to replicate this on my end. Do you have a .story file with publish settings that is displaying this behavior?
Another way to grab the internal status regardless of whether it's been passed to the LMS, which I'm not sure is possible as I haven't been able to set off an event within SL that would trigger a change in status without a correlating call to change it on the LMS.
player.SetVar("yourStatusVariable",g_oContentResults.strStatus);
**just noticed this is not displaying exactly what I expected. Still usable and consistent. Another internal variable that's employed through abstraction with a library between use and the API wrapper. Incomplete = Incomplete. Passed = Pass, Completed=complete.
Hi Joseph,
As Mike and Steve helped clarify this thread is particularly long and a lot of information shared. Without knowing the specifics of what Javascript was being referred to, I shared our general information in regards to the writing and editing of Javascript code within triggers or custom set ups to communicate variables to and from Storyline and the LMS. Storyline also does not allow for the accessing of system variables as detailed here.
As for reporting the values of the course status between Storyline and your LMS, if you believe something is not being passed correctly as Mike mentioned it'll likely be something we'd want to get our team to take a look at. We'd also want to confirm that the same behavior exists within SCORM Cloud (an industry standard for testing LMS content) to help isolate the issue to the Storyline file set up or the LMS.
If you're able to replicate there or would like to work with our Support Engineers for further testing, please reach out to them here and upload your project file.
Hi,
I know this thread is old but it's the best I found so far that is close to want I'm trying to do. The problem I have is there is no documentation on storyline communicating with the LMS using SCROM functions. I understand how to do external javascript and call SCORM functions and I can see the functions inside the file included with storyline (LMSAPI.js SCROMFunctions.js) and I understand SCORM.
I can even get the studentName data from the LMS and the read and write comments.
But the whole list of SCORM functions, don't work - it should be easy if you can use javascript and you have the the scorm wrapper.
So what I am wondering is - does storyline block or disrupt the full SCORM functionality? IS there ANY document/resources on this area from Storyline - NOT how do do external javascript?
Specifically I'm struggling to get suspend_data and GetBookmark (cmi.core.lesson_location) to work.
Thanks
Barry
Barry, i'd also be interested in this.
I've started a test course to see what works and what doesn't (initially in scorm cloud but to be used on others too) - i'd be happy to see if anyone else has done the same.
Hi Andy, I managed to get and set status, and get and set cmi.core.lesson_location (set/getBookmark) which is all I need for now - I use lesson_location to store any data I need. Happy to send you a file if you need.
Hi I have to capture the Date with the use of any API or any other method using JavaScript. E.g. lmsAPI.GetStudentID(); is pulling Student Name and we can display it on any SCORM published course. Please assist.
Hi Vishal, you can capture the date via javascript: https://community.articulate.com/discussions/articulate-storyline/javascript-for-date
Is that what you wanted?
I would indeed be interested in the JS for get location (get/cmi.core.lesson_location
Hi Matthew, you should be able to use:
var dataResult=lmsAPI.SetBookmark(data);
where data is the string to be saved into cmi.core.lesson_location
Hi,
what about the Suspend function?
I don't see it in the LMSStandardAPI(strStandard) function defined in lmsAPI.js file (Articulate Studio 360), while it is defined in API.js file...
Is this a bug or could I call the suspend function in another way?
This looks great - but to use their second name I also need salutation - any ideas how I can get that?
This discussion is closed. You can start a new discussion or contact Articulate Support.