heinrich_k wrote: ↑
Tue Sep 10, 2019 10:10 am
Summary tells us, 6 votes were given.
So the number of answers given has no meaningful application.
Perhaps not meaningful to you but a lot of information can be derived from it.
First of all "6 votes were given" is strictly incorrect, a "vote" is the complete submit, and there were only 3 submits, by a maximum of 3 voters.
It would be better to refer to a poll_option, whereas the "vote" is the set of poll_options selected.
Let's see which information could be "missing".
= 6 x selected
= 10 x selected
= 40 x selected
Since a user can only vote for a
once (and similar for b
) we know 6 users votes for a
, 10 for b
and 40 for c
We also know a minimum of 40 user have cast their vote (and a maximum of 56), and that maximum 6 users voted for a
(not necessarily a meaningless vote as such), and a maximum of 6 users voted a
, whereas a maximum of 10 voters chose b
As mentioned before, the total number of voters is in the range 40-56 (let's say 50 for sake of argument), so if we knew the exact number of voters then we can ascertain that 6 out of 50 selected at least option a
, 10 out of 50 selected at least option b
and 40 out of 50 selected at least option c
>> that gives the percentages
%1% votes by %2% users
It's not clear here whether you want absolute numbers or percentages. If it's absolute numbers then both are the same (since each option selected = 1 user). I suspect that what you want is a percentage showing the number of times an option (a
) was selected compared to the total number of options selected but that still doesn't give the number who voted a
(which you didn't request anyway).
So the only thing I see "missing" is the total number of users who have voted.
In the table "phpbb"_poll_votes... the following fields are present: topic_id
, poll_option_id, vote_user_id
so for a topic_id, count of (group by) vote_user_id gives the total number of voters, something which can probably be done on the fly.
As for calculating (and showing) how many users voted a
, those queries are a bit heavier and (to me) not worth the extra load. In fact, this is more something for the posts in the poll-topic, where users can then explain (or defend) their choice if they want to.
Oops forgot to mention that I'm in favour of including the number of voters, but am refraining from voting at this time until it's clear what exactly is wanted.