Branching Quiz - Sending custom variable score to LMS - Can it be done?

I am building a sample quiz for a client which has four branches.  I've built it with one Result slide and am using a variable 'UserScore' to calculate only the result that affects their branch.

If I can get it to work properly I want my UserScore to be sent to the LMS not the ResultScore.Percent. Can this be done with JS?

I'm a JS noob so if you can give a detailed answer I'd be really grateful.

24 Replies
Wendy Farmer

Hi Matt

the removalist is running 7 hours late so I've had time to have a go at sending my custom variable score to LMS - SUCCESS thanks to the posts you linked me to...only thing that is not showing is the Passed / Failed.

Can you look at this code (which I duplicated from your post) and added a bit for the Complete status and see what I have done wrong.

var player = GetPlayer();
var passingScore = "80";
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("UserScore"), 100, 0);
if (player.GetVar("UserScore")>= passingScore)
{
SetStatus("passed");
} else {
SetStatus("failed");
}

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.SetReachedEnd();

Steve Flowers

Hi, Wendy - 

In your publish settings under Reporting and Tracking, what's your LMS Reporting set to. It may not make a difference in your LMS but it likely will in SCORM Cloud. The other thing you may find is, if your SL file is set to Completed/Incomplete and Storyline reaches the condition that would trigger completion such as a slide count, Storyline will overwrite your status. I tend to create a slide that cannot be reached. The new feature in SL360 gets around this by enabling a trigger to set completion. 

We tend to use Completed / Incomplete or Passed / Incomplete. Failed has a special place in my heart but I wouldn't use it in an eLearning status:)

Wendy Farmer
Steve Flowers

I tend to create a slide that cannot be reached.

Hi Steve, thanks for the reply. I have it set to Passed/Incomplete and for this example I'm using SL2.

I'm not sure what you mean by a slide that cannot be reached (I understand the what not the why) - how will that affect pushing the information to the LMS?

Matthew Bibby

If you have your course set to be complete when all slides are viewed, that will override any custom completion messages you are sending via JS.

So add a new scene with a new slide. Make sure that there is no way for the learner to ever access that slide. Then set your slides viewed to the maximum number. That means that the learner will never satisfy the slides viewed requirement (as they can't access the orphaned slide) so completion will be left to your JS.

Russell Killips

Good morning Wendy,

I have this working in the SCORM cloud. Here is the code and a sample project for you to take a look at.

var player = GetPlayer();
var passingScore = player.GetVar("passingScore");
var UserScore = player.GetVar("UserScore");

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(UserScore, 100, 0);
if (UserScore >= passingScore){
lmsAPI.SetPassed();
}else{
lmsAPI.SetFailed();
}

lmsAPI.SetReachedEnd();

Wendy Farmer

Hey Russell

Thank you for replying :-)

I applied your JS to my file and something is not working (probably me) as it's early here in Australia.

Yes I get the Passed status but my passing score is 80 and I only scored 60.  I don't see where in your JS you set the pass score to 80.

Wendy Farmer

Hi Steve

I didn't create a custom passing score I was using Results.PassScore is that my issue

oops hang on I changed using the result slide yesterday when Matt suggested trying by number of slides...I do it again. Please hold 

Nope that didn't work

I'm obviously making a rookie mistake.

In the JS I first used: the second line was setting PassingScore but in Russell's JS above I don't see that line

var player = GetPlayer();
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(player.GetVar("Your_Score_Variable"), 100, 0);
if (player.GetVar("Your_Score_Variable")>= passingScore)
{
SetStatus("passed");
} else {
SetStatus("failed");
}