Students press a button to select questions randomly to answer from a list

Hi:
This is a feature I am trying to add to a phone app for my students. I have a list of questions (say c20). I would like students to be able to press a button on the screen to show a randomly selected question from the list, in a text component below the button. Can I do this? I would like to copy the questions from a list that is on the “question list” sheet - onto the data sheet being used for this screen. I think this should be done as an array – then have the button select a random item. Ideally I would like to be able to vary the range of items that can be selected randomly (eg there may actually be 100 questions – but I only want students to see from numbers 20 to 30 at that time) I feel sure it is possible to do this. But I am equally sure I don’t know how!
Thanks for your help.
Paul

Add a collection list that sources your questions. Sort it randomly and set the number of items to 1. Add a button that has the action of shuffle. If you only want to show a certain set of the 100 questions at a time you could add a boolean column to your questions table and check the ones you want to be available. Then filter your collection by ‘checked’. Another way is to number the questions and filter the collection by that column. To simplify the process (so you don’t have to go into the Glide builder every time) create an in-app dashboard that only you can access where you can set the parameters of which questions to show. This might involve a number entry that sets the minimum number and another that sets the maximum. Then filter you collection based on that.

To avoid the app repeating questions that have already been shown you could add an add row action to the item (question) that stores the question in another table. Then relate that back to the questions table and filter the collection by the relation. Or have an action that checks another boolean column in the questions table

Hi Paul!
There is a column called “Roll the Dice”.
General algorithm:

  1. Create a “Questions” table with the list of all questions.
  • Create Row ID column.
  • Create a lookup column with name “Index/All”. Pick table “Questions” > Row ID.
  • Next column - name “Index/Current”, its going to be “Find Element Index” column type. Fill in Values - Index > All; To find - Row ID; Precision - 1. This should create an order number for all of your questions starting from 0. But since Roll the Dice can not be 0, we need a math column to basically increase that index by 1. Therefore next column
  • Next column name “Dice #”, it’ll be a math col with configuration Index + 1, where index is current (this should automatically get prefilled). Precision 1, no group separator.
  1. In User table
  • Number column name “Question/Selected”. Precision 1, no group separator.
  • Roll the Dice column name “Dice”. For the Roll Seed pick Current Time, for number of sides you can pick as many as the amount of questions you want your students to pick from. Precision 1, no group separator. At the moment I can’t figure out the logic how you can pick the mid-range of questions, only from the first one.
  1. Layout
  • create a collection with questions and show this component when the column “Question/Selected” is empty.
  • duplicate that collection and show it when “Question/Selected” is not empty. We reconfigure this component with the following: Add filter where math column “Dice #” equals User Profile > “Question/Selected”.
  • Add a button component and configure action to it: Name “Pick a Question”, instead of “show notification” pick “set column values” and for the “Question/Selected” pick “Dice”.
  • Probably can set up an additional button to reset where you will just clear the “Question/Selected” value.

All names are just for the ease of explanation and you can rename as you wish. This flow will explain the basic functionality of what you are planning to build and can be expanded from here.

Good Luck! Hope this helps!

2 Likes

Thanks very much - I have followed your advice and it works perfectly. Paul

1 Like

Thanks Nataliya. Actually I first tried dan’s suggestion and it worked fine - so I am using that now - but I have also noted yours and will try it to develop my proficiency.
Thanks for your help. Paul

1 Like