Forum Discussion
Results Slide Percent no Decimal Points
All,
I have a results slide which pulls in data from several other results slide.
The problem is that the results percentage is showing the percentage with decimal points. From a cosmetic point of view I would like the percentage rate to be rounded up or down to the nearest full number.
Is there a way to do this?
Thank you in advance
Rich
68 Replies
Love a play by play - so looking forward to seeing it!
- TonyChilversCommunity Member
I found this thread while looking for a solution to the same problem.
What I did:
1. Insert a numerical variable called myScore
2. Insert a trigger on the results slide adjusting myScore to the value of the Results.ScorePercent.3. Insert a new trigger to Execute JavaScript when the timeline starts
4. Click on the … button, and insert the code below into the panel that opens
var player = GetPlayer();
var score = player.GetVar("myScore");
player.SetVar("myScore", Math.round(score));5. Now edit your Results slide text to display %myScore% instead of %Results.ScorePercent% as below.
Job done :)
Tony C
- MikeDelaneyCommunity Member
Hey Tony, pretty elegant solution, thanks!
Mike
- SherrieFrench1Community Member
This is beautiful! Thank you!
- NatashaBomba-Community Member
HI. Can you clarify--When you say edit the results slide--should it only say "%myScore% and not the info in the brackets? Or do you keep the brackets and change the text to "MyScore"? Is it a double %% at the end or a single? I assume points or percent refers to the same thing in step 5?
Also, does the trigger to send results to the LMS need to be after the Java Script trigger in the order?
- PaulyBarnes1Community Member
The double percent is because you actually want it to say %. So to read 80%, where 80 is the variable, it would look like this:
%Variable%%
for step 5 I would assume you leave whats in the brackets alone since those are referring to points rather than percentages. I usually delete the entire bracketed area since we do not utilize points.
Also, to answer your final question, the script to send needs to be AFTER the javascript or it will send the incorrect value.
Hope this helps!
- TonyChilversCommunity Member
No problem Mike :)
I should have added that if you use:
player.SetVar("Results.ScorePercent", Math.round(score));
as well it will pass the same rounded figure to the LMS, for some reason, I coudn't get the Results variable to update...
TC
- MikeDelaneyCommunity Member
Thanks for the update, Tony!
Glad that this thread was able to assist you as well Sherrie. Thanks for popping in :)
- TonyChilversCommunity Member
As Pauly said :)
- NatashaBomba-Community Member
Any thoughts on why this would have worked on one course and not the other? I copied and pasted the slide into the new course but can't get it to work.
- PaulyBarnes1Community Member
If you copy and pasted there is a good chance It might of made another Results.ScorePercent variable which would confuse the trigger.
Hi Natasha,
Take a look at the Variables window to see if you've got a second instance of the Results.ScorePercent there. If you need extra help, feel free to share your .story file here so the community can take a peek at what you've got set up so far!
- RebeccaCarterCommunity Member
Hi guys,
I have tried both of the JavaScript work arounds suggested here and I can't get either to work so I assume I am doing something wrong, would anyone be willing to take a look at it for me?
PS I have added a big ugly button on the opening page to allow you to jump straight to the assessment.
Thank you :)