← Teacher guide

One table instead

Students rebuild the playlist as a table: Songs, with the fields title, artist and length (a number field), made in App Builder's sidebar spreadsheet. A Table object shows it; Add a row takes one value per field; clicking a row removes it with Remove row ClickedIndex. The Check traces row numbers after a removal and asks why a table can't split a song.

Data apps · Tables and records · 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–4 30 min · Check 8 min · Make it yours 15 min

Before class

Tables are an App Builder Level 4 feature; these lessons open App Builder at Level 4.

A table is a list of records: each row is one record, each column a field. Field types matter: length is a number so it can be added up (next lesson) and sorted by size (lesson 5). int(LengthInput.text) turns the typed text into a number; a number field also accepts text that is a number.

Removing a row renumbers the rows below it, as a list does.

Running the lesson

  1. Before Build 1 (whole class): draw the two lists from last lesson, then redraw them as one table. What's the same, what's better?
  2. Build 1: checkpoint: everyone's Songs table has three fields and length shows 123 (number).
  3. Check: act it out: three students hold cards for three rows; remove the middle one, and the third steps up.

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)

Making the table: rename the first field, add fields, change length to Number. The sidebar is narrow; the field's own menu (click its name) does rename, type and delete.

When students get stuck

What you will seeA question to askThe fix
The Table object says Choose a table in Properties.Which table does SongTable show?Click SongTable on the Design tab and set Shows table to Songs.
Add a row shows a box for name, not title.Did the first field get renamed?Click the field's name in the sidebar, Rename, and call it title; the action's boxes follow.
A message says length holds numbers.What was typed in the Minutes box?Type a number such as 4, or use int(LengthInput.text).

Answers to the checks

  1. Which song is row 2?: Songs has three rows: Blue Sky, Arc, Cove. Row 2 is removed. What is item(Songs, 2).title now?
    Cove
    The rows below the removed one move up, so Cove is row 2 now. item(Songs, 2) is the whole row, and .title is one field of it.
  2. Can they get out of step?: In the table, can removing a song leave the wrong artist beside a title, as in the two lists?
    No: each row holds its own title and artist, so they move together
    A row is one record. Removing a row removes all its fields at once, so a title can't lose its artist.

Solutions

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

Make it yours: a genre field › Add a genre

{"version":1,"name":"Playlist table","device":"web","features":{"level":4},"variables":[{"name":"Songs","table":{"fields":[{"name":"title","type":"text"},{"name":"artist","type":"text"},{"name":"length","type":"number"},{"name":"genre","type":"text"}]},"value":[{"title":"Blue Sky","artist":"Kai","length":3,"genre":""},{"title":"Arc","artist":"Mo","length":5,"genre":""}]}],"screens":[{"id":"home","name":"Home","objects":[{"name":"Title","kind":"text","instanceVars":[],"instances":[{"id":"h1","x":24,"y":16,"w":500,"h":40,"text":"My playlist","visible":true,"vars":{}}]},{"name":"TitleLabel","kind":"text","instanceVars":[],"instances":[{"id":"l1","x":24,"y":64,"w":60,"h":36,"text":"Title","visible":true,"vars":{}}]},{"name":"TitleInput","kind":"input","instanceVars":[],"instances":[{"id":"i1","x":84,"y":60,"w":170,"h":42,"text":"","visible":true,"vars":{}}]},{"name":"ArtistLabel","kind":"text","instanceVars":[],"instances":[{"id":"l2","x":268,"y":64,"w":60,"h":36,"text":"Artist","visible":true,"vars":{}}]},{"name":"ArtistInput","kind":"input","instanceVars":[],"instances":[{"id":"i2","x":328,"y":60,"w":150,"h":42,"text":"","visible":true,"vars":{}}]},{"name":"LengthLabel","kind":"text","instanceVars":[],"instances":[{"id":"l3","x":492,"y":64,"w":70,"h":36,"text":"Minutes","visible":true,"vars":{}}]},{"name":"LengthInput","kind":"input","instanceVars":[],"instances":[{"id":"i3","x":566,"y":60,"w":70,"h":42,"text":"","visible":true,"vars":{}}]},{"name":"GenreLabel","kind":"text","instanceVars":[],"instances":[{"id":"l4","x":24,"y":108,"w":60,"h":36,"text":"Genre","visible":true,"vars":{}}]},{"name":"GenreInput","kind":"input","instanceVars":[],"instances":[{"id":"i4","x":84,"y":104,"w":170,"h":42,"text":"","visible":true,"vars":{}}]},{"name":"AddButton","kind":"button","instanceVars":[],"instances":[{"id":"b1","x":650,"y":58,"w":130,"h":46,"text":"Add song","visible":true,"vars":{}}]},{"name":"SongTable","kind":"table","instanceVars":[],"instances":[{"id":"T1","x":24,"y":160,"w":560,"h":280,"text":"","visible":true,"vars":{},"source":"Songs","columns":""}]},{"name":"Hint","kind":"text","instanceVars":[],"instances":[{"id":"t1","x":24,"y":450,"w":560,"h":30,"text":"Click a song to remove it.","visible":true,"vars":{}}]}],"events":[{"id":"e1","else":false,"conds":[{"type":"onClicked","target":"AddButton"}],"actions":[{"type":"tableAdd","table":"Songs","values":{"title":"TitleInput.text","artist":"ArtistInput.text","length":"int(LengthInput.text)","genre":"GenreInput.text"}}],"children":[]},{"id":"e2","else":false,"conds":[{"type":"onItemClicked","target":"SongTable"}],"actions":[{"type":"tableRemove","table":"Songs","index":"ClickedIndex"}],"children":[]}]}]}

Make it yours: a genre field › Test it with someone

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

Stretch and support

Stretch: Use Columns to show to hide length on the screen. Does the table still keep it?

Support: Make the table together on the projector; pairs build the events.

Exit ticket

A table Books has the fields title, author and pages. What does one row hold, and what does item(Books, 3).author give?

One row holds one book's title, author and pages. item(Books, 3).author is the author of the third book.

What each step is for

Where it leads

Next: Records and fields: read one field of a row, add up a column, find the longest song.