Jump to content

Poll, one answer per user

Recommended Posts


I'm designing a poll app. It's a simple one-question poll with an arbitrary number of answer options. I have a connection on it to authenticate users and require them to log in before answering polls. 

Everything is working so that my admins can make new polls/answers and users can log in and answer them. However, I can't figure out how to restrict users to one answer per poll.

I have tables for users, polls, answer options for each poll, user responses. It's all working, but I need a (non-kluge) way to check whether a user has already responded to the specific poll before inserting a new response in the response table. 

I am stuck. I have a kluge in place (basically tracking in an array which polls the user has responded to in his record in the user table). 

I'd love it if Caspio Bridge would let me do a "single-record update" or "details page update" which would, if it couldn't find the record, insert a new one. Something like that would make this app perfect and kluge-free. 

Or maybe I need to go about it another way entirely? 

Any feedback appreciated!

Link to comment
Share on other sites

As I understand each user can answer to only one answer per poll, meaning the combination of User ID and Poll ID should be unique. So you need to add one more field to the answer table and make it unique. In the submission page where user can answer include this field and use the script at

to combine IDs and save it in that field upon submission.

Link to comment
Share on other sites

Thanks MayMusic -- I thought of that, but then figured I'll get an error for users who've already answered, won't I? Problem is, when people visit the page with the poll on it, what displays depends on whether they've already answered. So I need a way to check for such a unique value and behave differently depending on whether it's already there. Can't try to insert or I error out if unique value is already present. Right? 

Link to comment
Share on other sites

  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...