Quiz game with random questions

Hello all,
Im a beginner with Appgyver, but I have to say that is a great tool and full of possibilities.
That’s why Im trying to create a Quiz game with it (with multiple choices). But Im having some problems.

So I created the questions, possible answers and correct answer in a table with Xano:

After that I imported the data into Appgyver and created a Data Variable. API call to get collection is like this:

I created a component, which contains 1 paragraph for the question, and 2 rows each one with 2 cells containing the answers.
image

Now: If I use the command Repeat with, I can display everything correctly. But Id like to display just 1 question and this should be randomly. After question was answered, then a new one should come.

I tried different formulas…LOOKUP, PICK_ITEM, SLICE, RANDOM_INTEGER_BETWEEN…in order to get 1 question and randomly. However couldnt achieve that.

Any light in here?
Thank you
Danilo

Hi, I would do a random quiz like this:

  • Data variable data.Questions
  • When quiz starts, generate range with all indexes of your list: GENERATE_RANGE(0, COUNT(data.Questions) - 1, 1)[0, 1, 2, ..., data.Questions.length - 1]
  • Shuffle this list → SHUFFLE(...) and save to page variable index
  • Then take the first random index and use it to display an item from your list of questions → data.Questions[pageVars.index[0]]
  • Remove the index you just used: REMOVE_ITEMS_AT(pageVars.index, 0, 1)

And repeat until pageVars.index is empty, then you can end the quiz :slight_smile: