Random repeating group in 4 rows only


Hoping someone can help me with this. I have an app where I am wanting to include a Quiz. I have a Data Type called ‘Learnings’ that has two fields in it, one called ‘Question’, One called ‘Answer’.

I then create 2 repeating groups, one where I just display a button “Current cells Learning Question”, this has a fixed number of cells, just the one to display one question.

I then have another repeating group which shows a button in each “Current cells Learning Answers”.

Then I create a condition so if the user clicks the button where the answer matches the question it goes green.

Everything works as it should but…I only want to display 4 possible answers, not the whole list of possible answers, one of the 4 MUST be the correct answer and the position in the 4 must be random (so that for the next question it’s not always position 1 etc). Is there any way this can be achieved without me having to create separate Data Types etc(The Data Types are used extensively for other parts of the app)?
Any help appreciated.

Hi… Where are you storing “Possible answers” and the real answers?

Every Data Type has a question and answer stored in the database. The 2nd repeating group just shows all the answers of which one will be the correct answer to the question being asked.

I’m sorry I still don’t understand it. There are 4 answers and one of them is correct. Where are the wrong answered stored :slight_smile:

The incorrect answers are the correct answers from other questions, it’s just a repeating group showing ‘Current cells learnings answer’, one of them will obviously be the correct one, this way I don’t have to create a separate list of incorrect answers. As an example the question may be ‘What’s the capital of England and the possible answers may be ‘Paris, Brussels, Dublin or London’. The next question may be ‘What’s the capital of Spain and I want it to display just four from the answers in the repeating group ensuring one of them is the correct answer. It all works if I show all the answers, I just want it to display only 4 which is also easy to do, the one thing missing is how can I ensure that when showing 4 answers one of them contains the answer to the question in repeating group 1. Hopefully that makes sense.

To recreate this:

  1. Create a new data type called Learnings with two fields called Question and Answer, both text.
  2. Populate the questions and answers with around 20 items all on the same subject.
  3. Setup a repeating group searching for Learnings. Have a text field showing ‘Current cells learnings question’ only show 1 question, sorted randomly.
  4. Setup another repeating group searching for Learnings. Have a button showing ‘Current cells learnings answer’ show full list, sorted randomly.
  5. Setup a condition and state so when the answer button is clicked it goes green if it is the correct answer to the question in the first repeating group.
  6. Create a Next button to select next question and update answer group.

All of the above works, the next step is where I need help.

Instead of the full list of answers in step 4 which may be 30 long in some cases I want to show just 4 of the list, however one of those MUST be the answer to the question shown in repeating group 1 and MUST be shown randomly in position 1-4, not always in position 1 as it will be too obvious for people to answer. Hopefully this helps.

This topic was automatically closed after 70 days. New replies are no longer allowed.