Javascript variables and the LMS
Apr 21, 2013
Wonder if someone can help.
I want to utilize the objectives that are part of the Scorm 1.2 run time and they are supported in my LMS.
Normally in html I would use the Run Time Environment calls to get or set the values of the score or the status. Like those below.
LMSInitialize("");
//Set objective 10 to 100
LMSSetValue("cmi.objectives.10.score.raw", "100");
//Set objective 10 to pass
LMSSetValue("cmi.objectives.10.status", "pass");
LMSFinish("")
LMSInitialize("")
//Get the score of objective 10
var objScore = LMSGetValue("cmi.objectives.10.score.raw")
//Get objective 10 status
var objStatus = LMSGetValue("cmi.objectives.10.status")
Both of these work and return the correct values when initialized through my testing environment.
But when I use these calls inside Storyline they fail.
I can see there are objective functions in the SCORMFunctions.js file
SCORM_SetObjectiveScore (strObjectiveID, intScore, intMaxScore, intMinScore)
SCORM_SetObjectiveStatus(strObjectiveID, Lesson_Status)
and the same for the "Get" calls
There also appears to be calls in the lmsAPI.js that reference the objective function.
What I can't make out is the actual syntax for the calls through Storyline. Can some one please shed some light on this one.
I want to get a value from a numeric input field for score and get a value from another numeric input field for the objective ID and then Set the objective score in the in the LMS. I have used the SCORM_Initialize() to make sure the conversation is initialized, and the SCORM_CommitData() is just making sure the LMS retains the data. I believe Storyline does both of these automatically
SCORM_Initialize();
var player = GetPlayer();
var intScore = player.GetVar("SetScore");
var strObjectiveID = player.GetVar("SetID");
SCORM_SetObjectiveScore(strObjectiveID, intScore);
SCORM_CommitData();
In need of help!
8 Replies
Hi Graeme -
You might give this a try. I'm not sure you need to initialize or commit to get this to work. I'd try calling the method with lmsAPI.method().
For example, to fill a variable with the student name:
var player=GetPlayer();
var studentName=lmsAPI.GetStudentName();
player.SetVar("sName",studentName);
So in your case, this should work:
var player = GetPlayer();
var intScore = player.GetVar("SetScore");
var strObjectiveID = player.GetVar("SetID");
lmsAPI.SCORM_SetObjectiveScore(strObjectiveID, intScore);
I'm not sure how the call will behave missing the last two parameters.
I'm not sure, but lmsAPI may access functions in the file API.js. So it may be better to call in there:
lmsAPI.SetObjectiveScore(strObjectiveID, intScore, intMaxScore, intMinScore)
Hi guys
Thanks for the insights I'll let you know how I get on.
Would be nice if there was a document detailing the the Storyline version of the scorm calls.
I shall try the suggestions and let you know.
Storyline is still the best thing since sliced bread
Hi Graeme,
Did you manage to resolve this as I am also working on something similar. If you have resolved this will you please share your solution with us.
Have a gr8 weekend.
Cheers
Ganesh
Can you provide me your code?
Please provide the code, it's very helpful to my future?
Thanks in advance
Hi Shaurya,
This discussion is a bit older, so I may suggest using the "contact me" button on a ELH users' profile to reach out to them directly, or starting a new discussion to ask for help on how to set up Javascript!
Best of luck with your project!
Thanks for reply, I created a new discussion
This discussion is closed. You can start a new discussion or contact Articulate Support.