Scratch Tutorial: Quiz

Dan Beltran

Audience

Attendees

Number of facilitators

Level

Preparation

5 minutes

Activity

30 minutes

Description

This is a tutorial on how to create a simple quiz in Scratch.

Objectives

Understanding basic block programming

Worked skills

Block programming

Prerequisites for the audience

Reading, writing

Equipment

Computer with Scratch or internet connection

Content used

http://scratch.mit.edu

Introduction

The goal of this tutorial is to create a quiz involving multiple questions and answers. These will appear on the screen and the player will have to click the button corresponding to the right answer.

 

Choosing a backdrop

We will first create a backdrop.

Choose the backdrop in the bottom right of the creation screen.

Making the questions

To make a question, create a new sprite by hovering over the icon near the bottom right of the screen and then clicking on ‘Paint’.

 

The question will be one of the sprite’s costumes. Under the ‘costumes’ tab, click the T icon to add text. Then write a question and three possible responses (only one should be correct). Name the costume ‘Question 1’.

 

Add as many questions as you want by adding more costumes to the same sprite. To do this, stay under the ‘Costumes’ tab and go to the icon on the bottom left.

As before, write a question using the text tool and rename the costume.

 

Now you need to create two costumes – ‘true’ and ‘false’ – this time by using coloured text (so that true and false are different colours). In this example, the questions are black, true is green and false is red.

 

Animating the first question

Click on the sprite. Under the ‘Code’ tab, copy the below blocks. These will start the game with the right question and will stay there until someone chooses a, b or c.

 

 

Code explanation: when the green flag is clicked, the sprite changes to the costume ‘Question 1’ and so the first question appears. The script stops until the player press a, b or c on the keyboard.

Now the connection needs to be made between the key pressed and the right answer. Add the following blocks:

 

Code explanation: if the player press ‘a’ (the right answer in this example), the costume changes to ‘true’ and stays in this state for 1 second. If the player chooses either of the other 2 possibilities, the script changes the costume to ‘false’ and waits 1 second.

Integrate the code you have written so far to finish the first question.

 

 

Animating the second question

The code for the second question is identical to that of the first, except that this time the correct answer is b. The blocks to be used are as follows:

Add these the previous code and add the extra blocks so the second question is displayed, as follows:

 

Code explanation: after waiting 1 second, the computer will display the second question. It will wait for the player to choose 1, 2, or 3.

 

Going further

Some tips to improve the game:

  • Choose a theme and think about the kinds of questions to include
  • Add a point count which increases when the right answer is given
  • Find a way to indicate the correct response when the wrong one is given before moving on to the next question
  • Display a question count so the player knows how far they have progressed
  • With an audience familiar with Scratch, challenge them to improve the code used for the example. Here are a few hints: avoid block repetitions, execute the costume-related actions more efficiently, use messages.