vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.0 Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=33)
-   -   Proper poll percentages (https://vborg.vbsupport.ru/showthread.php?t=70734)

Martin CX 10-17-2004 10:00 PM

Proper poll percentages
 
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,

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

Quote:

Originally Posted by nexialys
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

Quote:

Originally Posted by FleaBag
From what?

I think he meant "coughs" ....


All times are GMT. The time now is 12:32 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.00964 seconds
  • Memory Usage 1,733KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (4)bbcode_code_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete