💻 TechnologyGrade 6Lesson 30
← Back🔒 PDF with full access

Code a quiz or interactive story

Lesson preview: the Mini Lesson and Vocabulary are open to everyone. Guided practice, exercises, the parent checklist and the printable PDF worksheet come with full access (free 7-day trial or membership).

Learning Objectives

  • 1Plan an interactive story with an opening scene, two choices, and an outcome for each branch
  • 2Match each story choice to the outcome it should lead to
  • 3Use variables, events, and conditions to score a quiz and follow a story branch
  • 4Test the quiz or story and rewrite any branch that confuses the player
📘

Mini Lesson

A quiz asks the player a question, checks their answer, and updates a score. An interactive story tells a scene, asks the player to choose, and then jumps to a different scene depending on the choice. Both are built from the same parts: text on screen, a choice the player makes, a condition that checks the choice, and a variable that remembers what happened so far. Plan every branch on paper first, then code one screen at a time.

The Branching Script Frame

  1. Opening scene — set the place, the character, and the problem in one or two sentences.
  2. Choice A — the first thing the player can decide to do.
  3. Outcome A — what happens, in detail, after the player picks Choice A.
  4. Choice B — the other thing the player can decide to do.
  5. Outcome B — what happens, in detail, after the player picks Choice B.
  6. Ending — how the story closes (or which branch it loops back to).

How a Quiz Works

  • A variable called score starts at 0.
  • Each question is shown one at a time, with four options labeled A, B, C, D.
  • When the player taps an option, an event fires.
  • A condition checks: was that the right answer? If yes, score = score + 1.
  • After the last question, the program shows the final score and a message.

How an Interactive Story Works

  • Each scene is one screen of text plus two or three buttons.
  • When the player taps a button, an event fires and the program jumps to the next scene.
  • The next scene depends on the choice — that is the BRANCH.
  • A variable can remember things across scenes (did the player open the door, take the sword, talk to the dragon).
  • Endings are reached when no more buttons are shown — the story is over.
A two-branch story

You write: "You stand in a dark forest. A path leads left and a path leads right." What four parts of the script frame do you need to plan?

Answer:Choice A (take the left path) with Outcome A (you reach a village). Choice B (take the right path) with Outcome B (you meet a wolf). Both outcomes need their own ending sentence — or another choice that branches further.

Every choice ALWAYS pairs with its own outcome. If you write Choice A but forget Outcome A, the program has nowhere to go. The branching script frame forces you to write both halves before you start coding.

Test, Tune, Repeat

  • Play every branch yourself — pick A every time, then play again and pick B every time.
  • Watch a friend play. If they freeze on a choice, the wording is unclear.
  • Make sure no choice leads to a dead end with no buttons unless you mean it as an ending.
  • For a quiz, double-check every right answer in your code matches the question.
  • For a story, read every outcome aloud — does it follow naturally from the choice?
Branching Story TreeBranching Story TreeScene - choice - outcomeOpening Sceneyou stand at a doorChoice A: openChoice B: leaveOutcome Afind treasureOutcome Bmiss the prizePlan both branches before you code.
Quiz Card MockupQuiz Card MockupQuestion - options - scoreQuestion 1 of 5Score: 0Which planet is closest to the Sun?AMercuryBVenusCEarthDMarsSubmit AnswerEach click checks the answer and updates score.
💡

Tip: write every choice and every outcome on paper FIRST. If you can’t finish the sentence "if the player picks A, then ___", your branch is broken before you ever open the editor.

Vocabulary
quiz
A program that asks questions, checks answers, and tracks a score.
interactive story
A story where the player chooses what happens next.
branch
A path the story takes after a choice is made.
choice
A button or option the player picks to move the story forward.
outcome
What happens after a choice is made.
opening scene
The first screen that sets the place, character, and problem.
ending
The screen with no more buttons — the story is over.
score variable
A named box that adds up the right answers in a quiz.
event
Something the program watches for, like a button click.
condition
An if-question that picks which branch to follow next.
Free · 7 days · No credit card

Unlock the full HSEA system for 7 days.

Add your first kid profile and your 7 days start: every lesson in every grade, saved progress for each child. Nothing to set up, no card required, nothing to cancel.

  • ✓ All 1,680 lessons, Grades 1–6, every subject
  • ✓ Profiles + saved progress for every kid
  • ✓ Printable lessons with answer key
Start your 7-day free trial →
← Lesson 29: Sensors, robots or micro:bit introLesson 31: Refactor and Improve Code →