Skip to content

Please update your browser

Your browser version is not supported by this site. CS First may not work properly. Learn more

4. Reveal the Results

  • 1. Best Quiz Ever Introduction
  • 2. Create Quiz Content
  • 3. Changing Costumes When Clicked
  • 4. Reveal the Results
  • 5. Display the Introduction Screen
  • 6. Add-Ons
  • 7. Reflection
  • 8. Wrap-up: Best Quiz Ever
  • 9. Wrap-up: Share Your Project
  • 10. Wrap-up: Show Your Project
arrow_backward Back Next arrow_forward
Transcript

Now that your quiz taker can select quiz options, the program needs to tell them whether they are most like outcome 1 or outcome 2.

In this video, you will make the quiz keep track of which option the user clicked more and reveal the results by showing the appropriate backdrop.

In this example, the outcome 1 sprite is clicked twice, and outcome 2 once.

The program displays the outcome 1 backdrop to reveal the quiz results.

To begin, track how often each sprite is clicked with a variable.

Select the “outcome 1” sprite, click data, and choose “make a variable.”

Name the variable “outcome 1 clicks,” and select OK.

Doing this adds new “variable” blocks to the data menu.

Drag a “Change outcome 1 clicks by 1” block under the “when this sprite clicked event”.

To see the value of “outcome 1 clicks,” click the checkbox next to the variable.

You should see a variable display on the stage.

Right now, the value is 0 because the sprite hasn’t been clicked.

Click the flag, then the outcome 1 sprite.

Each time this sprite is clicked, the computer stores that count in the “outcome 1” variable.

Next, program the variable to reset its value to 0 when the quiz starts.

The variable should reset when the flag is clicked, so add a “set outcome 1 clicks to 0” block under the “flag clicked” event.

Try it out again.

OK great.

The clicks reset to 0 at the start of the program.

Now that “outcome 1 clicks” are counted, do the same for outcome 2.

Click the outcome 2 sprite and the data menu, and choose “make a variable.”

Name it “outcome 2 Clicks.”

Drag a “change outcome 2 clicks by 1” block after the “when this sprite clicked” event.

Drag a “set outcome 2 clicks to 0” block under the “when flag clicked” block.

OK, try it out.

Excellent.

Both sprites store the click count in a variable.

Now, if the quiz taker has gotten to the fourth costume, which is blank, then the backdrop should switch depending on which sprite was clicked more.

To check if the quiz is at the fourth costume, add an “if” block after the “next costume" block.

Choose an “equals” operator from the operators menu.

If the costume number equals 4, then the backdrop should change.

Click looks, and drag a “costume #” variable into the operator.

Then, enter a 4 in the other side.

This now reads, “If the costume equals number 4... then.”

To test this, add a “switch backdrop to outcome 1” block.

Run the program, and see if the backdrop changes after the first three questions are answered.

Great!

It does.

Next, make the quiz switch back to the question screen.

Add a “switch backdrop to question screen” block at the start of the program, and click the green flag to reset it.

Awesome.

You can now change the backdrop after three questions, but the backdrop change should match the sprite that received the most clicks .

To do this, use an operator.

Add an “if/else” statement inside the “if” statement you already programmed.

Then, select operators, and drag a “greater than” operator into the condition portion of the if/else.

Next, click data, and drag the “outcome 1 clicks” and "outcome 2 clicks" variables into either side of the condition.

If outcome 1 clicks is greater than outcome 2 clicks, then the program should switch the backdrop to outcome 1.

Drag the “switch backdrop to outcome 1” block into the “if” portion of the conditional.

Otherwise, or else, the program should switch the backdrop to outcome 2.

Click looks and drag a “switch backdrop to outcome 2” block into the else section.

Try it out by taking the quiz!

Great, now the backdrop changes to show the outcome of the quiz.

In the final step, you’ll program the title screen to appear, then to switch to the question screen.

Now it’s your turn!

Create “outcome 1 clicks” and “outcome 2 clicks” variables.

Program the variables to change by 1 after each sprite is clicked, and set the variables to 0 at the start of the program.

Next, check if the costume = 4 after the outcome 1 sprite’s costume changes.

Then, If outcome 1 clicks is greater than outcome 2 clicks, switch to the outcome 1 backdrop.

Else, or otherwise, switch to the outcome 2 backdrop.

Finally, Set the backdrop to the question screen when the flag is clicked.

Instructions
  1. Create a variable for both outcome sprites.
  2. Program the variable to change and reset.
  3. Reveal the results to the user.
  4. Program the quiz to reset.