Show a hint after two wrong tries
Variables and logic

Show a hint after two wrong tries

Count a student's wrong answers in a number variable, then let a hint appear on its own once they've missed twice, so students try first and get help only when they need it.

Level
Intermediate
Time
About 15 min
Steps
7
What you'll build

An "Oceans of the world" question that counts every wrong answer and shows a hint the moment a student misses for the second time, with no button to press.

Ready-made lesson

Get the finished lesson

Skip straight to the result, or keep it open beside the steps. Add this tutorial's lesson to your account and explore how it works in the studio.

A hint that's always on screen gives the answer away before students have had a chance to think. A hint behind a button helps, but some students never press it, and others press it straight away. A third option often works better: the lesson waits, and offers the hint only once a student has missed twice.

In this tutorial you'll build that for one question, "Which ocean is the largest?". Three pieces do the work:

  • a number variable called wrong_tries, which starts at 0,
  • an On Wrong Selected behavior on the question, which adds 1 to wrong_tries every time a student picks a wrong answer, and
  • a Conditional visibility rule on the hint, which shows it when wrong_tries is at least 2.

This builds on Remember a student's choice and use it later, where a variable holds a word. Here it holds a number that counts up. If you haven't used the studio before, start with Build your first quiz question.

Step 1: Set up the question

Start a blank lesson (New lesson, then Start from scratch) and name it Oceans of the world by clicking Untitled lesson at the top.

With nothing selected, open Background, click Choose a style, pick Nature, then Ocean horizon. If the sun lands where your question will go, click Randomize composition until it sits off to one side, then click Apply background. Give the Closing Scene the same background, so the ending matches. Creative Backgrounds covers the gallery in more detail.

Back on the Opening Scene:

  1. Add a Heading that says Which ocean is the largest? and drag it to the top.
  2. Add a Multi Choice question. Click ⚙ Configure and type the four answers: Atlantic, Indian, Pacific, Arctic.
  3. Mark Pacific correct. A new question starts with its first answer marked correct, so if Atlantic is still marked, click its mark to clear it. Then click Save.
  4. Rename the question Ocean question (click its name at the top of the properties panel), set its Font Size to 32 in Style & Layout, and drag it under the heading.
The Opening Scene with an ocean-horizon background: the heading Which ocean is the largest? above four answers, Atlantic, Indian, Pacific and Arctic, with Pacific outlined in green as the correct answer
Green marks the right answer. Students don't see the colors.

Leave the scene's Progression on Next. A right answer moves the student on to the ending straight away, and a wrong answer keeps them on the question to try again, which is what gives the hint a chance to help.

Step 2: Create a variable that counts

A variable is a named place where the lesson keeps a value while a student works. This one holds a number: how many wrong answers the student has picked so far.

A number variable, starting at 0.
  1. Click ⋯ (More lesson options) at the top right of the studio and choose Variables.
  2. Click New variable, then A number.
  3. Leave What number should it start as? at 0. Every student starts with no wrong answers.
  4. Under What is this variable called?, type wrong_tries.
The New variable form: the starting number 0, the name wrong_tries, and a note saying it's saved as wrong_tries and used in text as {{wrong_tries}}
Short names with underscores are easiest to find later.

Click Create variable, then close the window with Close.

Step 3: Add 1 for every wrong answer

Now tell the question to count. A Multiple Choice question has a trigger called On Wrong Selected, which runs each time a student picks a wrong answer.

One behavior, one action.

Click the question to select it, and open Behaviors in the properties panel:

  1. Click Add Behavior and choose On Wrong Selected. A new behavior starts with a Display Message action.
  2. Change Display Message to Increment Variable.
  3. In the variable list, pick wrong_tries · Number.
  4. Leave the amount at 1.
The question's Behaviors section: On Wrong Selected, with an Increment Variable action that adds the static value 1 to wrong_tries
Every wrong pick adds 1 to wrong_tries.

On Wrong Selected counts each _different_ wrong answer. If a student picks Atlantic, then Indian, wrong_tries goes to 2. Tapping Atlantic again after that isn't a new pick, so it doesn't count twice. That's usually what you want: the hint comes after two real guesses, not two taps on the same one.

Step 4: Write the hint

Click an empty spot on the scene to deselect the question, then add a Body text and type:

Hint: This ocean lies between Asia and the Americas. It is bigger than all of Earth's land put together.

Make it look like a sticky note, so students notice it when it appears:

  1. Rename it Hint, so it's easy to find in lists.
  2. In Style & Layout, choose Fixed width and set Width to 720, so the hint wraps onto two lines instead of running off the scene. (A new text box is Auto width and has no Width field until you pick Fixed width.)
  3. Set Font Size to 24.
  4. Click Background Color and pick the soft yellow swatch.
  5. Drag it below the question.
The hint text selected under the question: a soft yellow box reading Hint: This ocean lies between Asia and the Americas. It is bigger than all of Earth's land put together. Style & Layout shows Fixed width, Width 720, Font Size 24 and Background Color FDE68A
A yellow background makes the hint stand out when it appears.

A good hint points the way without giving the answer. This one names where the ocean is and how big it is, so a student still has to make the connection to "Pacific".

Step 5: Show the hint only after two wrong tries

Right now the hint is always on screen. A Conditional visibility rule hides it until a condition is true.

Show the hint when wrong_tries is at least 2.

With the hint still selected, open Visibility:

  1. Change Mode to Conditional. Behavior is already Show, which means "show this when the condition is true, and hide it otherwise".
  2. In the first condition list, pick Variable: wrong_tries · Number. It's near the bottom of the list, after the widgets.
  3. Change the comparison to is at least.
  4. The next list says what kind of value you're comparing to. It starts as Text, even though wrong_tries is a number, so change it to Number.
  5. Type 2 in the value box.
The hint's Visibility section: Mode Conditional, Behavior Show, All conditions are met, with the condition Variable: wrong_tries, is at least, Number, 2. On the canvas the hint has a small Shown by rule tag
The Shown by rule tag on the canvas means a rule decides when students see it.

Don't skip the Number step. Compared as text, wrong_tries would never count as "at least" anything, and the hint would never appear.

The hint stays visible on your canvas so you can keep editing it. The small Shown by rule tag above it is your reminder that students only see it when the rule is true.

Why 2? One wrong answer is often a slip. Two in a row usually means the student is stuck. For a harder question you might show the hint after one miss. Change the 2 and nothing else needs to change.

Step 6: Let students finish early

Berdee needs a way for students to finish the lesson early before it will publish, and the yellow pill at the top says 1 validation issue until you add one. Click an empty spot on the scene, add a Submit Button, and in Content set its Label to I'm done and Submits to Lesson. Set its Font Size to 16 and tuck it into the bottom-left corner.

The finished scene: the question, the yellow hint with its Shown by rule tag, and a small I'm done button in the bottom-left corner. The validation pill is gone
Ready to try.

Step 7: Try it as a student

Click Preview. Answer wrong twice, then right:

One miss, then a second, then the hint.

The answers are shuffled for each student (Randomize Order is on by default), so they may not be in the order you typed them.

  1. Pick Atlantic. It's wrong, and nothing else happens yet: one wrong answer isn't enough for the hint.
In preview, Atlantic is selected and there is no hint on the scene
One wrong answer. No hint yet.
  1. Pick Indian. That's the second wrong answer, and the hint appears straight away.
In preview, Indian is selected and the yellow hint is now showing under the question
The second wrong answer brings up the hint.
  1. Pick Pacific. It's right, so the lesson moves on to the ending.
The preview's Closing Scene: You finished the lesson! and Your score: 1 / 1 over the ocean background
A right answer goes straight to the ending.

To see the count yourself, click Show debug tools at the side of the preview and open the Variables tab. wrong_tries shows how many wrong answers this run recorded. Click Restart to try again from 0.

The preview's debug tools on the Variables tab, showing wrong_tries with the value 2
Debug tools show every variable's current value. Students never see them.

Notice that the score is still 1 out of 1, even though the student missed twice. The default Next progression only moves on after a right answer, so every student who reaches the ending through the question got it right in the end. If you want wrong tries to cost points, see Make some questions count more, and one not at all, which lets a wrong answer stick.

What you built

A question that offers help only when a student needs it:

  • a number variable, wrong_tries, starting at 0,
  • an On Wrong Selected behavior on the question that runs Increment Variable to add 1 for every wrong answer, and
  • a hint with a Conditional visibility rule, Show when wrong_tries is at least 2, plus a small I'm done button so the lesson can publish.

The same counter works for more than hints. Show an "Ask your teacher" note at 3, or put the count in text with {{ wrong_tries }}. With several questions on one lesson, remember that a variable belongs to the whole lesson: add a Set Variable action that puts wrong_tries back to 0 on the button that starts each new question, or give each question its own counter. Variables and Visibility and Personalization cover both.

Take it with you

Make this lesson yours

Add the lesson you just watched being built to your account, then change it for your class: your questions, your pictures, your colors.

Was this tutorial helpful?

Next tutorial