Hello community ! 🙂
I'm doing an App for a quiz.
Facts:
- I have an excel table of 300 rows with questions, 4 possible answers and the correct answer
- I created a gallery, use filter, shuffle, firstN and limited the questions to 25.
- Each time I refresh I need to get 25 new question from the table
Problem?
I don't want to scroll down and answer all questions and press finish.
I want to get question by question. For example, I answer question 1, press a button "next" and go to question 2.
This will allow me to score and show the result question by question.
I don't know if gallery is a the right tool to do this or if I need to proceed differently?
Thank you !
Solved! Go to Solution.
Hi @Marna2022 ,
If you add something like this to the OnStart property of the app, a collection will be generated with 25 random questions and a variable will be initiated:
ForAll(
Sequence(
25,
1
),
Collect(
colQuestions,
Index(
Shuffle(
AddColumns(
Questions,
"Response",
""
)
),
ThisRecord.Value
)
)
);
Set(
gblQuestionsIndex,
1
)
In a single screen you can then add controls to navigate through the questions:
In the above I set the below properties:
Arrow1.OnSelect: Patch(colQuestions,Index(colQuestions,gblQuestionsIndex),{Response: Radio2.Selected.Value}); Set(gblQuestionsIndex,gblQuestionsIndex+1)
Arrow1.DisplayMode: If(gblQuestionsIndex<25,DisplayMode.Edit,DisplayMode.Disabled)
Arrow2.OnSelect: Patch(colQuestions,Index(colQuestions,gblQuestionsIndex),{Response: Radio2.Selected.Value}); Set(gblQuestionsIndex,gblQuestionsIndex-1)
Arrow2.DisplayMode: If(gblQuestionsIndex>1,DisplayMode.Edit,DisplayMode.Disabled)
Radio2.Items: Index(colQuestions,gblQuestionsIndex).Answers
Radio2.Default: Index(colQuestions,gblQuestionsIndex).Response
Label8.Text: Index(colQuestions,gblQuestionsIndex).Question
This makes the Label show the question, the Radio show the possible answers and in case a an answer is selected, it is saved in the collection. When pressing the arrows, the user can navigate back and forth between the questions.
Hope this helps.
Hi @Marna2022 ,
I would probably generate a collection of questions in the App's OnStart property and use a form or individual controls to display the current question. Using a variable, initiated at a value of 1, you can navigate through the questions, using the Index function.
Let's say you are using a form, you can select a question by setting the Item property to:
Index(colQuestions, varSelectedQuestion)
The variable can then be incremented as a result of the OnSelect property of the "Next" button and decreased for the "Previous" button.
Hi! Thank you for your answer.
I have been watching videos all morning trying to understand all what you explained in the solution. I created a collection with my "questions" database. However, I'm not sure how to use it.
But I kept going:)
I'm stuck in this part:
1- I managed to get a question using label and the table directly from excel.
The name of the label is "Question1"
Text property: First(Shuffle(Questions)).Question
Also, I did a variable as you recommended,
Button Next:
On select property: Set(varQuestion,Question1)
And now, I don't know what to do. Navigate to another screen and add a second question?
Should I do 25 screens? or there is a more elegant way?
If you can give me just an idea, it would be highly appreciate it 🙂
Best regards,
Hi @Marna2022 ,
If you add something like this to the OnStart property of the app, a collection will be generated with 25 random questions and a variable will be initiated:
ForAll(
Sequence(
25,
1
),
Collect(
colQuestions,
Index(
Shuffle(
AddColumns(
Questions,
"Response",
""
)
),
ThisRecord.Value
)
)
);
Set(
gblQuestionsIndex,
1
)
In a single screen you can then add controls to navigate through the questions:
In the above I set the below properties:
Arrow1.OnSelect: Patch(colQuestions,Index(colQuestions,gblQuestionsIndex),{Response: Radio2.Selected.Value}); Set(gblQuestionsIndex,gblQuestionsIndex+1)
Arrow1.DisplayMode: If(gblQuestionsIndex<25,DisplayMode.Edit,DisplayMode.Disabled)
Arrow2.OnSelect: Patch(colQuestions,Index(colQuestions,gblQuestionsIndex),{Response: Radio2.Selected.Value}); Set(gblQuestionsIndex,gblQuestionsIndex-1)
Arrow2.DisplayMode: If(gblQuestionsIndex>1,DisplayMode.Edit,DisplayMode.Disabled)
Radio2.Items: Index(colQuestions,gblQuestionsIndex).Answers
Radio2.Default: Index(colQuestions,gblQuestionsIndex).Response
Label8.Text: Index(colQuestions,gblQuestionsIndex).Question
This makes the Label show the question, the Radio show the possible answers and in case a an answer is selected, it is saved in the collection. When pressing the arrows, the user can navigate back and forth between the questions.
Hope this helps.
Thank youuu!! It worked!!
Finally I can keep going!
I tried and had to do some modifications, and probably will spent part of my afternoon understanding why Onstart property! but thank you! 😄 😄
Have a great day!!
User | Count |
---|---|
262 | |
110 | |
92 | |
54 | |
43 |