Questionnaire / User Preferences

Hi I am totally new to Bubble. Seen some videos, read posts, and looked at some templates but couldn’t find exactly what I am looking for.

I want to create a questionnaire / user preferences, but not sure how to set it up and linking multiple tables (type).

So I have created two types with the following fields:

  • Category
  • QuestionNumber
  • Question


  • user id (not sure if I should use user unique id or something else yet)
  • QuestionNumber
  • Response (numeric 1 to 5)

What I have done and need to do:

  • Create a page that has repeating group to display the questions (done!)
  • Next to each question in the repeating group, I would like the user to provide an answer 1 - 5 using a slider (or drop down). I have put the slider and make a default value of 3 (done!)
  • What I don’t know, how to is to make the page so it can allow the user modify the slider, it will insert a new record in answer type for all fields, if this is the first time answering that question. However, if they have submitted an answer before for a particular question, the operation is just update the existing response (response field). Somehow I need to link the answer table and question table or something, and make the value in the answer table editable.

note: users do not need to answer all questions. if they don’t answer the question we don’t need to insert his response to the answer type

So, is my table / type structure correct and how to actually do what I need to do?

Thanks a lot in advance!

I’m thinking i may need to join the two tables together to display the current respond. But couldn’t find anywhere in doc to do that.

I’ve done something similar in the past. A few thoughts:

  • I would not use Repeating Groups (RGs for short) to collect information from users. The reason is, the only way to get this data into your database from an RG is to trigger a workflow each time any of the values are changed. So, if you have 10 questions then it’ll fire 10 times if users only pick one answer for each. However, sometimes users change their answer and sometimes do so quickly and sometimes the 2nd answer gets overwritten by the first one since the timing isn’t always the same with Bubble.
  • Instead, use a set of elements and put them in a group, then copy/paste the group and include it multiple times on the page. Then, include logic for each group to only show it when the number of questions to be displayed is > or equal to that groups number.
  • Your database structure seems like it fits your needs.
  • I’d recommend you use star ratings instead of a dropdown or slider. The reason for this is that star ratings only require one click to select (so quicker / easier to fill out for users) and also stars are associated with preference in people’s minds.
  • Consider ditching the 3 star default unless you’re okay with a lot of the selected answer choices being a 3 (people are lazy and may skip rating items). Really depends on your apps goals though.
  • Include a button at the end that submits the results to the database once users have filled out all of the questions.

Here’s a screenshot of ours (note, the question and answer choices are customized by our users, so this is just one example of the word choices, but always same core visual architecture):


Thanks @sridharan.s, I still don’t really get it. Let me respond to your statements:

So I create a group by choosing "answer " as the type of content. Then insert a text book and choose parent’s group answer’s response? How do I display the Question since it is in a different table? Is there a join table thing here?

You mean if there are 5 questions I create 5 groups, so this is not dynamically displayed like RG? What if the number of questions changed?

I really don’t get this part, what is group number?

Sorry if my questions sound too elementary. Is there a way to see that portion of your app so I can see your table structure and how to create these multiple groups and your logic?

Thanks in advance!

Sure, happy to help.

I’d have 1 table on the backend, as you have now. On the UI, I’d add a set of groups. In each group, I’d have a label and a 1-5 star rating. That’s probably all you need. Note - no need to set the group to any particular type of content. Can leave this blank.

I’d stack the groups top to bottom and call the top one #1, then #2, etc. For each group, I’d set a condition for that group to only be visible if the number of questions on the page is greater than that group’s number. So, if you create, say, 10 groups on the page and a survey has 8 questions, then the top 8 would display and the bottom 2 would not based on the conditional logic on all of the groups. Also, set each group to collapse height when not visible so that the content below it shifts up (for example, a save button at the bottom). Note - the one constraint here is you need a lot of groups if your surveys might be really long, and getting all of the alignment is tedious.

Explained in my answer above.

Also, I can’t share our app’s code, but happy to share a screenshot of the backend which is probably all you need anyway:

Actually I do have two tables. The question is in the question table and the response is in the answer table.

I think I almost get what you are saying.:slight_smile:

Can you share me the screen shot of this table? and if you don’t mind share the first record of the data?

Also I assume you have user id (unique id) column stored in your response table?

Ours is quite complicated because we have 2 or 3 additional layers of complexity which makes it quite hard to understand. So, here’s a simplified version of our table which is reflective of what you’re building here:

Answers / Preferences:
Survey (Thing)
Questions / Labels (Thing)
Answer Choice (number, ours end up all being 1-5)
User (Thing)

Questions / Labels:
Survey (Thing)
Question Label (Text)
Order_Number (number) - each question within a survey has a unique number, starting with 1 and going up to 15 since we only have 15 groups on the page

Thank you again @sridharan.s.

  • Since your groups are ‘static’ group - you don’t set it to any type of content, how do you get the values of your question labels and user’s responses? if your’s is set to a type of content, is it set to answer table?
  • How does it look when the user hasn’t updated his responses? do the question labels still appear and all stars are grayed? How do you make them appear?
  • The questions / labels in the answer table has a field type as ‘questions’, so it is a link?
  • How does your button work, does it perform an insert or update? If it is insert, how do you prevent it to insert another record if a user already answered it before. And if it is an update, how does it update if this is the first time a user answer the questions?

Thanks again.

Yep, no problem. Here’s answers to your 4 questions:

  1. I load the labels dynamically using “search for” logic. Then, when I save the data, I make sure that I save each item with the correct information as well using dynamic logic.
  2. The labels all load automatically and the stars are all set to default to zero stars filled in, unless the user has previously answered that question number for that survey, in which case I default the value tot he user’s selected value.
  3. In the database, when you have a field that references another table Bubble calls the field type “a thing” which, by definition, just means it references another database table. It’s similar to the database concept of “table keys” except it’s abstracted a level so you don’t need to reference it by an ID code or anything, but instead the whole “thing”.
  4. Ours are set to update since user’s may have answered them before. Additionally, we have them set to create a new value if there isn’t already a value in our database (which you can turn on by checking that box with the action ).

I think I am almost there. How do you load the user’s response. Do you also ‘do a search for’ under conditional tab?

When I tried to do that it didn’t let me choose Question (thing) = 7

also how do you put a logic to set it to 0 if no response?

We use a workflow and actions to load the responses. 1 workflow (On Page Load) then 1 action for each potential question. It’d basically say if user’s answer for question 1 is 3, then set the value for that star icon to 3.

Note - we use our own star rating icon, not the default one so I’m not as familiar with how the default one works. I suspect you can “set” the value for it to be equal to a number. If not, you can set the value of a custom state one the page and then use conditional logic on the star to set it’s value to be equal to the custom state’s value.

Also, since we’re using our own star ratings, not sure how to set the default ones to zero. Probably a way to do so though.

got it. let me play around a little bit. worst case I have a back up solution, which is more manual.

thanks a lot for your help and insight! it has been very productive for me.

Glad to hear. The more you play around with and overcome these types of challenges in Bubble, the easier they become.

Thanks! Any suggestions on how to update this questionnaire to see how answers change over time?