← Teacher guide

A values journal

Students build a three-screen journal: choose a value, describe what they did, and see every entry in a list. A global variable (Chosen) carries the choice between layouts, an Array (Journal) stores entries with Push, and screen 3 rebuilds a List from the array with Repeat and loopindex in a separate event from Clear.

Construct apps · Screens and lists · about 75 minutes · Open the student lesson

Classroom resources

Open these in Waypoints Prepare with one click. To share a file another way, copy its address and paste it into Load URL, or download the file and import it. In Prepare, the worksheet's Teacher edition shows the answers; the student copy hides them.

Students will be able to

Timing

Predict 3 min · Build it 40 min · Investigate 12 min · Modify 5 min · Make 15 min

Before class

The values are examples. Use your school's own values if it has them, or let students choose four that matter to them. Entries are personal: students keep the app on their own device and nothing is collected or shared. Keep any class discussion on made-up entries.

Check before class: the Array's Global property. If the array isn't kept between layouts, entries pushed on screen 2 won't be there on screen 3. Step 4 tells students to make sure Global is ticked; confirm the property name in the current editor.

When a layout is added, Construct usually offers to add an event sheet too. If a student has extra or missing sheets, click an empty part of each layout and set its Event sheet property.

Step 12 and 13 must be two separate events. If Clear sits in the same event as the Repeat, it runs on every repeat and only the last entry is left (the Investigate bug).

The journal forgets everything when the preview closes. That's fine for a prototype; saving between sessions (Local Storage) is a stretch.

These steps were written fresh for this site and have not yet been checked click by click in the current editor. Run through them once before class.

Running the lesson

  1. Predict: ask what 'global' might mean before the reveal.
  2. Build it: checkpoint after step 10: does screen 2 show the chosen value? Fix that before arrays.
  3. Investigate: write loopindex 0, 1, 2 under three entries on the board, and point to At(0), At(1), At(2).
  4. Make: pair students from different tables, so the tester hasn't seen the app built.

In class

On the slides at these points. Students can do the whole lesson on their own; these are for the room. In the deck, the Run, Modify and Make slides have the live playground in them (the tutorial link is the backup), and the notes above are in each slide's speaker notes.

The hard part (on purpose)

This is the longest build in the course, and the most common failure is a layout using the wrong event sheet, so nothing on that screen happens. Check each layout's Event sheet property before anyone debugs further.

When students get stuck

What you will seeA question to askThe fix
A screen's buttons do nothing.Which event sheet does this layout use?Click empty space on the layout and set its Event sheet property to the sheet with its events.
Screen 3's list is empty.Is the Journal array Global, and does the Push run before Go to layout?Tick Global on the array, and keep Push above Go to layout in AddButton's event.
Only the last entry shows.Are Clear and Add item in the same event?Move Clear into its own On start of layout event above the Repeat event.

Answers to the checks

  1. does the choice survive?: On screen 1 you click Courage. Its event sets the global variable Chosen to "Courage", then goes to screen 2. Screen 2's On start of layout sets its question to "What did you do to show " & Chosen & "?". What does the question say?
    It says Courage. A global variable belongs to the whole app, not one screen, so it keeps its value when the app goes to another layout.
  2. Try the finished app: Add two entries with different values. Watch Chosen and Journal.Width under the event sheet.

    Chosen keeps its value from screen 1 to screen 2, and Journal.Width goes up by one with each entry.
  3. Count with loopindex: The journal has 3 entries, so Journal.Width is 3. The Repeat runs 3 times. What is loopindex each time?
    0, then 1, then 2
    loopindex starts at 0 and goes up by 1 each time round, so 3 repeats give 0, 1, 2. The first entry is Journal.At(0), so each repeat adds the next entry to the list.
  4. Find Nib's mistake: Nib's journal only ever shows the latest entry. Click the line where Nib first goes wrong.
    line 2
    Line 2: Clear is in the same event as the Repeat, so it runs on every repeat. Each time round the list is cleared, then one entry is added, so only the last one is left. Clear belongs in its own On start of layout event.
  5. Why global?: What if Chosen were an instance variable on a button in screen 1, not a global variable?
    Screen 2 couldn't read it
    When the app goes to Layout 2, screen 1's objects (and their variables) aren't there. A global variable belongs to the whole app, so every screen can read it.
  6. Choose the expression: Screen 3 should say "You've added 5 moments". Which expression gives the 5?
    Journal.Width
    The array grows by one each time you push an entry, so its Width is the number of entries.

Stretch and support

Stretch: Save the journal between sessions with the Local Storage object (Array AsJSON and Load), or show the newest entry first.

Support: Build screens 1 and 2 as a class first, then let students build screen 3 in pairs.

Exit ticket

A shopping app has a Cart screen and a Pay screen. The Cart screen sets a variable Total to 25. How can the Pay screen show $25?

Make Total a global variable; it keeps its value when the app goes to the Pay layout, so the Pay screen can set its text from it.

What each step is for

Where it leads

Next: Creature stats, where one object has many copies, each with its own values.