Poll Module

Posted by arlo 
Poll Module
July 27, 2004 01:06AM
Hi,

I've written a module that lets you create simple polls within messages. You can give either moderators or registered users permission to create polls via the module settings. Unregistered users can't start polls or vote. This is my first nontrivial mod, so I'd appreciate any tips on my coding style or suggestions for improvement. And of course, you're welcome to fiddle with it and make it better.

---

From the readme.txt file:

In addition to placing the poll directory inside mods and turning the
poll module on, you need to do the following:


1. Phorum Admin -> Custom Profiles -> add a profile field called mod_poll


2. Add {POLLFORM} to the post_form.tpl template

Within the post form (on top of the message body is best), add the line:

{IF POLLFORM}{POLLFORM}{/IF}


3. Add a New Poll link to your templates.

For example, you could add the following line to list.tpl, read.tpl,
and others:

{IF NEWPOLLURL}<a class="PhorumNavLink" href="{NEWPOLLURL}">New Poll</a>{/IF}


******
EDIT: see below for a newer version of the module
******



Edited 2 time(s). Last edit at 08/21/2004 04:27AM by arlo.
Re: Poll Module
July 27, 2004 01:11AM
Here are some ideas for improvement in case anyone wants to try...

allow people to edit their polls
allow users to add write-in votes
don't require a message body
allow users to change their votes
add restrictions on which forums can have polls
allow unregistered users to vote

EDIT:
localize the strings



Edited 1 time(s). Last edit at 07/29/2004 03:57AM by arlo.
Re: Poll Module
July 27, 2004 01:20AM
******
EDIT: see below for a newer version of the module
******



Edited 1 time(s). Last edit at 08/21/2004 04:27AM by arlo.
Re: Poll Module
July 27, 2004 03:45AM
Sounds interesting. Do you have an example forum where one could see it in action?

registered users can only vote once in a poll? (like it should be :))


Thomas Seifert
Re: Poll Module
July 27, 2004 04:07AM
ts77 Wrote:
-------------------------------------------------------
> Sounds interesting. Do you have an example forum
> where one could see it in action?

Sure...

[www.alouie.com]

> registered users can only vote once in a poll?
> (like it should be :))

Yup!
Re: Poll Module
July 27, 2004 08:32AM
Ok arlo, you are starting to rock.

Brian - Personal Blog
pat
Re: Poll Module
July 27, 2004 12:53PM
Very nice !

pat
Re: Poll Module
July 28, 2004 04:22PM
Impressive, well done. A couple of suggestions for a future version:

- Since you know what option a user voted for, can you let them change their vote? (maybe by letting them revoke their original vote, so it'll think they haven't voted)

- If a poll creator makes a typo or something, a way to edit the poll to correct that.
Re: Poll Module
July 29, 2004 04:01AM
Tridus Wrote:
-------------------------------------------------------
> Impressive, well done. A couple of suggestions for
> a future version:
>
> - Since you know what option a user voted for, can
> you let them change their vote? (maybe by letting
> them revoke their original vote, so it'll think
> they haven't voted)

That's a good, easy solution -- I'll put that into the next version.

> - If a poll creator makes a typo or something, a
> way to edit the poll to correct that.

Hmm... that's a little tougher. :)

Thanks to everyone for all the feedback.
Re: Poll Module
July 29, 2004 07:02AM
arlo Wrote:
-------------------------------------------------------

>
> Hmm... that's a little tougher. :)

Yeah, I ran into a similar problem in the avatar module. What I ended up doing is checking what page is being looked at, and if its edit.php/moderation.php, setting up the avatar list based on which one is presently selected in whatever post is being looked at rather then the users defaults.

You could do something similar here. Add a link to the poll when the poll creator is looking at it that goes to edit.php with a poll flag on it like how the newpoll link works. When on the edit page, if you see that flag display the existing poll information in an editable way.

Then use the pre_edit hook to process the changes. Shouldn't be too bad. :)

Sorry, only registered users may post in this forum.

Click here to login