By Kato on
I like this module..polls are handy and fun. But is there a way to make it so that when the poll is displayed in a block, it doesn't show the poll results until that person has voted on that poll? It's frustrating that it will display the poll results to a user that is not logged in or if they do log in, they see the current results even without voting.
Anyone? Is there a way to fix that?
Comments
Anyone
Anyone have an idea or response on how to possibly correct this?
http://nglofsalina.com
Up to the top
I am still searching for a fix on this issue. When a new visitor comes to the site and they are not logged in, the poll block shows the current poll results. It should display the poll questions with the radial buttons for what to choose. Please, can anyone help find a fix for this issue?
--
http://nglofsalina.com
Ugh
Please....this is really starting to bug me. Does anyone have any way to fix this?
--
http://nglofsalina.com
Is there even a fix for it?
I'm looking at the poll.module and it seems that it goes by the IP as to whether or not it should display the results or questions to a user that is not logged in...is that correct? Is there any way to change this?
--
http://nglofsalina.com
ARGH!
Please...someone help. I'm begging. I won't turn my poll on for anon users to vote...how can I fix it so that an anon user does not see the poll results? Or even a registered user before they sign in...
--
http://nglofsalina.com
Not sure this can be done... here's why:
The most recent poll block decides whether to show the poll or to show the results based on whether the database has recorded a vote for the individual viewing the poll. In the case of a visitor that has not yet signed in, the system registers that person as the "anonymous" person (uid=0). When an anonymous person votes, their vote is recorded as belonging to the combination of their uid and their host information. That is, what their computer information is. If you have a test site that you are viewing locally on your own computer, that information is probably 127.0.0.1. If the combination uid/computer information has never voted, then the poll itself is shown to that person before they login. Once that combination of uid=0 and computer (that is, as anonymous) votes, however, the system thinks that the "anonymous" person has voted and then it shows the results the next time that same person shows up.
The solution, of course, is to tell users that if they vote as anonymous, then forever more they will be greeted with the results of the poll. If they don't want that, they need to vote only once they have signed in. This is especially critical if you have a community where a single computer is typically used by multiple users. Drupal doesn't know it is Mary or John who is sitting down at the computer this particular evening before they log in, so if either one of them decides to vote before logging in, that computer will forever be known by your Drupal site as an anonymous user that has, in fact, voted.
One way to get around the whole issue is to not display polls or results to anonymous users. That way, they are never voted on by an anonymous user and the results are therefore not ever shown to somebody who votes accidently as anonymous and then revisits the site. This can be easily accomplished by turning polls off in Adminster=>Access Control for anonymous users.
In a perfect world, the poll module would be redesigned to provide a third view in the case of somebody who it thinks has already voted. That view would be something like: "You have already voted, click
<here>to see the result of the poll to date or click<here>to cancel your existing vote so that you can vote differently."Doesn't sound terribly difficult. Want to give it a try? I don't understand enough about the way Drupal is put together to do this right now, as I've only picked up Drupal in the last couple of weeks. But I might do this in a couple of months (unless somebody tells us that there is a much simpler solution to all of this, which is entirely possible) if I have time at that point.
The only reason I found this post at all was that I was looking for a way to turn off the "older polls" link that renders itself in the block. It appears that there is no option to do so. It appears that the following line in poll.module renders the "older polls" link and that only by commenting it out completely can it be removed. So, by putting the two right slashes at the beginning of the following line, the link disappears:
// $links[] = l(t('older polls'), 'poll', array('title' => t('View the list of polls on this site.')));Making changes to core drupal modules is not recommended, however, so I'm going to poke around and see if there isn't a better way.
If I had my druthers, I'd figure out a way to add a checkmark variable to the Administer=>blocks=>Most Recent Poll block with a question of: "Display 'older polls' link?"
And then I'd modify the poll_view of poll.module to skip the above line if that checkmark variable was true.
But I'm not there yet. Maybe once I get there I will also be able to figure out how to do the modification you are looking for, as well. Actually, see below***.
Hmmmmmm....now that I'm looking at the poll_view function, I see that the following block of code renders the poll or the results:
What you might want to do is change that so that it can never do the second thing if the user is anonymous. If you do this, though, you will want to provide a link somewhere on the page to the /poll page or directly to the poll itself (/node/6, for example) so that the User can get to the results somehow.
Let's see if I can come up with a change that does that.......
Yup, that seems to do it. The only negative is that it displays the poll to anonymous visitors that have already voted, rather than the page that I talked about earlier indicating that the system thinks they have already voted. If they attempt to vote, however, it just doesn't record the vote (although it doesn't give an error message, either). That is for next week.
Now, for the followup. Referenced above as see below***.
I've done a terrible thing. I've hacked the MySQL database by adding a new row to the "variables" table. It has a name of "poll_show_prior" and a value of "0". I then replaced the commented out line shown above with the following in my poll.module:
I would still love to figure out a way to get a checkmark in /admin/settings/content-types/poll linked to that new variable.
We are about to see how long a reply is allowed, I think. ;-)
I use Drupal 6 so it might be
I use Drupal 6 so it might be different. But can't you just change the permissions in admin so that anonymous users can vote in a poll?
Vote based on IP does not work well behind a proxy
We experienced this same issue with one of our customers. For anonymous users, the poll module keeps track of users that already casted their vote using the remote IP address (i.e. the user's external IP). However, when the web server is behind a proxy, the remote address as seen by the poll module for any user is ALWAYS the same, i.e. the proxy IP address.
The solution here is to apply the following patch (for Drupal 6 only):
http://drupal.org/node/219825