Back to vBulletin 3.0 Add-Ons

Proper poll percentages
Mod Version: 1.00, by Martin CX

This modification is in the archives.
vB Version: 3.0.3 Rating: (0 vote - 0 average) Installs: 1
Released: 19 Oct 2004 Last Update: Never Downloads: 0
Not Supported  

This mini mod is made because vB didn't calculate the percentages in a poll by looking at the total number of voters, but by looking at the total number of votes. In multiple choice polls this number is not the same and it seems intuitive to me that the interesting percentage number is the percentage of people who have chosen that particular option.

In poll.php, substitute:
Code:
		if ($option['votes'] == 0)
		{
			$option['percent'] = 0;
		}
		else
		{
			$option['percent'] = vb_number_format(($option['votes'] / $pollinfo['numbervotes']) * 100, 2);
		}
with:
Code:
		if ($option['votes'] == 0)
		{
			$option['percent'] = 0;
		}
		else
		{
			if ($pollinfo['multiple'])
			{
				$option['percent'] = vb_number_format(($option['votes'] / $pollinfo['voters']) * 100, 0);
			}
			else
			{
				$option['percent'] = vb_number_format(($option['votes'] / $pollinfo['numbervotes']) * 100, 0);
			}
		}
And in showthread.php, substitute:
Code:
			if ($value == 0)
			{
				$option['percent'] = 0;
			}
			else
			{
				$option['percent'] = vb_number_format($value / $pollinfo['numbervotes'] * 100, 2);
			}
with:
Code:
			if ($value == 0)
			{
				$option['percent'] = 0;
			}
			else
			{
				if ($pollinfo['multiple'] && $pollinfo['voters'] != 0)
				{
					$option['percent'] = vb_number_format($value / $pollinfo['voters'] * 100, 0);
				}
				else
				{
					$option['percent'] = vb_number_format($value / $pollinfo['numbervotes'] * 100, 0);
				}
			}
That should do it.

Best wishes,

Download

No files for download.


vblts.ru supports vBulletin®, 2022-2024