Forum Discussion
Calculating percentages on the results using variables
- WaltHamiltonSuper Hero
Andrew,
What is throwing you off is that SL can't evaluate an expression. It can perform only one math function per trigger, so your solution is correct that you have to write a trigger for each step.
You can accomplish these same actions all on one slide, using steps 3, 4, and 6. Triggers are executed one at a time, in the order they appear, from top to bottom, so you can set several triggers to one action. You can set these to fire when a button is clicked, when a slide or layer starts, when a variable changes values, or on any other action the learner can take.
Your instinct in step 3 is correct, you don't want to change NumberCorrect.
Copy NumberCorrect to PercentCorrect, then divide PercentCorrect by TotalPoints, then multiply PercentCorrect by 100.
The percent correct will appear so fast you won't see the changes.
Hello Phezulu,
Thanks for reaching out!
You can perform mathematical calculations in Storyline 360 using the 'Adjust variable' trigger. Here's a screenshot of what that looks like in Storyline 360 when division is chosen as the operation:
It looks like you already have your variables setup, so you can start setting up the mathematical operations using triggers.
- AndrewCrosby-b8Community Member
I'm running into the same issue. Specifically, there doesn't seem to be a function that will let you divide two variables and then display the result as a new one.
Right now I'm trying (and failing) to display a simple formula: (CorrectResponses / NumberAttempted) x 100.
- AndrewCrosby-b8Community Member
I found a solution (albeit a somewhat clunky one).
1) Create a slide that displays results (not a Results Slide).
2) I display the value for NumberCorrect. Duplicate the slide (we'll call this Results1 and the duplicate Results2).
3) Set up a trigger so that variable PercentCorrect is set to the value of NumberCorrect when the Results1 slide starts. Don't display PercentCorrect yet.
4) Make a button called CALCULATE SCORE. Create a trigger that divides PercentCorrect by total points possible.
5) Make a trigger that moves to Results2 when user clicks CALCULATE SCORE.
6) Create a trigger that multiplies PercentCorrect by 100 when the timeline starts on this slide.
7) Now you can display the PercentCorrect variable along with the NumberCorrect. Since you duplicated the page it will appear instantaneous (as long as there aren't any transitions).