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
Sam Coulson

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

Juanjo Haro

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!

Juanjo Haro

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);

Juanjo Haro

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.

Sam Carter

Juanjo Haro said:

Who can i create a variable and store in the LMS?

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.

Juanjo Haro

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

Sam Carter

chris freebairn said:

Hi Brett

Did you manage to get a .js code that pulls the "dept" from the lms?


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

Sam Carter

chris freebairn said:

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


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

Ashley Terwilliger-Pollard

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.