Why wont this Javascript pass 100% Score into LMS?

Nov 06, 2017

Hi,

I'm using the following Javascript to report the score back to the LMS - all works perfect up to 99% - but as soon as the course confirms 100% - the 100% result does not display in the LMS (it just changes the status to complete) - can anyone see why?

/*Get player to reference*/
var player = GetPlayer();
/*get LMS API*/
/*set score; the first number is the score*/
lmsAPI.SetScore(player.GetVar("RoleModelComplete"), 100, 100, 100);
/*set status; possible values:"completed","incomplete", "failed","passed"*/
if (player.GetVar("RoleModelComplete")=>99){
SetStatus("completed");
}
if (player.GetVar("RoleModelComplete")<99){
SetStatus("incomplete");
}

4 Replies
OWEN HOLT

Steve is correct.
Here is a handy list of comparison operators in JavaScript followed by their description. 

== is equal to some value
=== is equal to both the value and the data type (number, string, etc.)
!= is not equal to some value
!== is not equal to the value or it is not equal to the type (number, string, etc.)
> is greater than some value
< is less than some value
>= is greater than or equal to some value
<= is less than or equal to some value

I'm curious to know why you are using a target of greater than or equal to 99%. At 99%, you might as well just set it to a full 100% (which I think might be your intent).  If so, any of the following should work for you:

if (player.GetVar("RoleModelComplete")>99){
SetStatus("completed");
}

if (player.GetVar("RoleModelComplete")==100){
SetStatus("completed");
}

if (player.GetVar("RoleModelComplete")===100){
SetStatus("completed");
}

If you really want it to be greater than or equal to 99, try either of these:

if (player.GetVar("RoleModelComplete")>=99){
SetStatus("completed");
}

if (player.GetVar("RoleModelComplete")>98){
SetStatus("completed");
}

Linda Ladley

Thank you - I've  updated the code to reflect that - but it still doesn't pass the % score into the LMS when it hits 100%...

/*Get player to reference*/
var player = GetPlayer();
/*get LMS API*/
var lmsAPI = parent;
/*set score; the first number is the score*/
lmsAPI.SetScore(player.GetVar("RoleModelComplete"), 100, 99);
/*set status; possible values:"completed","incomplete", "failed","passed"*/
if (player.GetVar("RoleModelComplete")>99){
SetStatus("completed");
}
if (player.GetVar("RoleModelComplete")<99){
SetStatus("incomplete");
}

Above is the code I'm using... and getting the following results:

1) If I complete the course to 100% - it changes the status to Complete and Success to Passed - but doesn't show the 100% score (shown in file complete at 100%)

2) If I complete the course but get less than 100% it shows correctly (as shown in file Score - less than 100%)

2)If I go back into the course and carry on where I left off and get to 100% - it changes the status to Complete and Success to Passed but doesn't change the % score to 100% (it will change the score if it's less than 99 but it never tips it over to 100%) - shown in file passed at 100%

Can you see why?

Thanks

Lind

 

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