Random List of Questions

I have stepped away from Thunkable for awhile now due to life and covid but I have returned to continue my education here. A lot has changed since I have last been here and I still have tons to learn. I have the beginnings of a quiz app and need some guidance from the community.

My question is how do I create a list of randomly selected question from my local db? I have a local db with 8 questions currently and would like to say pick a random 4 questions for each quiz. I have read through a bunch of past post but still cant get my head wrapped around how to make it work.

What I think I may need is for someone to actually show me in my app block so I can see it in action and understand how it is accomplishing the function. I learn a little better for a “monkey see monkey do” method.

I have added the link to a copy of my project below if anyone is will to assist. The page with the blocks in need is in “Category 1 - General”.


I am open to all advice and thanks in advance.

1 Like

I will use something like this

I added a variable to hold the list of random 3 questions out of the available questions. I created a list of 1 to the number of rows in the table and shuffled the list and then selected the fist 3.

This has now become my randomly selected questions.

In the Update quiz screen question function, I assign the first number in the list to the variable question and immediately remove it from the list to avoid duplicates.

You will need to check that the list of selected questions is not empty before attempting to read the next question.

Have Fun Thunking!


@muneer this is a really elegant solution! :clap:


Many thanks @tatiang

I would like to thank you all for your assistance. My apologies for not replying sooner but I have been out in the field on a hawk trapping expedition for falconry purposes. The purpose of this app will be to help new falconers study for their required state exams. Again, thank you all and I will look over your suggestions carefully.

1 Like


Thank you for your solution advice. It works just like I saw it in my head. I do have one follow up question dealing with hoe to end the quiz at the number of questions selected. In the capture below you can see where I implemented your solution. I the function labeled “after user answers” I am using the first line to end the quiz and direct them to the results page. I’m not sure what to use to use here. I have shuffled the list from 1 to 25 by 1’s and a sub-list from 1 to 5. How do I get it to recognize the list is completed at the 5th question.

I hope this is not asking for to much of your time. I really do appreciate it.

1 Like

If length of app variable Selected List = 0 then there are no more questions. You can use the list empty block if you like instead of checking the length.

1 Like

I see where I was overlooking the issue you pointed out. I was using the variable question counter and not the variable selected list. Got it. Changed it to (app variable selected list = 0).

I’m sure I will have more questions but thank you guys.

1 Like

I knew it would not take long for another question to pop up. It again has to do with a questions list. Everything recommended previously is working perfectly for my purpose. I now want to take it to the next step. I am trying to create another random list of questions from multiple sources. I have a “created local. dB” with 3 tables currently. I would like to grab say 5 questions from each of the 3 tables and and create a single list. This is to take questions from multiple quiz categories and make a single practice test. The previous screen capture is still accurate.

Consider the fact that a way to simplify this whole process is to either (1) manually build a single list of questions from multiple sources in a Google Sheet or Airtable (or local data source but the editing capabilities are so so limited that I would recommend against it) – and by this I mean that you compile one long list of questions that you will use as a single data source with the methods suggested above or (2) automate creation of a single list by using Google Sheet or Airtable formulas to combine multiple sources into a single source/column. And actually, you could probably even use formulas to generate a single list from random selections of multiple sources but… since I did use the word “simplify” let’s stop there and consider something else…

The only way I can think to do this with multiple sources (especially local data sources) that haven’t been combined in some way is to do the combining using Thunkable blocks and specifically, to loop through each source and choose random rows and insert their values into a list, and then use that list the way you’ve been doing it already. I know just saying that doesn’t tell you how to set up the blocks but hopefully it lets you start that process and then ask more questions when you get stuck.

1 Like

Gonna need a bit to wrap my head around that one. Thanks, you have given me a lot to consider.

Do you think it might be possible using blocks to create a first list for questions 1-25 and when it reaches question 26 to create a second list for questions 26-50 and so on… ?

1 Like

Will you be using a cloud storage such as Airtable or Google sheet or Firebase or will you have it as a local table?

When using a cloud storage remember that others using the same app will can also add to the questions therefore you need a way to control question creation.

However, if you consider a single user system then you can build the blocks to do whatever you want.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.