Sending status to LMS using JS - Need help

May 01, 2020

I’m using 3 QB’s that go to one result slide.
The pass score is set to 33%

My result slide variables are
Results1.scorepoints (shown on results slide)
Results1.passpoints (not shown on result slide)
Results1.scorepercent (not shown on result slide)
Results1.passpercent (not shown on result slide)

The client wants to show on the result slide scorepoints / 10 not score percent.

Do I need to have a custom variable to hold the score for the script even though we don't want to report score just completion and status.

I’ve changed it a couple of times and regardless of whether I pass or fail the course I’m getting Status ‘passed’. I need the completion and status only NO score needs to be recorded in the LMS.

This is what I have:

var player = GetPlayer();
var passingScore = "33";
function findLMSAPI(win) {
if (win.hasOwnProperty("GetStudentID")) return win;
else if (win.parent == win) return null;
else return findLMSAPI(win.parent);
}
var lmsAPI = findLMSAPI(this);
lmsAPI.SetScore(player.GetVar("result1.scorepercent"), 33, 0);
if (player.GetVar("result1.scorepercent")>= passingScore)
{
SetStatus("passed");
} else {
SetStatus("failed");
}

This is what displays in Scormcloud - the success is Passed regardless

Any help is much appreciated and of course it's urgent.

13 Replies
Ned Whiteley

Hi Wendy,

When you score 100% in your quiz, the actual variable output is 33.33333. Whether this fraction is causing issues when compared to your pass score of 33, I can't be certain. However, you could try one of the following options:

Option 1: (This will change your score to a maximum of 100%)

var player = GetPlayer();
var playerscore = player.GetVar("Results1.ScorePercent") *3
var passingScore = "100";
function findLMSAPI(win) {
if (win.hasOwnProperty("GetStudentID")) return win;
else if (win.parent == win) return null;
else return findLMSAPI(win.parent);
}
var lmsAPI = findLMSAPI(this);
lmsAPI.SetScore(playerscore), 100, 0);
if (playerscore = passingScore)
{
SetStatus("passed");
} else {
SetStatus("failed");
}

Option 2: (Change your variable to the ResultsPoints variable)

var player = GetPlayer();
var passingScore = "10";
function findLMSAPI(win) {
if (win.hasOwnProperty("GetStudentID")) return win;
else if (win.parent == win) return null;
else return findLMSAPI(win.parent);
}
var lmsAPI = findLMSAPI(this);
lmsAPI.SetScore(player.GetVar("Results1.ScorePoints"), 10, 0);
if (player.GetVar("Results1.ScorePoints")= passingScore)
{
SetStatus("passed");
} else {
SetStatus("failed");
}

Phil Mayor

you cannot send results variables to javascript you need to assign the values to a different variable and send that.

I am not sure why you cannot use the results slide to pass score if it is set to 33% then it will work.

Be aware if you pass the score to the LMS via javascript you have to ensure that Storyline cannot meet its own completion criteria or it will overwrite your status and score in the LMS. I normally do this by tracking by 100% slide viewed but ensure I have one slide that cannot be visited.

Russell Killips

Hello Ned,

Phil is correct. You cannot access the Built-In variables directly with javascript.

So create your own number variable. Then using a trigger, set your variable equal to the Built-In Variable.

Then you can execute the javascript after that trigger and reference your variable instead.

In your javascript, you are setting the passingScore to a string. The if statement won't work because you are then comparing a number to a string.

Remove the quotation marks so it becomes: var passingScore = 10;

 

var player = GetPlayer();
var passingScore = 10;
function findLMSAPI(win) {
if (win.hasOwnProperty("GetStudentID")) return win;
else if (win.parent == win) return null;
else return findLMSAPI(win.parent);
}
var lmsAPI = findLMSAPI(this);
lmsAPI.SCORM_SetScore(player.GetVar("YourCreatedVariable"), 10, 0);
if (player.GetVar("YourCreatedVariable")= passingScore)
{
lmsAPI.SCORM_SetPassed();
} else {
lmsAPI.SCORM_SetFailed();
}

Wendy Farmer

Hi Russell, it was actually my question and Ned was trying to help me.  By creating a number variable and sending that will it display the score in the LMS? The client doesn't want that.

They only want to see reported - Completed & Passed or Failed but no score.

Is there other JS I should use to achieve this?

Russell Killips

I think the LMS would always show a score. If no score was sent, it would show a score of 0.

You can override the score that is sent to the LMS from Storyline using Javascript. You can only set it to a number value and it cannot be left blank.

lmsAPI.SCORM_SetScore(player.GetVar("YourCreatedVariableScore"), 100, 0);

Wendy Farmer

Hi Phil

I had the JS to try and send Passed / Failed and I was using a Complete course trigger to send the Completion status.

Completion works but success status is always Passed regardless if I pass or fail.  So I thought the issue was in the JS. 

Is there another way to send Passed/Failed status?

Phil Mayor

There are different criteria for what can be sent, I do believe if you send passed you will need a score. Wheras Complete/incomplete is for without a score.

If you are using the completed trigger as well I don’t believe the javascript will work as Articulate will override the status, to use the javascript you ideally ensure that Storyline cannot complete and send nothing.

This discussion is closed. You can start a new discussion or contact Articulate Support.