Unique random questions

Hello all, I am making a trivia game, everything went fine until now… I followed a Thunkable tutorial and I got in that point, I made a loop blockchain and a database so it’s going to be easier but when I open the app one random question appear and then after I respond the same question remain, what can I do so other question would come?

P.S. I got other blocks with correct answear and other stuff, they work fine, only this problem.

1 Like

Without seeing the other parts, I’m assuming you are doing something like
“When user click” → check answer → get next question


This are all the blocks, I tried to fit all of them inside this photo… If there is any other block that will tell the program to pick another question that wasn’t picked I would love to see it, maybe will fix my problem

at the end of
image

(right after set Image3 blah and set Image2 blah…
you have to insert
image

The questions are changing now, but the correct answear isn’t matching after the first one, sometimes it changes the correct answear but not the rest, pretty weird

1 Like

can you post the contents of your table.
can you post a screen that shows you answered the question correctly - then show one where the question doesnt have the correct answer.

2 Likes

If you can, share your project, it makes it easier to try and help :grinning:

2 Likes

This is the link of the project ( Thunkable ), I am trying for now to understand how it’s working, after that I will work more at the design and other stuff, but the question randomization it’s a pain xP

1 Like

Here is what you need to do. You are trying to change the question before assigning a new question number. I moved the get random integer to just before the update question. And now it works :slight_smile:

3 Likes

It works <3, thank you so much ^^ … I have one more question, is there any way to set the question number to be unique? Like when you start once, if you give the answear, doesn’t matter if it’s correct or not, you’re not gonna take this question again. Because a 0/40 trivia, to see your score at the end is a good idea xD

1 Like

You need to use a different method for randomizing questions without repeating them. One way to do this is to create a database/table with cell values for each question number:

1
2
3
4
etc.

Then, when you want to pick a random question number, choose a random row from 1 to the number of rows in the database. Store that number as the question number (in a variable). Delete the row from the database. Repeat until all rows have been used up.

It’s possible to do this with a list instead but if you’re not experienced with using lists, I would probably recommend sticking with a database.

3 Likes

I second what you say, you can just creatse a data source and input all of your questions. Or connect it to a google sheet or something :grinning:

you can use this technique: create a shuffled list of numbers from 1 to # of questions. (eg. 7,4,1,2,6,3,5)
as you run your quiz, start using numbers from the left. when you’ve used 7, remove it from the list , leaving 4,1,2,6,3,5. when the list is empty you’ve used them all up.
here’s a picture of the blocks.

you can use the question number as an index to your table of questions.

here’s a link to the demo (select Screen4)
https://x.thunkable.com/copy/3ad3d4ccd6996bcf1b1218bb1deefd27
i hope this helps.

6 Likes

I will look into that also, for now I put a limit of 3 fails, and I want to have a lot of questions so if 2-3 questions will come again won’t be a problem… I got only one more question, when I upload a gif I got a error with “Please select a animation file” and nothing shows, any idea how I could repair that? Thanks everyone for the help ^^

this is what i did: i found my lottie (animation) file and renamed it to DL_icon.json
and uploaded it to my File Assets

then i added it to my screen in thunkable

and inside the blocks, i set the properties ot the animation component.

you can do the same.

5 Likes

I guess it worked, thanks again ^^… I add some more question and now I have to figure out how to stop the acces to the button after 1 resonse, cuz now if I spam a button I will respond more times on a single question and it’s bugging the score

Your algorithm should be:

  1. Select new question number
  2. Enable guess button(s)
  3. User clicks guess button
  4. Disable guess button(s)
  5. Check to see if guess is correct
  6. Provide feedback to user
  7. Repeat steps 1-6 until no questions remain
2 Likes

It makes sense, now I have to put the blocks xD… I try to understand as much as possible, thanks again for help :smiley:

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