Local DB random question for app quiz

hello guys ! I want to ask how can you make random selection of questions and answer in local DB, I’m making a quiz app but I want to shuffle everything just to have some challenge for the user. But it’s hard and I’m stuck.

I did try different approach like make a list and then shuffle it there but its not ideal because if I’m going to add question I need to put it again on a block text list and I think putting the questions in Local DB is much better way.

1 Like

When you initialize the app, you can get all the questions from the LocalDB and put them in a list. That way, you are using questions from a LocalDB, but they are in a list and can be shuffled.

1 Like


I’m not sure if you are using the term “Local DB” as used by Thunkable. If you are referring to the same component then you need to know that this is a temporary storage which does not retain data after the app is closed. This is mentioned in the documentation.

1 Like

Hi there,

You can make this pretty easy using Lists blocks.

Start by creating a list that lists every row number in your Local DB. For example, if your Local DB is 5 rows long, this will create a list of the numbers 1-5. If your Local DB is 20 rows long, this will create a list of the numbers 1-20, etc. You can also create the variable question number, which is how we will point to the row on the Local DB whose question we’re displaying in the app.

Now, to randomly select a row without repeating questions, we can get and remove a number at random from this list:

As you can see, if we have shown every question in the Local DB, the list will be empty. In that case, we will navigate to the end screen.

You can then use the variable app question number to get and display data from your Local DB!


The code is missing the main block. The one that makes use of the number as being the row number and retrieves the “quiz” from the Local DB. Without it, the app is just showing the numbers in a random fashion.

Hi Muneer,

My focus here was on showing how to get a random, non-repeating series of numbers that can then be used to retrieve the information from that row number in the local DB.

I didn’t include the blocks saying ‘get cell at [column name] [question number]’ because it wasn’t the focus of this question, though of course you are correct in saying such blocks are needed to build a quiz app!


Much better than the (bad) way I did it in Dinosaur vs Microorganism. Gonna have to refactor that bit of code!


I’m glad you like it! The benefit of a forum like this is that we don’t have to independently figure out how to write the most efficient code - we can take inspiration from each other! :grin: