Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Poll - Vote Only Once
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Poll - Vote Only Once

 Post Reply Post Reply Page  <123>
Author
ljamal View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 16 April 2003
Status: Offline
Points: 888
Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post Posted: 16 May 2003 at 11:41pm
Ideally you would create another table in the database with the Poll_ID and Author_ID. When a voter votes, it would add the Poll_ID, Author_ID to the this new table (as well as increment the pollChoice table for the correct choice). When the poll expired you could just remove all the vote placed on that table.

I have similar table in my SQL and it required 1 MB for every 2000 or so records.
Back to Top
exile2003 View Drop Down
Newbie
Newbie
Avatar

Joined: 20 April 2003
Status: Offline
Points: 11
Post Options Post Options   Thanks (0) Thanks(0)   Quote exile2003 Quote  Post ReplyReply Direct Link To This Post Posted: 17 May 2003 at 1:06am

I agree with ljamal, the use of a separate table with fixed-size records would probably be faster than the use of a variable-size memo field.  This method would be slightly more involved, since you'd need to create an additional table.  If you're comfortable with Access databases, following is another method that can assuredly prevent multiple votes.  This has been tested on v7.01, Access 2000 but should work with Access 2002 as well

1.  Open your forum database in Access, then add an empty table called 'tblVotes' with the following fields & attributes:

Field               Attributes

Vote_ID:     AutoNumber, Indexed with no duplicates.  Set this as the primary key.

Poll_ID:       Number (long integer)

Author_ID:   Number (long integer)

Save & upload your database to your server

2.  Download http://www.allersoft.com/wwf/poll_mod_701_v2.zip.  Replace poll_cast_vote.asp in the forum directory and poll_display_inc.asp in the includes directory with the provided files.

That's it.  This method on average will require slightly more space than the method I described in the previous post, but should be faster.  If borg decides to implement a more rigorous vote-once option, this (or something similar) is probably what he'll use.  Thanks borg for a great forum

P.S.  There's no provision for deleting the vote records, that would involve mod to the admin panel which I'll leave to borg or a more motivated mod-builder, but you can manually delete the vote records periodically.



Edited by exile2003
Back to Top
ljamal View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 16 April 2003
Status: Offline
Points: 888
Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post Posted: 17 May 2003 at 8:05am
The Vote_ID isn't necessary in this case if you declare that Poll_ID and Author_ID together as the primary key. Using the Vote_ID would only increase the size of the table.
Back to Top
exile2003 View Drop Down
Newbie
Newbie
Avatar

Joined: 20 April 2003
Status: Offline
Points: 11
Post Options Post Options   Thanks (0) Thanks(0)   Quote exile2003 Quote  Post ReplyReply Direct Link To This Post Posted: 17 May 2003 at 9:41am
Searches and updates would be slower in that case.  But if you're really pressed for space, you could combine the Author_ID and Poll_ID into one "long integer".  In this case Author_ID and Poll_ID cannot exceed 65000 (size of a "short", 2-byte integer), and you can have only up to 65000 vote records.  But you then will only have to store one long integer (4 bytes), instead of three for each vote.
Back to Top
ljamal View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 16 April 2003
Status: Offline
Points: 888
Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post Posted: 17 May 2003 at 10:30am
The only searches on this would be against Poll_ID and Author_ID and not against the Vote_ID. Therefore having Vote_ID would not improve searching performance. There would be no updates because you are either in the list are not. There would only be look-ups against the Author_ID and the Poll_ID, deletions by Poll_ID, and insertions. Where does the Vote_ID improve performance?
Back to Top
fernan82 View Drop Down
Mod Builder Group
Mod Builder Group
Avatar

Joined: 17 November 2002
Location: United States
Status: Offline
Points: 362
Post Options Post Options   Thanks (0) Thanks(0)   Quote fernan82 Quote  Post ReplyReply Direct Link To This Post Posted: 17 May 2003 at 12:22pm
I agree with ljamal, i don't think you need to store the vote_id, also you don't need to edit the admin panel neither just insert some code on poll_display_inc.asp that runs only if the poll has expired, that code will check if the votes are still in the db and delete them...
FeRnAN
Back to Top
exile2003 View Drop Down
Newbie
Newbie
Avatar

Joined: 20 April 2003
Status: Offline
Points: 11
Post Options Post Options   Thanks (0) Thanks(0)   Quote exile2003 Quote  Post ReplyReply Direct Link To This Post Posted: 17 May 2003 at 12:54pm

Well...who am I to argue with a mod-builder...

A quick disclaimer: my original intention was to make a couple of quick modifications since I'm gonna do a couple of polls that require strick enforcement of the vote-once option.  Since I'm restricting poll-making ability to mods/admin, database size/cleanup was not a big issue.  Plus I could manually control the size of the vote records.

That being said, if someone decides to do a "full" implementation, a couple of suggestions:

1.  Give select groups of users (mods/administrators) the ability to create polls that use "strict" enforcement, i.e., through database-stored voter IDs instead of cookies.  Non-mod/non-admin could be limited to creating polls that enforce through cookies only.  This way the database is not filled with voter records for "trivial" polls.

2.  As fernan82 indicated, the database cleanup operation could take place when the poll is displayed, but it could also be implemented through a "Removed expired vote records" in the admin panel, so the database cleanup can be done at one setting; that might reduce database fragmentation (and save the server one extra database query every time the poll is displayed).

OK Dokey...have fun



Edited by exile2003
Back to Top
fernan82 View Drop Down
Mod Builder Group
Mod Builder Group
Avatar

Joined: 17 November 2002
Location: United States
Status: Offline
Points: 362
Post Options Post Options   Thanks (0) Thanks(0)   Quote fernan82 Quote  Post ReplyReply Direct Link To This Post Posted: 17 May 2003 at 11:02pm

Well I finally finished it!

I made the mod so you can set an expiration date on the polls and on the admin section you can set it to automatically delete the votes once the poll expires or to display a link to admins on the poll once it has expired to delete the votes, it also deletes the votes if the poll ever gets deleted before it expires.....

read about it and download it here: http://forums.webwiz.net/forum_posts.asp?TID=2808&PN=1&TPN=1

FeRnAN
Back to Top
 Post Reply Post Reply Page  <123>

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.