Some votes sometimes go to 140%, 160% and brake the design with a bar up to width:160%.
Somebody can tell me where/which function implement the calculation?

Phil

Comments

ChrisKennedy’s picture

Status: Active » Postponed (maintainer needs more info)

Can you provide more information on the settings you are using and what combination of votes generates this bug?

pguillard’s picture

I don't have aceess to any configuration, /admin/by-module gives me just a link to user permissions.
I should tell i mostly voted myself several times. The node is a advpoll-binary and its settings :

Basic question Yes/No
Allow users to cast a write-in vote by default=>inactive
Use electoral list by default=>inactive
Show individual votes by default=>active

Phil

briandelicata’s picture

Have exactly the same issue. 3 options with the first one showing 111% of votes cast, second 33% of votes cast, third option showing 0% of votes cast. The foreground bar extends over the block. I am using latest dev release.

ChrisKennedy’s picture

Please include the actual votes cast in these bug reports so I can try to replicate the error.

briandelicata’s picture

The three results for the poll I am running:

Option 1 - 111% (10 votes)
Option 2 - 33% (3 votes)
Option 3 - 0% (0 votes)

pguillard’s picture

I can't re-produce this. MAybe some votes have been cancelled, also some people may have vote again and again..

I can't find the individual votes in my database, but here is what i have found at the moment:

"In 2009, do you plan to buy or rent a flat ?"
Buy 200% (10 votes)
Rent 120% (6 votes)
Total voters: 5

mysql> select * from advpoll where nid=15;
+-----+--------+--------+----------+--------+-------------+-----------+------------+------------+----------+----------+---------------+----------+
| nid | quorum | mode | use_list | active | max_choices | algorithm | show_votes | start_date | end_date | writeins | show_writeins | question |
+-----+--------+--------+----------+--------+-------------+-----------+------------+------------+----------+----------+---------------+----------+
| 15 | 0 | binary | 0 | 0 | 1 | plurality | 1 | 0 | 0 | 0 | 0 | |
+-----+--------+--------+----------+--------+-------------+-----------+------------+------------+----------+----------+---------------+----------+

mysql> select * from advpoll_choices where nid=15;
+-----+-----+---------+--------+---------+
| cid | nid | label | weight | writein |
+-----+-----+---------+--------+---------+
| 6 | 15 | Buy | 0 | 0 |
| 7 | 15 | Rent | 1 | 0 |
+-----+-----+---------+--------+---------+

mysql> select * from votingapi_vote where content_id=15;
+---------+--------------+------------+-------+------------+-----+-----+------------+----------------+
| vote_id | content_type | content_id | value | value_type | tag | uid | timestamp | vote_source |
+---------+--------------+------------+-------+------------+-----+-----+------------+----------------+
| 6 | advpoll | 15 | 1 | option | 6 | 1 | 1231174276 | 88.177.191.216 |
+---------+--------------+------------+-------+------------+-----+-----+------------+----------------+

mysql> select * from votingapi_cache where content_id=15;
+---------------+--------------+------------+-------+------------+----------+-------------+------------+
| vote_cache_id | content_type | content_id | value | value_type | tag | function | timestamp |
+---------------+--------------+------------+-------+------------+----------+-------------+------------+
| 111 | advpoll | 15 | 1 | | _advpoll| total_votes| 1231860345 |
| 112 | advpoll | 15 | 1 | | 6 | option-1 | 1231860345 |
+---------------+--------------+------------+-------+------------+----------+-------------+------------+

mysql> select * from content_type_advpoll_binary where nid=15;
+-----+-----+-------------------+
| vid | nid | field_ferme_value |
+-----+-----+-------------------+
| 15 | 15 | 1 |
+-----+-----+-------------------+

mysql> select * from poll;
Empty set (0.00 sec)

mysql> select * from poll_choices;
Empty set (0.00 sec)

mysql> select * from poll_votes;
Empty set (0.00 sec)

Thanks

Philippe

briandelicata’s picture

Browsing the votingapi_vote table showed 6 votes from the same IP address. Deleting the rows from the table fixed the voting going over 100% so the issue seems to be coming from multiple votes from the same ip.

igorik’s picture

StatusFileSize
new4.09 KB

same problem
hi, I have a same problem,
I attached a screenshot

Igorik

igorik’s picture

in poll settings, there is option to choose 2 from total 3 answers.

leban’s picture

I have the same problem. The way I see it is that the result precentage is calculated from VOTERS count, not VOTES. The same way as in the example above: 10 votes, 5 voters, result 200%. It adds up too.
Can't track the error though.

kitt’s picture

I'm seeing this error, and believe the problem is with the totals in the cache table:

mysql> select * from votingapi_cache;
+---------------+--------------+------------+-------+------------+----------+-------------+------------+
| vote_cache_id | content_type | content_id | value | value_type | tag      | function    | timestamp  |
+---------------+--------------+------------+-------+------------+----------+-------------+------------+
|            45 | advpoll      |        174 |     5 |            | _advpoll | total_votes | 1236010670 | 
|            46 | advpoll      |        174 |     1 |            | 1        | option-1    | 1236010670 | 
|            47 | advpoll      |        174 |     2 |            | 2        | option-1    | 1236010670 | 
|            48 | advpoll      |        174 |     4 |            | 3        | option-1    | 1236010670 | 
+---------------+--------------+------------+-------+------------+----------+-------------+------------+
4 rows in set (0.00 sec)

The total votes is clearly not the sum of the options' total votes (5 vs 7). These votes were made by setting the anonymous vote reset to 'immediately' in the votingapi settings page, then voting on the same system with 3 different browsers, refreshing the page and revoting.

The duplicate anonymous votes increase the individual choice vote counts, but don't change the overall total vote count.

Updated:
Here's the problem (in my configuration, which allows anonymous votes AND multiple voting):

modes/binary.inc around line 170, there's this query:

  $result = db_query('SELECT uid, vote_source FROM {votingapi_vote} WHERE content_type = "advpoll" AND content_id = %d AND value_type = "option" GROUP BY uid, vote_source', $node->nid);

The 'GROUP BY uid, vote_source' combines multiple values into one vote. So, anonymous users voting multiple times (which is allowed in my setup), merges all the votes into one vote.

In this case, the total_votes value never updates. If the total_votes value doesn't update, while the individual counts increase, the percentages (votes / total_votes) go over 100%.

igorik’s picture

hi

maybe you are right but I have this problem but anonymous can't vote on my site

Igorik

vako’s picture

Everyone is right here. There is a serious issue with Advanced Poll and am surprised that not many people are noticing it.
I have the following issues:
- number of votes is not adding up to the individual counts
- percentage count is adding up to more than 100%
- bars are going overboard, hence making the poll look really weird and funny
- Reset vote option doesn't do anything...am not sure what it is supposed to do.
- Vote button doesn't refresh the screen, we have to refresh to see the results (I tried it on multiple computers)

Please please someone get us a fix.

thanks!

VladRM’s picture

StatusFileSize
new53.78 KB

Hi,

I managed to reproduce the wrong (>100%) percentage issue.
1. Create a binary poll
2. Set the Voting API 'Anonymous vote rollover: ' to 'Never' (go to admin/settings/votingapi)
3. Cast votes using the same IP without being logged on (use different browsers)

As I understand it, if the Step 2 setting is 'Never' i should not be able to cast a second vote (with the same IP address) so this may be the actual problem.

Check out the attached image for a visual on the bug.

vako’s picture

Thanks for the info. I did your settings and created a new binary poll, but it's the same issue:
1. over 100%
2. when clicked on the Vote button it doesn't refresh but increments the count...

What about the VotingAPI's 3rd option: Do not tally results automatically: I am using a module that manages its own vote results?

ChrisKennedy’s picture

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new949 bytes
ChrisKennedy’s picture

Ugh, drupal.org just deleted the text of my comment for some reason. Here it is again:

Try out this patch and let me know if it works ("patch -p0 < advpoll_over_100pct.patch" in your advpoll directory). Or just edit line 170 in modes/binary.inc to be "GROUP BY uid, vote_source, timestamp".

vako’s picture

Thanks Chris. I did the change, however I got the following error:

Fatal error: Cannot redeclare advpoll_info_binary() (previously declared in /home/keghart/public_html/sites/all/modules/advpoll/modes/binaryOLD.inc:11) in /home/keghart/public_html/sites/all/modules/advpoll/modes/binary.inc on line 15

should I run update.php perhaps?

vako’s picture

It's working now as follows:
- Make sure you don't leave the old binary.inc file in the same folder!
- run update.php after this change.

Thanks a lot Chris! it is working beautiful now, even the old polls are adjusted.
Will this patch be committed in the main source?

ChrisKennedy’s picture

Status: Needs review » Fixed

Yep, I just needed someone to confirm that the patch worked. Committed: http://drupal.org/cvs?commit=186616

vako’s picture

One more issue I found today:
Option1: 64% (9 votes)
Option2: 21% (3 votes)
Option3: 14% (2 votes)
Option4: 0% (0 Votes)
Total Voters: 14
Total%: 99% doesn't add up to 100%

After submitting one more vote for the same poll, I got:
Option1: 56% (9 votes)
Option2: 19% (3 votes)
Option3: 13% (2 votes)
Option4: 13% (2 votes)
Total Voters: 16 (incremented by 2)
Total%: 101% <-- should be 100%

The above happens if we have more than 3 options to choose from and gets scewed more as the options increase.
Note that I also have the following problem (which might be related): When people press the Vote button, nothing happens, they can click it several times. To see the results, they have to refresh the whole page, the form doesn't refresh automatically.
I tried this on several computers in different locations. Could it be a theme issue or perhaps an AJAX issue?

thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

vako’s picture

StatusFileSize
new14.46 KB

This issue still exists, if the choices are more than 2 then the numbers don't add up! I am using the latest code.
check this image, adds up to 105% and number of votes should be 215 not 204.

vako’s picture

it's weird that we still have this issue on this wonderful module. how come nobody else is complaining about it and why don't we have a solution??
Does anyone know of any other poll module that acts nicer than the standard poll? I would prefer one with Ajax functionality and color bars.

ChrisKennedy’s picture

Status: Closed (fixed) » Active

Hmm this does seem to be an error. Can you come up with a repeatable way to get the error so I can fix it more quickly? e.g. Add X choices, vote A,B,C, then you'll see that the result doesn't add up to 100% - something along those lines would be very helpful.

vako’s picture

I will do more experimentation and let you know. But for now I have noticed that anything with more than 3 choices is consistently giving this issue - both vote-count and percentage-count are not adding-up.

will keep you updated.

vako’s picture

StatusFileSize
new25.61 KB

OK, here's the problem:
1. As long as the poll has 3 or less choices, it works great.
2. If you have 4 choices then the sum of the votes AND the percentages will be skewed.

This is consistent with every site that I have tried it with and am sure you can reproduce it easily.
Here's another image from another website:

vako’s picture

OK, I gave up on this module. It has nicer features, but only if they works!!
I'm going back to the regular one.

vako’s picture

I suppose the Advanced Poll module is an abandoned project. I hope someone will take ownership and continue development on it.

spiesser’s picture

I had the same problem this weekend. 114 % with 4 options. I have the clue that this is a result of entries in the table {votingapi_vote} with the same timestamp.

I updated this entries with varying stamps and everything worked fine. In sum: 100%

vako’s picture

Exactly! Thanks for finding the culprit, I found all the duplicate timestamps in the database. But can you please post the sql statement that you wrote to find the duplicates and change them using phpAdmin? or any other tips would be appreciated. Thanks!

I hope the developer Chris Kennedy is still around and can help in fixing this issue now that spiesser pin-pointed the reason for the wrong stats being that the module registers the same date stamp to multiple records.

vako’s picture

Can anyone help please? How many people are using this module anyways? can't they see the issue with it?

vako’s picture

OK, here's another approach: Does anyone know if the settings in the Voting API module will affect Advanced Poll?

aasarava’s picture

Can everyone who is experiencing the problem please share what version of Voting API and what version of Drupal they are using? Also, can you please double check and confirm that you are using 6.x-dev of Advanced Poll?

vako’s picture

Drupal 6.13
Voting API 6.x-2.3
Advanced poll 6.x-1.x-dev (the converter is not enabled)

thanks!

aasarava’s picture

StatusFileSize
new893 bytes

Ok, after researching further, it seems kitt was right in comment #11. The SQL query used to count votes was wrong because it grouped multiple votes by one user into a single result. (By the way, it's important to point out that this bug only effects binary votes that allow users to select more than 1 vote choice.)

Try the attached patch for binary.inc.

You will need to register a new vote in each poll that has a problem in order to forced advpoll to update the vote total in voting_api_cache. (Does anyone know if there's a way to clear this table and recalculate all votes automatically? Just clearing Drupal's caches didn't do it for me.)

The patch works for me but I haven't fully tested with other vote types yet.

vako’s picture

Thanks a lot for the solution, I will test it on several of my polls and let you know.
Two issues:
1. My votes let users select only a single vote
2. How can I apply the patch? :(

thanks!

aasarava’s picture

Vako -- Strange that you're seeing the error when only allowing one vote. I couldn't reproduce the error on binary polls w/ one vote allowed.

In any case, here's a link that explain show to apply patches:
http://drupal.org/node/60108

In short:
1. make a backup copy of your modules/advpoll/modes/binary.inc file.
2. make a backup of your database.
3. place the patch file in the modules/advpoll/modes/ folder.
4. run this command (in the modules/advpolls/modes/ folder): patch < patch-binary-inc-361593.patch

I'm not sure if that'll overwrite your existing binary.inc file or create a binary.inc.new file. If it's the latter, then rename the binary.inc.new file to binary.inc.

Good luck!

vako’s picture

Worked great!
I downloaded a free ssh client called Putty from www.putty.org and applied the patch. Re-entered my vote on every poll and the numbers match now.
Although some of them still have small discrepancies, but I can live with that. Hopefully the new polls will be flawless.

thanks again for your great help!

aasarava’s picture

Vako: Excellent. Are the small discrepancies just minor issues due to rounding, or bigger than that? The rounding errors are going to be there unless the module is modified to display percentages with decimal points. For instance, you might see a poll with three options broken down like this: 34%, 34%, 33%. The first two, with 33.5% each were automatically rounded up.

vako’s picture

I get two issues:
1. Rounding issue, exactly as you described
2. If we had a poll that had 5 questions and after getting several votes, two questions were removed that already had votes.
I am not sure if the second case is totally valid, it might also be related to the rounding issue.

Question: what happens if we remove questions that already have votes applied to it?

For me the case is closed, perfect module thanks to all the developers!
When will this last patch be committed?

roball’s picture

Title: Votes goes over 100% » Binary votes allowing more than 1 answer may exceed 100%
Status: Active » Reviewed & tested by the community

Can the patch from #36 please be committed?

vako’s picture

My goodness, it hasn't been committed yet? I hope Chris, the maintainer, will commit it soon also we can have an official 6.x release (currently it's in dev only).

Vector-’s picture

StatusFileSize
new880 bytes

So I suppose this is related, since this patch changes the effected code, but does not resolve the error in the quoting of the db_query string

Maybe this will help, here's a reroll of the patch from #36, with a fix included for #641476: advpoll_calculate_results_binary() escapes values with " instead of ', which fails on Postgres:

miro_dietiker’s picture

Status: Reviewed & tested by the community » Postponed (maintainer needs more info)

Vector-
I'm not sure your correction will solve all cases.
If anonymous users could vote, we can't simply count users. There could be many votes by different anonymous users.

Are you sure the code will also solve this issue?

Vector-’s picture

I am not, I rerolled the existing patch from this thread to contain a postgres fix, and to be more testable...

I did not mark this as RTBC, nor am I sure it is of that quality.

I am using the patch, which is why I posted the reroll, but the site I'm running AdvPoll on doesn't allow Anonymous votes, so indeed I have not tested that use case *at all*

igorik’s picture

maybe it is still better to have it fixed for authenticated and no change or anonymous users, as to have it wrong for both authenticated and anonymous :)

maybe not really true, but I use this for authenticated only, so I will welcome when this will be fixed.

thank you both.

Igor

miro_dietiker’s picture

Status: Postponed (maintainer needs more info) » Active

I suspect anonymous polls are still quite popular.
As this fix will lead to wrong display (even worse than now) for all anonymous cases it is (at least for me) no candidate to commit.

Please take the time to provide a patch that considers all regular cases.
The votes and results code should be reconsidered in this module as they all contain some weird code.

Thanks

liquidcms’s picture

just updating as this 2 yr old post still seems to be active. i have latest dev rel and my poll counts still exceed 100%.

liquidcms’s picture

yes, patch in #36 worked for me once i added a new vote (causing votingapi cache table to be re-calced).

actually #16 would work as well; but #36 is more efficient

vako’s picture

Isn't that patch committed to the official release though??

liquidcms’s picture

not in the most recent dev version.. so i think that means it can't be in any release.

roball’s picture

Priority: Normal » Major

Can somebody please suggest a way to "update the vote total in voting_api_cache" (as mentioned in #36) without the need for actually voting at least once? This is no option for already closed votes.

Thanks.

gobinathm’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

D6 is EOL hence this issue won't be fixed (or) attended. So closing it.