Creating a Quiz with random order options

I am trying to create a quiz with options to click. I have a database with a custom data type with fields for the question text and options I created for each question. For each question, I have say 2-6 options. What I want to do is to display a random question along with buttons for options. If I have less than 4 populated options, I would display every populated option. If it is more than 4 options populated, I want to display the correct option along with 3 other options. The options would have to be in random order of display and also random order of selection among the false options. I managed to get the question chosen randomly in a repeating group but have these questions:

I only managed to “hardcode” option 1 or option 2 or so on. How can I get it to choose the correct answer for the randomly selected question along with 3 additional random options, shuffle the order of display and then populate the buttons. That way I will have 4 options chosen randomly among the six and order in which those four options are displayed would be random as well.

Thank you for anyone’s help with this one!

Hi @kilaigal, you will need to add another object (thing) to your database structure for your options.

Should look something like this:

However you choose to display the options, you would use this type of search:


Then, regardless of whether you add 3 options or 300, it will look up all the wrong options for that question, sort that list randomly, take only the first 3 options, add the correct answer to the list, re-sort the new list randomly and display the options to the user in that order.

That should get you started :slight_smile:


Thank you for the quick response. I’m slightly confused though. I had a data type called question which had the question text along with options. Are you saying I should get rid of the options fields in the question data type and create a new data type with the options? How will questions tie to the options then?

Or are you saying create just one data type say “newtype1” with question text and correct answer and options as list of newtype1s like this? I guess I’m not clear what the fields for type Options are in your response.


Yes. If you want to be able to randomize the options then keep the Question data type and create an additional data type called Options (as shown is my screenshot above). The questions connect to the options with the fields Correct Answer (which is an Option) and Optional Answers (which is a list of Options).

If that doesn’t make sense, go back and retake this particular Bubble lesson: Learn | Bubble Editor

The lesson has the user input the new items and a new Text entry is being created every time there is a new entry which can be displayed. In my case the choices were part of the db. When I create the Options data type would I create fields inside the data type to enter the choice for each question as text. Here is what I have done…

This is where I think the trouble for me is:

I uploaded my questions from a csv. Each question is supposed to have the correct ans as text and wrong options as a list. I am not sure how to set it up at this stage. The tutorial creates a new entry every time through a user input which makes sense to me. In this case I’m not sure if the options need to be prepopulated as a list under options datatype. If that is the case then how would q1 and q1’s options be tied since we are simply linking the generic data type and not a particular question.

Thank you for your patience. The learning curve is steep and I’m getting used to thinking through the bubble way.

It is a steep learning curve, no doubt. I don’t have the time at the moment to respond in depth but will when I have a chance.

Not to be confusing but you could have all your options in one list and simply have one option noted as the correct answer instead of storing the correct answer separately on your question data type as well. Or have both. Lol. Sorry, I’m rethinking my earlier advice though it will work just fine.

However, you are on the right path. Set up a place to manage your questions and a form to add options to your questions. An easy way would be to have a repeating group with your questions and in each cell have a text input and submit button to add your option. You want to create a new Option and then use the Make changes to a thing action and ‘add’ the new option to the current cells Ans Options.

I’ll stop before I ramble too long. If someone else doesn’t step in before, I’ll make a video walkthrough later for you.

Great! I’ll continue to poke at it. Just to clarify, the user would not be adding any options. I have a db of questions and choices. Lets say Q: What is 100+100? Options are 10,100,200,300,400 and 500. Out of these I when the user opens the app, they will see what is 100+100? with four buttons with four of the five options in random order. They click on an answer and we tell them if it is the right one or not. That’s the extent of what I’m trying to do here.

Thank you for your input.

As @eli said, this might be a steep learning curve for someone so new to Bubble. I might recommend signing up for This will help you get through the basics of Bubble. Essentially walk before you run.

If time is an issue, you can always pay to have a tutorial on how to do what you are asking. In short, you need to know how to link data types and records. You can do it though! I started a year ago and I way beyond where I was when I started.

Got this done!

This was the datatype setup:

This is kinda how the app data would look. Ofcourse you can upload data from a csv but the options would need to be in a single column with brackets like [1,2,3,4,5,6,7] during import.

On the design side, I had to create a group and use text for the question. The options are part of a repeatingGroup.

with each button being text of one of the options. Produces a different sequence of answers always having the right answer in it.


Hello can you share how to applying that repeating group ? thank you