Proper poll percentages
This modification is in the archives.
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); } 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); } } Code:
if ($value == 0) { $option['percent'] = 0; } else { $option['percent'] = vb_number_format($value / $pollinfo['numbervotes'] * 100, 2); } 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); } } Best wishes, Download No files for download. |