Help Interpreting Java script on a Quiz Results Slide

Aug 12, 2019

Hi All, 

I just inherited a suite of 5 compliance courses to update for a client and as I was going through them I found a java script trigger on the quiz results page.  I don't know java script so I'm not sure what this trigger does or why it is important.  Can someone give me a clue?  I'm a little rusty on my quizzing and I don't want to accidentally mess something up.  Below is the code.  Thank you!

 

Execute javascript when the timeline of this results page starts:

var player = GetPlayer();
var score = player.GetVar("AssessmentResults_1");
player.SetVar("AssessmentResults_1", Math.round(score));

2 Replies
Steve Gannon

Hi Jodi,

If a quiz result does not come out to be a whole number (e.g., 79.63 % instead of 80%), Storyline displays the decimal portion of the score. It appears that the original Storyline developer used JavaScript to round the score so it would display as a whole number (no decimals).

There is probably a trigger on the Quiz Results slide that sets a custom variable they created (named AssessmentResults_1) to Storyline's default Result.ScorePercent variable. Then the JavaScript trigger you found is fired to pull in the AssessmentResults_1 variable from Storyline, round it, and send it back to Storyline to be displayed.  

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