cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Marna2022
Frequent Visitor

Excel data base for a quiz. Make each row a individual question

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? 

Marna2022_1-1669043542388.png

 

Thank you !

 

1 ACCEPTED SOLUTION

Accepted Solutions
BCBuizer
Super User
Super User

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:

 

BCBuizer_0-1669136587599.png

 

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.



Did you like my post? Please give it a thumbs up! Did I resolve your issue? Please click Accept as Solution to close the topic and so other members of the community can find solutions more easily.

View solution in original post

4 REPLIES 4
BCBuizer
Super User
Super User

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.

 

 



Did you like my post? Please give it a thumbs up! Did I resolve your issue? Please click Accept as Solution to close the topic and so other members of the community can find solutions more easily.

@BCBuizer 

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

Marna2022_1-1669133688510.png

 

Also, I did a variable as you recommended, 

 

Button Next:

On select property: Set(varQuestion,Question1)

Marna2022_3-1669133828503.png

 

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,

 

BCBuizer
Super User
Super User

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:

 

BCBuizer_0-1669136587599.png

 

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.



Did you like my post? Please give it a thumbs up! Did I resolve your issue? Please click Accept as Solution to close the topic and so other members of the community can find solutions more easily.

@BCBuizer 

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!!

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (6,764)