Store data in custom state and send it to database (build a survey)


I have read a lot of forum posts but I have been unable to find an anwser to my question. If anyone could help it would be awesome !

My situation is that I want to build a questionnaire on Bubble where a user can chose between either strongly agree or strongly disagree.

I have created a repeating group to show the list of questions, and the Likert scale (the group of radio buttons from strongly agree to strongly disagree) so that the user can answer :

My survey is made of a lot of questions, and I display questions 6 by 6, and when the user clicks on “next” it displays the next 6 questions.

What I do is that I have created a group made of all my radio buttons, and then I have created 7 different custom states in this group to be able to have a condition on my radio buttons and to show if it is selected or not :

In my workflow, when a user clicks on a radio button, it changes the custom state of the group of all the radio buttons and then it changes the background color of my radio button to show the user which one is selected.

What I want to do next, is that when the user clicks on “next” and it displays the next group of 6 questions, it sends to the database the choices of my user. In my database, I have created a type called “answer” with 3 fields :

  • “Question” to store the text of the question
  • “Answer” to store the answer of the question (number from 1 to 7 - strongly agree to strongly disagree)
  • “User” to store the user who has answered.

Right now, I am able to create a new thing in the database, each time a user clicks on a radio button. I create a new thing in the database with these 3 fields, but it makes problems when I want to make sure that the user doesn’t answer twice the same question.

Instead, I want to use the states that I have stored in my radio button group and to store them in the database each time the user clicks on next, with the information about the answer and the user also. I have seen that it is possible on this forum post : Can bubble build a survey - #4 by sridharan.s (@sridharan.s)
But I really don’t understand how is it possible to do that.

The final goal for me is to build a survey that looks like this one : Free Personality Test | 16Personalities

Is anyone can help me on the topic ? Do not hesitate if I can give you any other information !

Thank you very much :pray:

Hi @cesar1

Perhaps you have issues with avoiding answering a question twice, because the custom state for respondeu is a text instead of a thing and I do not know how Bubble can check if a text is contained in a list of texts. When you make respondeu a thing you can then check if it is contained in whatever list (state or dB thing) you save those answers to.

1 Like

Thank you @cmarchan !

I think you point to the right issue, I need to change the custom state of my element into my data type “answer”, and then I’ll be able to send it to the database.

So I have changed the custom state of my element into my “answer” data type, this is the custom state “Réponse à la question” that you can see on the screenshot below. This data type is made of 3 types: the text of the question; the value of the answer; and the user who answered the question.
But when I am in the workflow panel and that I want to change the custom state with the data type “answer”, I just have one row, so I am unable to change the 3 fields of my type. I have something like that :

But I would have want to have something like that so that I can fill all the fields of my data type with each time the correct value :

Do you know what can I do in order to fill properly the custom state, to be sure that I store the 3 fields of my data type?
Because each time I have an error and it says that the field I am trying to enter is not the type “Answer”.

Thank you very much !

I am not sure if the following can help:

Think of singular vs plural.

  • When you search or filter for singular things you can search for its fields.
  • But when you search or filter for multiple things you have to see if they are contained within a list.

It is very hard to provide you with specifics as a build in Bubble is made up of multiple aspects … the dB structure, the resulting logic depending on the dB structure, how conditionality can be applied depending on many aspects that might no be present yet … etc etc.

I suspect you may be running into difficulties perhaps due to the above.

But I may be totally wrong!