lmsAPI.SetScore is not working

Hello,

 

I have a course where I want to get a custom score. For example, I want every user to get a score of 87%, so the LMS has the information "87%". 

 

First, I tried this code: ("scoreCustom" is my variable in Storyline, with a value of 87)

var player=GetPlayer();
var totalScore=player.GetVar("scoreCustom");
onBWEvent("BW_UpdateStatus","complete|~|"+totalScore+"|~|0|~|100|~|80|~|quiz");

 

But this doesn't work on HTML5 devices, only in Flash. So I tried another code, for HTML5: 

 

var player=GetPlayer();
var totalScore=player.GetVar("scoreCustom");
var lmsAPI = parent;
lmsAPI.SetScore(totalScore, 100, 0);

 

But this doesn't work either. 

Any suggestions? 

2 Replies
Daniel Koch

Found a solution in another post: 

 

https://community.articulate.com/discussions/articulate-storyline/lmsapi-functionality-in-html5-output?page=2#reply-451483

 

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