PDA

View Full Version : Proper poll percentages


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,

Andreas
10-18-2004, 10:00 PM
*cough*
https://vborg.vbsupport.ru/showthread.php?t=67910
*cough*

Martin CX
10-18-2004, 10:07 PM
Oh dear, didn't see that.

nexialys
10-18-2004, 10:31 PM
damn, KirbyDE will have to go to the doctor... about one time a week, someone release a hack he already coded... he will die from caughts...

Polo
10-18-2004, 10:51 PM
KirbyDE will have to go to the doctor... about one time a week, someone release a hack he already coded... he will die from caughts...

lol :)

FleaBag
10-19-2004, 06:24 PM
From what?

Blam Forumz
10-22-2004, 08:16 PM
caughts

Polo
03-29-2005, 10:31 PM
From what?
I think he meant "coughs" ....