Martin CX
10-17-2004, 10:00 PM
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: if ($option['votes'] == 0)
{
$option['percent'] = 0;
}
else
{
$option['percent'] = vb_number_format(($option['votes'] / $pollinfo['numbervotes']) * 100, 2);
}with: 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: if ($value == 0)
{
$option['percent'] = 0;
}
else
{
$option['percent'] = vb_number_format($value / $pollinfo['numbervotes'] * 100, 2);
}with: 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,
In poll.php, substitute: if ($option['votes'] == 0)
{
$option['percent'] = 0;
}
else
{
$option['percent'] = vb_number_format(($option['votes'] / $pollinfo['numbervotes']) * 100, 2);
}with: 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: if ($value == 0)
{
$option['percent'] = 0;
}
else
{
$option['percent'] = vb_number_format($value / $pollinfo['numbervotes'] * 100, 2);
}with: 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,