Forum Discussion
A Solution to rounding in Storyline – without using Javascript
Since this does not work in Storyline 360, I found a very easy way to implement a floor flunction in Storyline 360 without using Javascript.
EDIT: Corrected for edge cases and much simplified! Also attached an updated screenshot.
Corrected Steps:
- Create one variable, floorScore, and initialize to 0
Results Slide triggers:
- Set floorScore equal to 100 when the timeline starts
- Subtract 1 from floorScore when floorScore changes if floorScore is greater than Results.ScorePercent
And that is it!
--------------------------------------------
Old (incorrect) version below.
Edit 4/17/2019: I have removed the incorrect version to avoid confusion.
Hi Mitch,
Thank you for providing this! When we implemented it we realized if we got a perfect score it was rounding down to 99%. I added a trigger between your step 1 and 2 triggers that says Set floorScore equal to Results.ScorePercent if Results.ScorePercent =100, and also added a condition on your step 3 trigger to say if floorScore does not equal 100. This solved the problem for us.
- AkhileshRao7 years agoCommunity Member
Hey Mitch and Lauren!
Thanks for sharing the inputs :)
Can you please explain the logic behind the triggers?
- MichaelBrown27 years agoCommunity Member
Hi everyone
This discussion is great, some really useful info!
I'm still slightly stumped with this, I've created a SL using the triggers etc detailed above and it's got rid of the decimal places which is great, however it doesn't seem the maths is right. If I score 4 out of 5 the results slide is telling me I score 79% rather than 80% and I can't work out whats not quite right.
I've attached the file, if anyone can help i'd be very grateful!
Thanks
Mike
- MitchHayashi7 years agoCommunity Member
Hi Michael,
I noticed the same thing after playing around with my original triggers. I now use a much simpler method, though it just gives me a true floor function instead of rounding. I'm sure it can be adjusted to give true rounding, but a floor function works for what I need. Here is the updated version:
Initialize variable floorScore to 0
Slide Triggers on results slide:
Set floorScore = 100 when timeline starts
Subtract 1 from floorScore when floorScore changes if floorScore is > Results.ScorePercent
Then display floorScore on your results slide as the user's score. Attached is your project file with adjusted triggers.
- MichaelBrown27 years agoCommunity Member
Thanks so much Mitch!