poll system for Symfony2

1k views Asked by At

I want to make a poll system into my website like http://dilemmaplugin.com/, this is what I want but is just for Wordpress...

I don't know if there is some plugin for Symfony2, I've searched but nothing... So I would like to ask you a walkthrough about how to make it, using caché/ip for not voting twice... This is where I'm lost, the vote is basic, I think:

Database would be like

id     question              option_a       option_b
1      PS4 or Xbox One?      1523           1102

So if you press the two buttons, option fields will do +1, easy as ABC, but what about the caché/ip preventing duplicate votes?

I was also thinking about making some carousel div that contains random votes when you press next but that can be done via Json I think, just querying the DB with Ajax...

Thank you

1

There are 1 answers

0
Johnny On BEST ANSWER

If you want/need to stick with your current schema, one way of preventing duplicate votes by IP Address is that you could use something like memcached(very fast) and for each vote store the question id and the ip address. If your using Doctrine as your ORM then you could use a preUpdateEvent to check for the existence of the ip address.

You could setup a custom Validation Constraint on your entity to check for the ip address as well which has the benefit of presenting friendly messages to your forms.

Another possibility is to setup an Event Listener in your controller or model manager to check for the ip address.

Hope that gets you going in some decent direction.