Portal Poll Block not rounding

Current Version: 1.0.6
Released: 09.01.10
Forum rules
Before creating a new support thread, please take a look in the board3 Portal FAQ and use the search!
Many questions have already been answered.
Locked
User avatar

Topic author
Jupiter
Active Member
Posts: 21
Joined: 11. June 2008 18:27

Portal Poll Block not rounding

Post by Jupiter »

Your Portal Version: 1.0.4
Your phpBB Type: Standard phpBB3
MODs installed: No
Your knowledge: Beginner
Boardlink: http://www.gopherpucklive.com/forum/portal.php

What have you done before the problem was there?
This must be a bug because it has always been wrong.

What have you already tryed to solve the problem?
Nothing

Description and Message
Why doesn't the poll block on the portal page round up or down? It rounds when you go in to the specific poll thread, but it does not on the portal page.

If you go to my portal page you will see a poll about halfway down. As of this posting the poll had 53 votes. 43 for one option and 13 for the other. The percentages are 75% and 24%. Well that does not add up to 100%. When you view the thread in it's native area, it reads 75% & 25%.

The actual percentages on the portal page are not getting rounded up and down like they should be. So the 75% is actually 75.47% and should be rounded down to 75% and the 24% which is actually 24.52% should be rounded up to 25%. It appears the portal poll block is ignoring the decimal places and just displaying the whole number. Hence my poll is adding up to 99% instead of 100%.

It does sometimes get the percentages correct, but that is only when there are no decimal places. I have seen this bug going back quite a few versions and I am surprised that no one has ever noticed it.
User avatar

Topic author
Jupiter
Active Member
Posts: 21
Joined: 11. June 2008 18:27

Re: Portal Poll Block not rounding

Post by Jupiter »

I found the error/bug....

For version 1.0.4
In the portal/block/poll.php file.

Find on line 347:

Code: Select all

$option_pct_txt = sprintf("%.1d%%", ($option_pct * 100));
Replace with:

Code: Select all

$option_pct_txt = sprintf("%.1d%%", round($option_pct * 100));
This should now round the output percentage correctly on the poll block on the portal page. I found the correct code directly from the veiwtopic.php file. Hopefully someone fixes this to the next version of the portal.
Locked

Return to “board3 Portal 1.0.x - English Support”