I use a selection voting where anonymous users can give a maximum of 3 votes.
I found that on the Votes page all anonymous votes were shown under 1 IP-address.
I changed the $query line in function decisions_votes_tab()
from: 'GROUP BY v.uid'
to: 'GROUP BY v.vote_source'
and now I see different IP-addresses all with a maximum of 3 votes.

As I'm a newbee to drupal: Is this a bug fix or am I missing something and messing up other scenario's?

CommentFileSizeAuthor
#7 755068.patch1.51 KBfloater

Comments

ezra-g’s picture

Status: Active » Postponed (maintainer needs more info)

Can you clarify what voting mode you're using, post the unexpected output/data you're seeing and explain what you would expect to see?

floater’s picture

Using Decisions - selection I create a test poll with 4 choices and max 2 allowed. I vote several times for choice 1 and 2 and one time for choise 1 and 3, from 2 different IP's.
On the Votes page I see only:
IP2 with votes: Choise 1, Choise 2 and Choise 3 (this IP voted only 1 and 2)

Using the following modification in 'decisions.module':
original line 720:
$query = 'SELECT u.name, v.uid, v.vote_source, GROUP_CONCAT(DISTINCT CONCAT(v.value,"=>",v.tag) ORDER BY v.value) as votes FROM {votingapi_vote} v LEFT JOIN {users} u ON v.uid = u.uid WHERE v.content_id = %d GROUP BY v.uid'. tablesort_sql($header) .'';

modified line 720:
$query = 'SELECT u.name, v.uid, v.vote_source, GROUP_CONCAT(DISTINCT CONCAT(v.value,"=>",v.tag) ORDER BY v.value) as votes FROM {votingapi_vote} v LEFT JOIN {users} u ON v.uid = u.uid WHERE v.content_id = %d GROUP BY v.vote_source'. tablesort_sql($header) .'';
(Changed the group by)

Now I get:
IP1 choise 3, choise 2, choise 1
IP2 choise 2, choise 1

floater’s picture

Status: Postponed (maintainer needs more info) » Active

(I guess I had to change the status?)

ezra-g’s picture

It would be really helpful if you could post a screenshot and a patch to help with reviewing this issue.

GigantPlus’s picture

It's really a good solution... with a small addition. We must also replace (DISTINCT v.uid) --> (DISTINCT v.vote_source) in the second line:

$query_count = 'SELECT COUNT(DISTINCT v.uid) FROM {votingapi_vote} v LEFT JOIN {users} u ON v.uid = u.uid WHERE v.content_id = %d GROUP BY content_id' . tablesort_sql($header);

Complete solution:

$query = 'SELECT u.name, v.uid, v.vote_source, GROUP_CONCAT(DISTINCT CONCAT(v.value,"=>",v.tag) ORDER BY v.value) as votes FROM {votingapi_vote} v LEFT JOIN {users} u ON v.uid = u.uid WHERE v.content_id = %d GROUP BY v.vote_source' . tablesort_sql($header) . '';

$query_count = 'SELECT COUNT(DISTINCT v.vote_source) FROM {votingapi_vote} v LEFT JOIN {users} u ON v.uid = u.uid WHERE v.content_id = %d GROUP BY content_id' . tablesort_sql($header);

It is working properly!

ezra-g’s picture

Status: Active » Needs work

Thanks for this suggestion. Marking as NW pending a patch.

floater’s picture

Status: Needs work » Needs review
StatusFileSize
new1.51 KB

Attached our combined patch