Let's start step by step implementation of screens.
In this screen, we will add a label (for the quiz) and button (to start the quiz) as below,
On the selection of the button, we will navigate to the question 1 screen. So we will write the formula on the OnSelect property as below,
Now we will add some controls for the all questions screens like labels for question number and question, the radio button for the options and button for the check answer, and store in some variable and move to the next screen. So let's see the implementation.
Question 1 Screen
The output screen will be like this,
We will write a formula on the OnSelect property of the Next button. Now we will set the score as if the answer is wrong then 0 and if right then 5 and then navigate to the Question2 screen.
- We will use if condition and in if condition we will get radio button selected value and will check with our answer and will set score = 5 if the answer is true; else will set to 0.
- then we will reset the radio button selected value
- and then will navigate to the next screen.
- If(
- Radio1.Selected.Value = ".stp",
- Set(
- Score,
- 5
- ),
- Set(
- Score,
- 0
- )
- );
- Reset(Radio1);
- Navigate(
- Question2,
- ScreenTransition.Fade
- )
Question2 Screen
The output screen will be like this,
- Here we will check if the answer is true then we will add 5 points to the existing score and then reset the radio and navigate to the next screen. We will do the same for screen questions 3 to 5.
Execute a formula on Onselect of Next button as below,
- If(
- Radio2.Selected.Value = "iisreset",
- Set(
- Score,
- Score + 5
- )
- );
- Reset(Radio2);
- Navigate(
- Question3,
- ScreenTransition.Fade
- )
Question 3 screen
The output screen will be like this,
Execute a formula on Onselect of Next button as below,
- If(
- Radio3.Selected.Value = "443",
- Set(
- Score,
- Score + 5
- )
- );
- Reset(Radio3);
- Navigate(
- Question4,
- ScreenTransition.Fade
- )
Question 4 screen
The output screen will be like this,
Execute a formula on Onselect of Next button as below,
- If(
- Radio4.Selected.Value = "All the above",
- Set(
- Score,
- Score + 5
- )
- );
- Reset(Radio4);
- Navigate(
- Question5,
- ScreenTransition.Fade
- )
Question 5 screen
The output screen will be like this,
Execute a formula on Onselect of Next button as below,
- If(
- Radio5.Selected.Value = "One",
- Set(
- Score,
- Score + 5
- )
- );
- Reset(Radio5);
- Navigate(
- ResultScreen,
- ScreenTransition.Fade
- )
Result screen
The controls inside the screen will be like this,
The output screen will be like this,
Now will execute a formula of Default property of the Rating control to show stars as per score as below,
- If(
- Score = 5,
- 1,
- If(
- Score = 10,
- 2,
- If(
- Score = 15,
- 3,
- If(
- Score = 20,
- 4,
- If(
- Score = 25,
- 5
- )
- )
- )
- )
- )
To show score we will set the Text property of Label as below,
After the quiz completion, we will navigate to the home screen so on the click of iconCheck so will execute the formula on the OnSelect property of this icon as below,
Output
You can find the full source code from the zip file.
Summary
In this article, we have seen step by step implementation of how to create a quiz/survey application in powerapps.
I hope this helps.
Sharing is caring.