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.

Comments

burningdog’s picture

StatusFileSize
new1.7 KB

Here's the patch.

burningdog’s picture

Status: Needs review » Active
StatusFileSize
new1.7 KB

I'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.

burningdog’s picture

Status: Active » Needs review
bcobin’s picture

Status: Active » Needs review

Successfully 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.

miro_dietiker’s picture

Status: Needs review » Fixed
StatusFileSize
new1.72 KB

Committed 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.

miro_dietiker’s picture

StatusFileSize
new1.06 KB

tiny typo - negation in a condition

if (!user_access('show vote results')) {

fixed in repo with resulting rev 1.21.2.88.2.32.

Status: Fixed » Closed (fixed)

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