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)
- ShayRiggsCommunity Member
Just a quick note to say thank and report success using this technique!! I wanted a rounded percentage, so divided by 10000000 then multiplied by the same number did the job.
Craig Bellingham said:
I'm pretty new to Storyline - only one course produced so far but loving it - and I have been asked by my client if I can get the final score to always be a whole number. I used the trick above to create the variable 'RoundedScore' and it works great, but I don't know how I then get that variable to be the score passed back to the LMS when my 'submit score' button is clicked.
Is this possible?
Not sure of how to go about this, but I would suggest storing the actual score, and then customising the score display web page to do the number rounding job – doing this means you are not storing bogus data in your LMS database. - 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!)
- RadosawKwasek-9Community Member
I've created simple file with rounding up and down to integer - maybe it helps.
- NatashaBomba-Community Member
Thanks Radoslaw. Are you able to just put a screenshot up or a link to other non-JS solutions? I can't open the .story file as my software is on my other computer behind a heavy firewall.
- RadosawKwasek-9Community Member
- CraigBellinghamCommunity Member
I'm pretty new to Storyline - only one course produced so far but loving it - and I have been asked by my client if I can get the final score to always be a whole number. I used the trick above to create the variable 'RoundedScore' and it works great, but I don't know how I then get that variable to be the score passed back to the LMS when my 'submit score' button is clicked.
Is this possible?
- TerryMcDonaldCommunity Member
Craig,
I haven't done much with the LMS side of Storyline, so I am not sure about passing the rounded score back to the LMS. Hopefully someone can shed some light on this for you.
- BrettRockwoodCommunity Member
Owen, thanks very much. I was just playing around with this and literally stumbled upon the 10,000,000 number making it work. It really is quite a clever workaround and works beautifully. Thanks again to everyone.
- NavinLodhiCommunity Member
Thanks everyone! this is really cool and nice work around.
- KeariEggers-3f0Community Member
This tip works really well on the PC but unfortunately doesn't seem to work on iPads (the decimal is still there).
- ChrisRoetzerCommunity Member
I'll try this not for quizzing but simply wanting to display whole % such as % of ee's in one location or another - quizzing must already be displaying %s not in decimal form, since, when working with variables simply on a silde or layer, you must divide by 100,000 & multiply by 10,000,000 to get the correct result.
Don't suppose there's a solution to formatting with commas? for ex: I want the number value (can't be text) of 31000 to display 31,000.
- RobVerzeraCommunity Member
Unfortunately this does not work when the html5 version of the course is run.