Javascript variables and the LMS

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
Steve Flowers

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.