Forum Discussion
A Solution to rounding in Storyline – without using Javascript
Normal
0
false
false
false
oNotPromoteQF />
EN-US
X-NONE
X-NONE
I found a way to round numbers in Storyline without using Javascript. The challenge was to show whole percentage numbers from calculated decimal numbers (i.e. 33% for 1/3 and 67% for 2/3). Searching through the forums, all I could find was Javascript solutions and suggestions to submit a feature request. Not happy with either of these answers, I continued to play around.
I found that Storyline only holds 7 digits past the decimal place, and the 7th digit is rounded. So to get a rounded decimal (percentage) as a whole number, divide by 100,000, and then multiply by 10,000,000.
For example:
2 / 3 = 0.6666667 (rounded at the 7th position by Storyline)
0.6666667 / 100,000 = .000006666667 (which is rounded to 0.0000067)
0.0000067 * 10,000,000 = 67
Now we have our rounded 67% from 2/3
You should be able to apply this to any number you want to round. Divide and then multiply by a multiple of 10 that is large enough to push the number you want to round to the 7th position past the decimal (i.e. 13,567 / 10,000,000,000 * 10,000,000,000 = 14,000)
Hello everyone,
I have some great news to share! We just released another update for Storyline 360. In Update 112, we’ve included essential fixes and new features. One of the new features we’ve included is:
- Simplify reporting with a built-in option that rounds quiz scores to whole numbers.
Launch the Articulate 360 desktop app on your computer to take advantage of this update, and click the Update button next to Storyline 360. You’ll find our step-by-step instructions here.
Please let me know if you need additional help.
100 Replies
- MikeClapper-5daCommunity Member
A colleague shared this very helpful tip that finally solved the issue for me! I created a Storyline number variable called RoundedScore, which I set equal to the Results.ScorePercent as the results slide timeline begins. Then I execute this Javascript:
var player = GetPlayer();
var score = player.GetVar("RoundedScore");
player.SetVar("RoundedScore", Math.round(score));Finally, I changed the "%Results'ScorePercent%%" text on the results slide to "%RoundedScore%%", and it works in Storyline 3! I hope this helps others who want to round the percentage in Storyline 3.
- SimonCCommunity Member
Hey Mike, I tried your method in Storyline 3 and it didn't seem to work for me. Do you execute that Javascript when the timeline starts are is the trigger set up to go off at some other point?
- LuchoCatelliCommunity Member
Hi!
Old but usefull thread. I´m trying to use it in Storyline 360 and it seems that it´s not working anymore. The number rounds up in storyline 2 but the same source file opened in 360 doesn´t work (it always shows two decimal numbers). Is there another workarround? Thanks!
- JayBoCommunity Member
Miriam Calvo
Hi!
Old but usefull thread. I´m trying to use it in Storyline 360 and it seems that it´s not working anymore. The number rounds up in storyline 2 but the same source file opened in 360 doesn´t work (it always shows two decimal numbers). Is there another workarround? Thanks!
I'm in the same boat as Miriam - In need of this, but it doesn't work in SL3 either - Anyone have any miracles?
- OwenHoltSuper Hero
As long as you are not using the mobile player, JavaScript is your friend for rounding.
StoryLine 3/360 now support an infinitely long decimal making the old math round solution obsolete.
- RadosawKwasek-9Community Member
This method only works in Storyline 2. Storyline 3 holds much more digits. I divided number by 1e+308 (max) and then multipled by 1e+308 and the result was the same as source number.
- MitchHayashiCommunity Member
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.
- LaurenFCommunity Member
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.
- AkhileshRaoCommunity Member
Hey Mitch and Lauren!
Thanks for sharing the inputs :)
Can you please explain the logic behind the triggers?
- PhilippeJEANTYCommunity Member
I have tried the trick of Terry and Tom but the math are incorrect. I am not using this with a test score but with a slider, and I would like the slider to display just non decimal values but allow the slider to move in 10th of decimals.
Why is this the "rounded" value incorrect ?
- PierreJouanCommunity Member
Hi Philippe,
Does not work with SL3 anymore (see Radosław Kwasek answer above).
Use Mitch's clever solution (impressive, just figured out how it works!)
- DerekSanfordCommunity Member
Is this still working in 360?
Some previous SL2 conversions to 360 aren't showing as rounded and starting from scratch comes up without rounding as well.
- MitchHayashiCommunity Member
I does not work in 360. See my solution above for a floor function that works in 360.
- CynthiaKlassenCommunity Member
I can't get this to work. I used the file that Tom uploaded four years ago (thanks Tom)! Wonder why this is still not automatic.
Anyway, maybe it's not working because I have two quizzes in my course so I have two results slides + I also have a final results slide.
I'm not as technically inclined as most of you so I just literally copy everything that Tom did in his file. I am unable to troubleshoot with my low skill levels.
Can anyone help me figure out why it isn't working? Does it have to do with the fact that I have 3 results slides? Should one of the triggers be altered? Do I need 3 variables...1 for each results slide? Everything I've tried has failed.
Thanks!
- AnnaGorshkovaCommunity Member
Hello Mitch and Lauren,
Mitch, thank you for the great workaround! Lauren, thank you for explaining how to keep the score at 100 vs. 99.
I am still trying to grasp how this workaround actually works... Now I'm getting 1% if I get all of the answers wrong.
Did anyone else run into this? What additional trigger am I missing to prevent this from happening?
Thank you again!
-Anna
- MitchHayashiCommunity Member
Hi Anna,
If you are getting 1% when you expect 0% my guess is that you are using "greater or equal to" instead of "greater than" when comparing your floorScore variable vs Storyline's Results.ScorePercent variable. If you post a project file with the triggers you are using I will take a look at it.