Jump to content

Rather complex poll system with PW?


yellowled
 Share

Recommended Posts

So I have this site to maintain which is a low-budget, kind of non-profit pet project. Basically, it's an online poll for a music festival. It runs once a year (it's actually running now, which is why I even think about it) for a month. As of now, it's implemented with Contao, but I want to move away from that because it drives me insane. PollDaddy is not an option (because of the budget), and apeisa's Fieldtype Poll might be a tad limited for it (not sure about that, though).

Currently, the way it works is:

  • People register for an account with a UID/PWD they picked themselves (UID could as well just be email address)
  • They get an email with an account confirmation link which leads them to the login
  • It's usually about 10-12 polls per year; people can vote in all of them, but they don't have to
  • Requirements for the polls are very simple – 5 or 10 possibilities, 1 selection per poll (so basically radio buttons)
  • The results are not made public or even open to registered users, but of course I need some way to get the results.

I'm gonna need some maintenance tasks in the backend like “delete all users which have a specific role (meaning delete all users which voted this year because we don't want to keep around the data forever)”, but all that should be pretty straightforward in PW. The part which I haven't quite figured out yet is the actual poll itself. As I said, third-party services like PollDaddy are not an option, and I'm not sure  Fieldtype Poll would meets all the requirements I have. (Just one vote per user, no multiple votes from the same browser, don't show the results to users etc.)

So my idea was this: a poll like this is basically just a form like any old contact form, isn't it? Submitted forms in PW can be saved as pages in the system. So I could build a system which saves every user's poll results to a hidden page under, say, a page called “Results 2014”, and I could probably write some PHP logic to gather the current year's results from those pages, right? Every poll would be a group of radio buttons which would have a value (or not, if the user chose to not vote in that poll), this value would be saved in a field in that user's results page, so iterating over all child pages of “Results 2014” and counting the values would give me pretty much what I need, wouldn't it? There wouldn't have to be some kind of fancy diagram or anything, just a list of values will do.

I don't need code examples here just now, I have about a year to implement this before the next poll takes place. What I'm not sure about this is:

  • if this is actally doable in a sensible manner the way I imagine it
  • performance issues due to the number of users (I don't have last year's numbers any more; this year, we're up to 980 users after the first week, but it usually slows down after that)
  • security; it's rather important to the operators of the site that every user can only vote once per poll (although they are aware that there are ways for users to create multiple accounts)

So, any thoughts on this? Does it sound like a bad idea?

Link to comment
Share on other sites

I would use page fields and a seperate pagebranch to count the votes. 

Polls setup

| polls (template)
|_ question (template)
|__answer (template)

Votes setup

| results
|_ result (template with page field: user and a page field: answer)

In this setup you can:

  • Get all the votes
  • Get votes by question
  • Get all the votes with a specific user

Offcource it's possible to place the results under the answers directly, but I prefer to keep those things seperated if you want to extend it later with multiple questions or such. You won't hit performance issues with these kind of numbers.

  • Like 1
Link to comment
Share on other sites

  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...