Simple equations

Jul 16, 2019

Lately I've been challenged with a course that requires some simple math equations. I've been able to figure out adding multiple inputs but now I need to take some totals from several screens, multiply them, total them, and lastly, divide the grand total (see attached graphic). I haven't seen any examples posted within the last couple years that address what I would hope are simple math equations and can be answered fairly quickly.

2 Replies
David Schwartz

Hi Ken,

Best bet is a little JavaScript. I tried an example that uses numeric entry fields so you can experiment with the values. It recalculates each time one of the fields changes, although for your use, you would not be doing that.

I used the variables as you had them named, and created a variable GrandTotal, and a variable Score.

Let me know if this makes sense. Basically, the JavaScript "player.GetVar" gets a value from a variable from Storyline, and after the calculations, "player.SetVar" sends a value back to a variable in Storyline.

Demo: https://360.articulate.com/review/content/da529093-e519-4d38-8d61-d3ea4984b5c4/review

Here's the script:

var player = GetPlayer();

var js_Tally5 = player.GetVar("Tally5")

var js_Tally6 = player.GetVar("Tally6")

var js_Tally7 = player.GetVar("Tally7")

var js_Weighted_Tally5 = js_Tally5 * 1

var js_Weighted_Tally6 = js_Tally6 * 2

var js_Weighted_Tally7 = js_Tally7 * 3

var js_Grand = js_Weighted_Tally5 + js_Weighted_Tally6 + js_Weighted_Tally7

var js_Score = js_Grand / 1.8

player.SetVar("WeightedTally5", js_Weighted_Tally5);

player.SetVar("WeightedTally6", js_Weighted_Tally6);

player.SetVar("WeightedTally7", js_Weighted_Tally7);

player.SetVar("GrandTotal", js_Grand);

player.SetVar("Score", js_Score);

 

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