Here's a version that does this only by content type.
* Adds "view results" permission.
* Adds new radio to content type to turn this permission on.
* Clarifies the description of the "Display results" option that it, unlike the preceding options, is not available on a per-poll basis.
* Adds a note in the poll settings indicating whether or not "view results" is active.
* Checks the permission if the option is selected.
BTW, the patch also includes a 3 week duration. I belong to several groups whose elections run 3 weeks, not 2 or 4.
Now I have to copy and modify ranking.inc to a new type so I can concurrently run multiple polls with different options.
Comments
Comment #1
anders.fajerson commentedDid you see http://drupal.org/node/168230?
Comment #2
anders.fajerson commentedSidenote: I've just added 3 weeks to the duration. See also http://drupal.org/node/100098
Comment #3
nancydru#1 - yes, I've seen it. Unfortunately, even collapsing a fieldset is not good enough in my case. The results must not be available at all.
#2 - I don't see in there where you said you added 3 weeks, but I'll take your word for it. Thanks.
Comment #4
nancydruThis is really a pretty simple change and, IMO, adds considerably to the capability and flexibility of this module.
Comment #5
anders.fajerson commentedWould it satisfy your needs if http://drupal.org/node/168230 + adding "Never" to the view result settings was implemented? That would be a cleaner approach then this IMO.
Comment #6
nancydruLet me see if I can make this clear.
Some of our members are ineligible to vote, so I use the electoral list.
The eligible members may vote, but NOT see the results. (BTW, that includes me. Ssshhh, we won't tell if you won't.)
There is an Election Committee, whose members are assigned a separate role (EC). They have to view the results so they can report the winners.
I don't think this is all that unusual a request. Certainly I belong to two organizations that operate this way (maybe a 3rd one, but it's having problems right now).
The problem is that I want to be able to run ordinary polls, such as "Is our webmistress doing a good job?" at the same time as the election. If there was just a flat "view results" permission, then those opinion polls would also be blocked and no one wants that.
Comment #7
anders.fajerson commentedCould you explain what you functionality you don't get from my suggstion in #5, compared to you patch?
My suggestion:
"The eligible members may vote, but NOT see the results" - set the view result setting to "Never"
"They (Election Committee) have to view the results so they can report the winners." - give them the permission 'Inspect all votes' (Or optionally we introduce a new permission: 'Always view result' if you convince me that it's a bad thing that they can see individual votes as well. But less permissions -> less settings/options -> me happy)
It's bad practice to mix settings and permission IMO (and I haven't seen it done in Drupal, which is a sign that you should think twice). One example: If a don't give a user the permission 'view result' I expect it to never be able to view results, ever.
Comment #8
nancydruThe elections used to be run on a Yahoo group where there are precious few controls. Therefore there were a number of abuses.
One of the reasons why we now have an EC is because of voting irregularities we have had in the past. Candidates have viewed who voted for whom and used it against them. We've also had members who were afraid to vote because candidates could see who voted for who. And we've had ineligible members vote.
We want to try to avoid all these problems.
I'm not tied to the idea of a permission that may be used if an option is selected. But I am tied to the idea of solving the problems.
I will admit I have not applied that patch to find out if it will do these things. I did read what was written and took a glance at the code; I did not see that it would. If I was wrong, then go for it. If not, then we need to find another solution.
As the election starts in 47 minutes, it is too late for an "official" solution this year; we have to go with what I devised.
Comment #9
ChrisKennedy commentedNeeds a re-roll, but I think this functionality could be a good idea to include given its reasonable use case.
Comment #10
morbus iffI just sent CK a note on this too - I need this functionality. I'd like admins (with a certain permission) to be able to see the final/current results at any time, but all users without this permission should not be able to view the results for a particular poll at any time. It needs to be a per-poll option.
Comment #11
nancydruI would think the original patch code be easily reworked. I am super busy right now, so it may be a while before I can get back to it.
Comment #12
wallan commentedI really need this functionality for a one-off poll I want to conduct on a site I admin. Would it be reasonably safe to use the patch, do you know? Also, is it against the latest stable 5.x release, or against the development version? (I tried to apply it to the development version of advpoll.module, but got errors - bad chunks, hunks, whatever...)
Thanks!
Comment #13
anders.fajerson commentedThe status of this patch is code needs work, so no, it doesn't apply anymore.
Comment #14
g011um commentedI'd like to add a "me too" here. We're in the same boat -- using the Advanced Poll module for online elections mostly, so we need the results to be hidden from the voters, even after the election/poll is closed. The suggestions in comment #7 would work well enough I suppose.
It would be great is this could be a per-poll option though, as I'm sure we'd like to expose the results of other (non-election type) polls to everyone.
Because the majority of our polls are for election purposes, even the users of the role that _can_ see the results don't need to (shouldn't be able to) see the individual votes cast by voters. We just need to see the order and the vote count really.
Comment #15
ChrisKennedy commentedWe need to figure out some workable solution before the 1.0 release. The ultimate purpose of Advanced Poll is to facilitate elections, and this feature is critical for organizations to use the module for electoral purposes.
I think a good case has been made that this should be a per-poll option. People should be able to keep results of some polls restricted and other polls not. If we don't want to do it on a per-poll basis we will need to support arbitrary content types (we need to do this eventually anyway, but it might take more work than is needed for this issue).
The main question is how we can create a clean, usable implementation across content-type settings, poll settings, and user permissions. Right now we have one content type setting for viewing poll results, which can be "always", "after user has voted", or "after voting has closed." Also, http://drupal.org/node/154691 has a reasonable request that this setting be on a per-poll basis.
I think we know that we need a new permission so that "election committee" roles can be authorized to view the results - this is a common use case for elections. Requiring "administer nodes" would expand their permissions too much to be practical.
Now, if we add this permission we need at least one per-poll setting that hides the results from people without the permission. I think the main question is if we can integrate all of these requests into a single permission & per-poll setting combination.
Comment #16
nancydruComment #17
anders.fajerson commentedPer-poll setting it is. Maybe one day we have a better way of dealing with the settings bloat, but today is not that day.
If this "election committee" only needs a "always view result" setting nancy's suggestion of adding a new option to the select field is good. Also my comment about mixing permissions and settings is not that relevant, since we already do that with "write-ins" and "show individual votes".
The other option is to add a checkbox like "restrict viewing to users with the [name of permission] permission".
We must come up with a good name for this new permission to make some sense of this.
Comment #18
anders.fajerson commentedOk, first try:
1. Added "Never" and "For users with the "inspect results" permission" as display results options.
2. Made it a per-poll setting.
3. Renamed old options to after_close and after_vote (if we want to rename them we better do it now to save us form another upgrade path)
Todo:
Convert per-content-type variables to per-node.
Comment #19
ChrisKennedy commentedThis looks very close. But what is the purpose of the "never" option? I think we have the use case handled via "inspect results permission" - no?
This patch also brings up the problem that if you don't have access to view results we should display a message. But that can be handled as a separate patch if preferred.
In _advpoll_can_view_results() I think we can just reference $node->view_results because any existing poll will have that value defined. We just need the default for creating new polls. I might be wrong on this though.
Comment #20
anders.fajerson commentedI'm not the best to talk about user case here ;) Maybe nancyw can chime in. But yes, I think you might be right. What it enables now is some kind of really strict option. No one will be able to see the result, not even user 1. Not sure if it's a real user case but this enables you to have polls that can be seen by users that have the "inspect votes permission" and polls that can't be seen by them, at the same time.
I'd prefer to do the friendly messages in another patch.
That row in _advpoll_can_view_results() was so I didn't have to write an upgrade path (inserting the previous default value in the advpoll table). But now that you bring it up, that looks like the right thing to do.
Comment #21
nancydruI can't say that I totally understand this. In my case, the Election Committee (EC), which is also a role, is allowed to see the votes so that they can confirm that there were no irregularities. We tell them that no one else can see the votes, but in reality user/1 (I wonder who that could be) can see the results as well (and who else really has any understanding of Drupal). I'm not sure anyone is going to want a case where even user/1 has trouble verifying correct operation.
Comment #22
ChrisKennedy commentedYeah let's remove the "never" option.
Comment #23
nscuka commentedOK -- feel like an idiot BUT -- I have followed this thread as I need functionality discussed earlier -- namely letting people vote but not let them see the results. I downloaded the patch above (advpoll_view_results.patch) but when I try to apply it I get that all the hunks failed.
Usually I let CVS managed merges and such so haven't worked with patch much. Read the man page but that did not help...Using patch version 2.5.8 in cygwin and get this output:
$ patch -l < advpoll_view_results.patch
patching file advpoll.install
Hunk #1 FAILED at 16.
Hunk #2 FAILED at 52.
Hunk #3 FAILED at 316.
3 out of 3 hunks FAILED -- saving rejects to file advpoll.install.rej
patching file advpoll.module
Hunk #1 FAILED at 15.
Hunk #2 FAILED at 469.
Hunk #3 FAILED at 596.
Hunk #4 FAILED at 704.
Hunk #5 FAILED at 717.
Hunk #6 FAILED at 1083.
6 out of 6 hunks FAILED -- saving rejects to file advpoll.module.rej
All files using unix file formats and writeable. Patch run in the directory containing the files to patch. I know this is pretty basic -- any pointers appreciated.
- N
Comment #24
jdleonardI would also like the ability to restrict viewing of poll results more precisely. Thanks to everyone for their hard work!
Comment #25
libbyh commentedUPDATE: I didn't mean to post it as "won't fix," but I can't change it now. Those status message are meaningless for new people, and telling us we got it wrong is not helpful. Telling us how to make it right might be. I tried to find definitions for those before I posted. Where are they? (turns out they're here: http://drupal.org/node/156119, but i still can't change it, and I get an error when I try to submit a comment with "none" in those boxes)
Some of my hunks are failing too:
patching file advpoll.install
patching file advpoll.module
Hunk #3 FAILED at 596.
Hunk #4 succeeded at 705 (offset 1 line).
Hunk #5 succeeded at 718 (offset 1 line).
Hunk #6 FAILED at 1084.
2 out of 6 hunks FAILED -- saving rejects to file advpoll.module.rej
And I get this error if I try to edit the poll:
user warning: Unknown column 'view_results' in 'field list' query: UPDATE advpoll SET active = 1, max_choices = 0, algorithm = 'plurality', use_list = 0, view_results = 'after_vote', show_votes = 1, start_date = '0', end_date = '0', writeins = 0, show_writeins = 0, question = '' WHERE nid = 16 in /var/www/includes/database.mysql.inc on line 172
I'm new, so any help would be great. I think this patch will help us out a lot!
Comment #26
nancydruChanging the status to "won't fix" won't help you get it fixed.
Comment #27
nancydruComment #28
Rosamunda commentedI´m just suscribing to this, but I think this feature is a must for any poll system.
Comment #29
torgospizzaI got this to work for my needs but I had to edit the latest patch (From December 13). The patch itself worked fine, except it did not include the new code for including the "inspect results" permission in hook_perm().
We needed to allow Anonymous voters the ability to see the results of the poll after they had voted. None of the other choices seem to work for Anonymous users ("after user has voted", etc.) so this is the only apparent option.
Once the "inspect results" perm was added to the module, I selected the permission for all user types, and now Anonymous voters can see the results after they submit a vote.
Comment #30
pomliane commentedThis version of Advanced Poll is not supported anymore. The issue is closed for this reason.
Please upgrade to a supported version and feel free to reopen the issue on the new version if applicable.
This issue has been automagically closed by a script.