Closed (won't fix)
Project:
Drupal core
Version:
8.0.x-dev
Component:
poll.module
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Anonymous (not verified)
Created:
23 Mar 2004 at 14:13 UTC
Updated:
29 Jul 2014 at 17:25 UTC
Jump to comment: Most recent file
Comments
Comment #1
jhriggs commentedUgh...wasn't logged in when I submitted this issue. Let me know if you have any problems with the patch.
Comment #2
dries commentedInstead of adding a second block, we should try to make the existing poll block configurable. Setting this to 'active'.
Comment #3
jhriggs commentedWhat if someone wants both blocks, though, or perhaps want the most recent on some pages and a random one on others?
Comment #4
jhriggs commentedAttaching an updated patch. Any takers on this? Am I the only one with interest in displaying a random poll rather than just the last one?
Comment #5
dries commentedI don't intend to commit this unless there is more demand for it.
Comment #6
alliax commentedI would like this too.
In my case I'd prefer have the poll block configured to randomly display active polls.
But I also like the idea of showing a specific poll in the block for specific nodes.
Comment #7
mikeryanCount me in... I've coded this already as a custom block, if there's interest I could produce a patch to add it to the core module... One question, is ORDER BY RAND() supported by pgsql?
An additional wrinkle I implemented - if there are any sticky active polls, one of them will be randomly selected, otherwise it will just be any random active poll.
To try it, create a new PHP block with the following content:
Comment #8
antarus commentedI've got a patch against cvs that adds this as well,although I did the randomizing in php as opposed to sql since I figure array_rand() was more portable.
Comment #9
saml commentedOn what version of Drupal is this patch supposed to work?
(I had to specify a version to be allowed to post, but I don't know if 4.7.x-dev is correct?!)
I have problems using it on 4.7.2. After enabling the poll module I see the message:
(I'm using table prefixes)
Also the random poll block doesn't show up, while the "latest poll" block still works.
BTW, any update for 5.0 on this one?
Comment #10
saml commentedHmm... testing on Drupal 4.7.6 works fine, also with tableprefixes. Must be either some issue with this version of Drupal, or with applying the patch while having existing poll content. Will report if I find a solution on this.
Comment #11
saml commentedI noticed that when you are logged out, polls that you have already voted on are show the radiobuttons and not the results (even though voting doesn't work the second time, as expected), which should be the case.
Comment #12
tengokuhi, i have a same problem that you mention here, but in diferent way.
i wanted a fixed poll that can be selected on block admin. so this is my code:
i'm an ultra-junior developer. so any fix will be appreciated. thanks. greetings from colombia
Comment #13
ekrispin commentedA version of #7 block that works with Drupal 5:
Comment #14
Camario39 commentedFirst time commenting here and newbie Drupal user.
For 6.0 I simply changed the SQL statement that searches for most current poll to the following:
vs
Hope this helps. I dont know how to create patches or contribute correctly, but I thought i would put this out there.
Comment #15
pasqualleComment #16
mcurry commentedSubscribe
Comment #17
JeremyFrench commentedI have written some code to do this on Drupal 6 (as part of another module). It is a little more complex. It displays a random poll that the user hasn't voted on, but if they vote it shows them the results of the poll they just voted on, it may need a bit of work but I can upload a D7 patch later today.
This is a very useful feature, more so than the latest poll block to my mind.
Comment #18
JeremyFrench commentedI am still working on a patch for this, work has taken over for a bit. However I am having a problem simpletesting the submit function as I am unable to determine the id for the options outside of the drupalPost method. So can't select a valid id to post.
Comment #19
JeremyFrench commentedUploaded patch. It is my first enhancement so please review well.
There are several points of contention I should imagine.
Order by rand(), I don’t know if this is acceptable, it will work with mysql but I am not sure about other databases, I can think of a couple of ways round this but they all involve running two queries instead of one.
$select->leftJoin('poll_vote', 'pv', 'pv.nid = n.nid and pv.uid =' . $user->uid);
I would prefer to use a param for the uid, but I don’t think this is possible in the left join statement.
Putting poll_random_voted_id in the user object. I wasn’t sure if I should use this or the session object, this seemed more Drupalish, but I think there may be an issue with anonymous users.
In the poll test I created a poll post method to get round a particular problem with testing when the form changes on a page load. I think this is unusual enough to warrant it.
Coder was giving me this message ‘@see references should be separated by "," followed by a single space and with no trailing punctuation’ but I am not quite sure what to make of it, it could be something with coder as the code that it reports hasn’t changed.
I am sure there is plenty else that may need looking at, but this is a nice feature and I have had to implement it on the D6 site that I help maintain so I am happy to try and fix any issues. It would be nice to get some feedback about the issues I have mentioned as well I don't know if they are bad or not.
Comment #20
JeremyFrench commentedComment #22
JeremyFrench commentedNeeded to change links to /admin/structure on the tests
Comment #23
stewsnoozesubscribe
Comment #24
Queeq commentedInterested. Subscribed.
Comment #25
amc commentedThis would be great.
Comment #26
berdirYou can use placeholders in joins:
Someone needs to test this on PostgreSQL/Sqlite/... :) Random ordering in SQL is a tricky thing, syntax and performance wise....
Comment #27
JeremyFrench commentedNew patch uploaded.
Changed:
now uses a placeholder in the join.
Does a count and then changes the range to aviod the order by rand();
Comment #29
raju4u52 commentedComment #30
truyenle commentedComment #31
truyenle commented#27: random-poll.patch queued for re-testing.
Comment #32
JeremyFrench commented@truyenle
Patch #27 won't work on D6, among other things it uses the D7 database API.
Comment #33
amc commentedIn any case, I'd guess this has to wait for D8.
Comment #34
truyenle commentedThank JeremyFrench.
Comment #35
robato commentedIs there a way to do this without hacking core?
Comment #36
Bojhan commentedI definitely don't see any reason to add this to the core block, something like http://drupal.org/project/advpoll should take care of these kind of usecases.
Comment #37
Satalink commentedNice job