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
I published a project and dug through the generated files created by Storyline and found an LMSAPI.js file which I think lists all functions available. You'll have to test them out individually to see what you get, as I haven't tried any of them out, and it doesn't state how many parameters they take, etc. Our beloved GetStudentName is here though.
This is advanced coder territory, reverse-engineer with caution.
lmsAPI.Initialize
lmsAPI.Finish
lmsAPI.CommitData
lmsAPI.GetStudentID
lmsAPI.GetStudentName
lmsAPI.GetBookmark
lmsAPI.SetBookmark
lmsAPI.GetDataChunk
lmsAPI.SetDataChunk
lmsAPI.GetLaunchData
lmsAPI.GetComments
lmsAPI.WriteComment
lmsAPI.GetLMSComments
lmsAPI.GetAudioPlayPreference
lmsAPI.GetAudioVolumePreference
lmsAPI.SetAudioPreference
lmsAPI.SetLanguagePreference
lmsAPI.GetLanguagePreference
lmsAPI.SetSpeedPreference
lmsAPI.GetSpeedPreference
lmsAPI.SetTextPreference
lmsAPI.GetTextPreference
lmsAPI.GetPreviouslyAccumulatedTime
lmsAPI.SaveTime
lmsAPI.GetMaxTimeAllowed
lmsAPI.DisplayMessageOnTimeout
lmsAPI.ExitOnTimeout
lmsAPI.GetPassingScore
lmsAPI.SetScore
lmsAPI.GetScore
lmsAPI.GetScaledScore
lmsAPI.RecordTrueFalseInteraction
lmsAPI.RecordMultipleChoiceInteraction
lmsAPI.RecordFillInInteraction
lmsAPI.RecordMatchingInteraction
lmsAPI.RecordPerformanceInteraction
lmsAPI.RecordSequencingInteraction
lmsAPI.RecordLikertInteraction
lmsAPI.RecordNumericInteraction
lmsAPI.GetEntryMode
lmsAPI.GetLessonMode
lmsAPI.GetTakingForCredit
lmsAPI.SetObjectiveScore
lmsAPI.SetObjectiveStatus
lmsAPI.GetObjectiveScore
lmsAPI.GetObjectiveStatus
lmsAPI.SetObjectiveDescription
lmsAPI.GetObjectiveDescription
lmsAPI.SetFailed
lmsAPI.SetPassed
lmsAPI.SetCompleted
lmsAPI.ResetStatus
lmsAPI.GetStatus
lmsAPI.GetLastError
lmsAPI.GetLastErrorDesc
lmsAPI.GetInteractionType
lmsAPI.GetInteractionTimestamp
lmsAPI.GetInteractionCorrectResponses
lmsAPI.GetInteractionWeighting
lmsAPI.GetInteractionLearnerResponses
lmsAPI.GetInteractionResult
lmsAPI.GetInteractionLatency
lmsAPI.GetInteractionDescription
lmsAPI.CreateDataBucket
lmsAPI.GetDataFromBucket
lmsAPI.PutDataInBucket
lmsAPI.DetectSSPSupport
lmsAPI.GetBucketInfo
lmsAPI.GetProgressMeasure
lmsAPI.SetProgressMeasure
lmsAPI.SetPointBasedScore
Wow... this can save my life...
How can display the value in a textfield? I mean, the name of the student?
Is possible to store a javascript variable in a storyline variable?
Trying thinks like that and does not work.
player.SetVar("nombre", newName);
player.texto = nombre;
texto = nombre;
player.texto = newName;
texto = newName;
where texto is the name of a text entry field
Thanks!
Ah... one thing---
Is there some API instruction to get and set data to the suspend_data in LMS?
What i'm trying to do is store some kind of array like "true,false,true,false", on item for slide to recover that when the course begin and change with these value the item of a menu to visited or completed... i don't know how to do that in another easy way...
I can write comments with lmsAPI.WriteComment but i can recover the info in it with lmsAPI.GetComments... something wrong i'm doing?
var myName = lmsAPI.GetComments();
var array = myName.split(',');
var newName = array[1] + ' ' + array[0];
player.SetVar("newName", newName);
alert("nombre 1 "+ newName);
player.SetVar("nombre", newName);
I have seen that in the lmsapi.js are references to the api.js... it will be possible to write our own functions, to create new lms instructions...
I've tried with a simple alert but the course hangs, problably by my zero knowledge of js
Storyline variables are saved automatically in suspend_data. Rather than risk breaking into Storyline's calls of suspend_data, just create a new variable in Storyline, e.g., MySuspendData and store your good stuff there.
Who can i create a variable and store in the LMS?
The problem is that:
The client wants to have an array in the suspend data with the status of each module in the course
If we have 3 slides the suspend data must have:
true,true,true or false,false,false or ,,,
I try to use comments (i can write on ir but not read) but they tell me that must be the suspend_data variable and the course saves a string of numbers and letters wich i don't know if this is the information about the slides completes or not... if this is it i don't know how to recover the info to show on screen wich slide is done or not in the moment we start the course
in this post, i put a superexplanation of the thing we do with flash and the js of our functions included the one who writes the suspend_data... What i need is to emulate that in articulate.
There is plenty elsewhere on this website about how to create variables in Storyline.
Storyline manages the suspend_data. You won't be able to control it much, but you can add to it via a Storyline Variable that you set to true,true,true.
But how?, evrybody tells me is posible but no one tells me how... i need an exmaple or code, plis :(
Here's a link to Storyline tutorials. Read about variables, states, and triggers.
http://community.articulate.com/tutorials/products/articulate-storyline.aspx
Ok, may be i can`t explain... I know about this stuff, i've used and created some cimplex menu sytem using variables and states, no problem with that. But, when the course exit, all the variables are reset, and the states too. What i need is to keep this states so i need to write in some part how the variables are to can recover at the course starts again.
I don't know if there are some specific system variables to keep this data and that be recorded automatic to the LMS. I've reached to write in the LMS field comments but the command lmsAPI.GetComments(); is not working to recover that data
I post the file i'm using to do that
If you use an LMS or flash cookie and enable resume variables are not reset and will resume
Oh... where is that options "resume variables" , flash cookies... the thing i'm working on is for flash and html5
Hi Brett
I am looking to do this very same thing.
Did you manage to get a .js code that pulls the "dept" from the lms?
Thanks
Chris,
"dept", or any organizational information about the student, isn't defined in the SCORM standard (that I know of), but it may be possible to get it by supplying an initial launch string in SCORM "suspend_data", then parsing that string to identify "dept" and storing that value in a Storyline variable for future reference.
Whew.
Not done yet. There could be a race condition, (probably is), that if Storyline requests the suspend_data before you do, it will reset the string as it doesn't understand it. There are two ways to solve this problem. First: Be the first to request it, get the value, then reset the string yourself. This would require getting your JS to run first, and there's always a way to get this done. Second, figure out the Storyline syntax for suspend_data and mimic that with the initial value of suspend_data. Storyline might store the value in a local variable for you automatically with this approach.
Makes me wonder if it's worth the trouble. It might be easier to create a proprietary call to the LMS to get unique values.
Sam
Thanks for swift reply Sam, it is much appreciated.
Do you have any ideas where I could start to create the proprietary call you mentioned above. That is totally new to me, but am keen to learn
Chris
Anything proprietary to the LMS would need to be developed in concert with the LMS vendor. If you have access to the LMS software and server, you could write it yourself.
Both are fairly big hurtles.
Sam
Hi guys!
I know this post is a bit old but it has helped me a lot!
I was wondering, though, if this method of getting the learner's name should work in every LMS?
Thanks!
Julio.
Hi Julio,
This *should* work in any SCORM conformant LMS.
That's awesome Steve, thanks for your answer!
Thanks for sharing now I don't need to depend on Articulate built in features for LMS.
Is there a way to pull information about other courses the LMS user has taken? Can I check that they have completed/passed another course from at the beginning of my course?
Has anyone managed to define some of these?
This post was removed by a moderator
A lot of the same questions here, but no helpful answers. :-(
Hi Erik,
This thread is a bit older, so I'm not certain that any users are still subscribed here. You could message them directly using the "contact me" button on their profile to reach out - but you could also start a new thread with the specifics that you're looking for so that the community could weigh in since the Javascript elements are not something that staff can assist with.
This discussion is closed. You can start a new discussion or contact Articulate Support.