Use case: a site wants to collect info from users without users being able to see what everyone else voted for. A user can vote, but can't see how many people voted for the different options.
How the current advpoll works: view your advanced poll and vote. You'll see the results of what other people voted for - there's no way to hide those results.
The solution is to create a new permission called 'hide vote results' which hides vote results from the user with that permission to see votes, like so: http://drupal.org/files/advpoll_results.png
The permission is 'hide vote results' instead of 'view vote results' because we want this module to work out-of-the-box with sensible defaults. The default is that most people want their users to be able to view vote results, and only in special cases do we want to hide it.
If a user has the permission 'hide vote results' then this is what they'd see after voting: http://drupal.org/files/advpoll_hide-vote-results_vote.png
Of course, if they don't have the 'cancel own vote' permission then that button wouldn't show up.
Patch attached.
The only addition I can think to add to this is to allow a user to see their own vote, even if they can't see everyone else's.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | advpoll_623426_6_negate.patch | 1.06 KB | miro_dietiker |
| #5 | advpoll_623426_5_results.patch | 1.72 KB | miro_dietiker |
| #2 | patch_623426.patch | 1.7 KB | burningdog |
| #1 | patch_623426.patch | 1.7 KB | burningdog |
| advpoll_hide-vote-results_vote.png | 11.33 KB | burningdog |
Comments
Comment #1
burningdog commentedHere's the patch.
Comment #2
burningdog commentedI've re-thought this - it doesn't make sense to have the permission be 'hide vote results' because if that is granted to registered users, then no-one can view the results. Much better to grant a 'show vote results' permission to a role. I've changed my patch to reflect that.
Comment #3
burningdog commentedComment #4
bcobin commentedSuccessfully patched the module (apparently) and the behavior is basically unchanged - after anonymous voting (allowed in this installation), the results are immediately displayed, despite anonymous users not having permission to view votes - and the options do not appear at all on subsequent page loads.
Thanks for trying to tackle this, Roger - I think the functionality you're trying to implement is super-important for polling to avoid what I call the "empty restaurant" scenario on lower-traffic sites. The way voting is implemented now, I'd say the first hundred or so voters have to feel a bit silly.
I will stay tuned... willing to help out with testing.
Comment #5
miro_dietikerCommitted attached slightly corrected patch to repo leading to rev 1.21.2.88.2.31.
Finally same as the checkbox "Show individual votes" we might should also add a checkbox "show results" to every poll.
Well compared to webform this might also be limited to certain roles on a per-node basis.
Still switching to fixed since it is in now. Please provide more inputs and reopen based on your opinion.
Comment #6
miro_dietikertiny typo - negation in a condition
fixed in repo with resulting rev 1.21.2.88.2.32.