← Teacher guide

A water tracker

Students build a water tracker with two variables (Glasses, Goal), an Every tick event that keeps the display up to date, Add and Reset buttons, and a cap. The cap is first built the way beginners often write it (Add 1 left on the AddButton event, the check in a sub-event), so it fails at the goal; students find why and move the action into the sub-event. The Make step adds a goal message with Else and a progress bar.

App Builder apps · Keep track · about 60 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

Try 5 min · Build 1–3 20 min · Check 8 min · Build 4 5 min · Make it yours 20 min

Before class

The cap in Build 2 is wrong on purpose: Add 1 stays on the parent AddButton event, so it runs on every click and the sub-event's condition (Glasses < Goal) controls nothing. The Investigate step finds it; the Modify step fixes it by deleting the action and adding it again inside the sub-event (App Builder has no drag between events; the ⋯ menu and + Action do it).

Every tick runs about 60 times a second. Setting text there is fine. Adding to a variable there is not (it would add 60 a second), which is why the exit question asks about it.

The Build step's tick boxes accept the slip on purpose (they check the cap as built); Build 4's tick only comes once Add 1 is inside the sub-event.

Pick any goal and thing to track if water doesn't suit your class (pages read, laps, minutes outside). The app is about counting towards a goal, not health advice.

Running the lesson

  1. Before Build 2 (whole class, on the deck): the Add event only adds 1, with no Set text. Does the count change? Compare with lesson 1.
  2. Build 3: everyone clicks 12 times before anyone explains.
  3. Check: draw the event and its sub-event on the board; circle which actions belong to which.
  4. Make it yours: work out one bar width together before students build it.

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)

The deliberate slip in Build 2 can feel like a trick. Say up front that the build includes one mistake beginners often make, and the class will find it together.

When students get stuck

What you will seeA question to askThe fix
The count shows the word Glasses or the & signs.Which parts are inside the quote marks?Only the words to show go in quotes; the variables and & go outside.
The bar doesn't move.Which event sets its width, and is it on BarFill?The Set BarFill width action goes in the Every tick event.
After the fix, Add does nothing.Where is the Add 1 action now?It should be inside the sub-event, beside Glasses < Goal, not deleted.

Answers to the checks

  1. What did you see?: You built the cap as in Build 2 and clicked Add 12 times, with a goal of 8. What did the screen say?
    Glasses: 12 of 8
    It went past the goal. The Add 1 action sits on the AddButton event, so it runs on every click. The sub-event's condition only controls actions inside the sub-event, and there are none.
  2. Find the slip: This is the cap you built. Click the line that lets the count pass the goal.
    line 2
    Line 2: the action is on the parent event, so it runs on every click. The sub-event's condition below it only controls actions inside the sub-event. Move Add 1 into the sub-event.
  3. Work out the width: The bar is a box 300 pixels wide when full. Glasses is 2 and Goal is 8. What width should the bar be?
    75
    2 of 8 is a quarter, and a quarter of 300 is 75. In App Builder: Glasses / Goal * 300.

Solutions

One possible solution for each task. Other correct programs are fine.

Make it yours: a message and a progress bar › Work out the width

Open task: any program that does what the step asks.

Make it yours: a message and a progress bar › Build it

{"version":1,"name":"Water tracker","features":{"level":2},"variables":[{"name":"Glasses","value":0},{"name":"Goal","value":8}],"screens":[{"id":"main","name":"Water","objects":[{"name":"GlassText","kind":"text","instanceVars":[],"instances":[{"id":"w1","x":229,"y":40,"w":342,"h":36,"text":"Glasses: 0 of 8","visible":true,"vars":{}}]},{"name":"AddButton","kind":"button","instanceVars":[],"instances":[{"id":"w2","x":229,"y":100,"w":342,"h":52,"text":"Add a glass","visible":true,"vars":{}}]},{"name":"ResetButton","kind":"button","instanceVars":[],"instances":[{"id":"w3","x":229,"y":170,"w":342,"h":46,"text":"Reset","visible":true,"vars":{}}]},{"name":"Message","kind":"text","instanceVars":[],"instances":[{"id":"m1","x":229,"y":240,"w":342,"h":32,"text":"","visible":true,"vars":{}}]},{"name":"BarBack","kind":"shape","instanceVars":[],"instances":[{"id":"m2","x":229,"y":290,"w":300,"h":24,"text":"","visible":true,"vars":{},"color":"#d5dae3"}]},{"name":"BarFill","kind":"shape","instanceVars":[],"instances":[{"id":"m3","x":229,"y":290,"w":300,"h":24,"text":"","visible":true,"vars":{},"color":"#2f8fdd"}]}],"events":[{"id":"w1","else":false,"conds":[{"type":"everyTick"}],"actions":[{"type":"setText","target":"GlassText","value":"\"Glasses: \" & Glasses & \" of \" & Goal"},{"type":"setSize","target":"BarFill","prop":"w","value":"Glasses / Goal * 300"}],"children":[]},{"id":"w2","else":false,"conds":[{"type":"onClicked","target":"AddButton"}],"actions":[],"children":[{"id":"w2a","else":false,"conds":[{"type":"compareVar","var":"Glasses","op":"<","value":"Goal"}],"actions":[{"type":"addTo","value":"1","var":"Glasses"}],"children":[]}]},{"id":"w3","else":false,"conds":[{"type":"onClicked","target":"ResetButton"}],"actions":[{"type":"setVar","var":"Glasses","value":"0"}],"children":[]},{"id":"w4","else":false,"conds":[{"type":"compareVar","var":"Glasses","op":"=","value":"Goal"}],"actions":[{"type":"setText","target":"Message","value":"\"Goal reached!\""}],"children":[]},{"id":"w5","else":true,"conds":[],"actions":[{"type":"setText","target":"Message","value":"\"Keep going\""}],"children":[]}]}],"device":"web"}

Stretch and support

Stretch: Let the user set their own goal with a text input and a Set goal button (int() from lesson 1).

Support: Give the finished Every tick event as a table and have students check theirs row by row.

Exit ticket

What goes wrong if you put "add 1 to Glasses" in the Every tick event?

It adds 1 about 60 times a second, so the count shoots up. Every tick is for keeping the display in step, not for changing the count.

What each step is for

Where it leads

Next: Values journal, with three screens, a choice that carries between them, and a list.