Support Forum

Multiple votes in polls

DH Dietmar Herian
Dietmar Herian
Member

Recently brought up a poll with the ability of multiple votes per voter and recognized that the results chart shows a total of ‘number of votes per voter times 100%’ – so let’s say they have three votes you get a total of 300% in the chart!

For my purposes, I had to normalize it to 100%. I could not find a suitable filter or hook, so I changed it in the plugin directly.

$percent = round(((($answer->answer_votes / $poll->poll_voters)/$poll->poll_votes) * 100));

I added the bold green marked items in sp-polls-components.php. I used $poll->poll_votes instead of $poll_maxanwers to get the real picture even if voters skip some of their votes.

I believe it should be changed to normalized 100% display.

4 Answers

New Answer

MP Mr Papa
Mr Papa
Member

I can see both sides of this coin…  so will open a ticket on it for consideration – or at minimum, a hook…

DH Dietmar Herian
Dietmar Herian
Member

Sorry,

I provided wrong code. I must be

$percent = round(($answer->answer_votes /$poll->poll_votes) * 100));

And to be precise -> this is not the full truth, because my testing yielded that $poll->poll_votes is not the real sum of all $answer->answer_votes but a simple multiplication of $poll->poll_voters * $poll->poll_maxanswers meaning that skipped votes are not reducing the total. This way, you get a percentage per answer of the max possible votes, not of the really submitted votes.

I think, rightfully it should be the latter one, but could not find a variable including this information.

Thanks for considering to change.

MP Mr Papa
Mr Papa
Member

okay, thanks… ticket open for at least a filter…

MP Mr Papa
Mr Papa
Member

next version will have a filter that you can custom the percentage calculation for yourself…  still think in most cases, the current calculation is right – want to know % of voters that voted for a choice vice that answer % versus all votes (whether including not selected entries or not)…  but as I said earlier, can see some specific types of polls where that might be what you want…  filter will let you do that…