Build a simple quiz game using coding blocks
A quiz game, you say?
A quiz game is a perfect digital solutions project for students in Years 3-4. It’s a ton of fun to build, and it’s a great opportunity for students to get creative by writing their own questions and answers!
This project is great for teaching students how to:
- Design their own algorithms
- Create branching statements
- Use variables as a method of data storage for user input (we’ll explain what this means in due time!)
The framework for this project is very versatile, meaning that you can integrate it into any unit you like! Use it to make a quiz game about Australian Convict History, Ned Kelly or Biology and Living Things!
The overview of competencies for Digital Technologies in a Year 3-4 classroom.
Let’s get started!
Before we break down what’s involved in making a quiz game, let’s take a look at a sample of a quiz game that we made earlier.
Difficult though it may seem, building a quiz game in Scratch is actually very simple. You only need 6 blocks to build the whole project! Let’s get stuck into it, shall we?
What does the quiz game entail?
A quick brainstorm session
Before we go to our computer, we need to start with pencil and paper to plan the content of our game.
Write a list of 5 questions and answers for your chosen topic. Our recommendation is that you choose questions with indisputable, one-option answers.
Here are some questions that you could use for a geography quiz:
- “What is the capital city of Australia?” Answer: Canberra.
- “What is the capital city of Brazil?” Answer: Brasilia.
Having questions with one-option answers will reduce the amount of errors that you’ll need to fix, as well as troubleshooting that you’ll need to do, later on!
Writing pseudocode
Next, let’s write our pseudocode. Pseudocode means that we use plain English to write our algorithm. We can then translate this pseudocode into an actual computer language (in our case, Scratch) in order to build our digital solution.
- Start the program by clicking on the green flag
- Quizmaster says “Hello!” and welcomes us to the quiz game
- Quizmaster asks question 1
- User types their response into the input box.
- User input is stored in a variable called “answer”
- Check to see that the user’s response equates to the correct answer
- e.g. If a question asks, “What’s the capital of Australia”, we need to check that the correct answer (Canberra) and the user’s answer are the exact same.
- If correct, the quizmaster says “Well done. That’s correct.”
- If not correct, the quizmaster says, “I’m afraid that’s incorrect. The correct answer is Canberra.”
- e.g. If a question asks, “What’s the capital of Australia”, we need to check that the correct answer (Canberra) and the user’s answer are the exact same.
- Repeat steps 3-6 for as many questions as you like.
Write your pseudocode before your actual code!
What concepts does the quiz game teach?
There are a few new concepts that the quiz game introduces. (See if you can spot where they’re mentioned in the pseudocode above!)
User input
An input is a piece of information that is entered into a computer. User input refers specifically to information that a user enters into a computer.
In the context of our quiz game, the input box (see below) is one method of gathering user input.
The Quizmaster awaits our input via the input box.
The user can use a keyboard to feed information to the computer (“keyboard input”); in other words, they can type in “Canberra” and hit enter, and the computer accepts this as information. It will then deal with said information accordingly.
Variables
A variable is like a container. There are a few things that you need to know about variables:
- It can only store one piece of information at any given time.
- This single piece of stored information can be changed multiple times across the course of a program.
Let’s say that, at the beginning of our project, our variable is empty. In other words, it contains no information whatsoever. We want to use this variable to store the user’s answers to each of our questions, like so:
- The Quizmaster asks, “What is the capital city of Australia?” The user inputs the answer “Canberra”. We want to save this answer in a variable called “answer”.
- Later, when the Quizmaster asks for the capital of Brazil, the user may input “Brasilia”. Since a variable cannot hold more than one piece of information at a time, the pre-existing value “Canberra” is thus replaced by the input “Brasilia”.
At one point in time, our “answer” variable might contain the word “Canberra”. Later, it might be “Brasilia”!
We can continue to change what piece of information is stored in a variable, but don’t forget that you will only ever be able to store one piece of information at a time!
Branching and conditional statements
Branching essentially allows us to automate how our algorithm handles different types of information. It uses something called a conditional statement to categorise information and determine what to do with it.
These concepts might be a bit difficult to understand, so let’s look at how branching occurs in our project:
- Our conditional statement is: Is the user’s answer correct? (In other words, does the user input match the answer that we’ve defined?)
-
- Option A: If the user’s answer is correct, say, “That’s correct”
- Option B: If the user’s answer is incorrect, say, “I’m afraid that’s incorrect. The correct answer is X.”
Whether or not the user’s input is correct determines what the program says.
As you can see, the conditional statement helps us to determine whether a user’s input is “correct” or “incorrect”. If the user’s input is categorised as “correct”, then the computer will say to the user, “That’s correct!”. If the input is “incorrect”, then the computer will say to the user, “I’m afraid that’s incorrect…”
How do I expand upon the quiz game framework?
Once you have mastered the quiz game framework, there are many different ways in which you can expand upon it and make the project more challenging to build.
- Can you add a scoring system?
- Would you like to deduct points for incorrect scores?
- Would you like to add sounds effects, e.g. an applause, if the player achieves a score of 10?
- Would you like to add sounds effects, e.g. a gong sound, if the player gets the answer wrong?
- What else can you add to your quiz game project?
Tell me how to build a quiz game!
Want to build a simple quiz game in the ScratchJr app? Check out our video tutorial on how you can do this!