← Data apps

A journal with drawings

Give every journal entry its own drawing: a table Entries with a picture field, a row added for each entry, a Table on the Journal screen with a thumbnail per row, and a click to see one big. Remember it between visits, tidy away the old list, and hand it in as a file with the drawings inside.

A photo app keeps every photo with its date and place, not just the latest one. A table with a picture field does the same: one row per entry, and the picture is part of the row.

In App Builder apps, the values journal learnt to keep a drawing, but only the latest one: draw a heart, then a star, and the heart is gone. One variable holds one thing.

Today every entry keeps its own drawing, in a table:

value note drawing
Courage asked a question in class (a picture)
Kindness helped a friend (a picture)

A picture field holds a picture in each row, just as a text field holds text. The table shows it as a small thumbnail.

How this lesson works: See it, Build, Check, Make it yours
See itTry the finished thing first, so you know what you are building.

Try the finished app

Add two entries with different drawings. On the Journal screen, click each row: its drawing shows big underneath. Then press ↻ Restart: the entries are still there.

If you didn't do Draw how you showed it in App Builder apps, this is the same values journal: Choose a value, Describe it (with a drawing), see your Journal.

Try it yourselfYour edits are saved in this browser.

BuildWatch the short clip, then do the steps. Your app carries on from the step before.

Build 1: a table with a picture field

  1. On the left, under Tables, type Entries and click +.
  2. Click the field name, choose Rename, and call it value.
  3. Click + beside the fields to add note, then drawing.
  4. Click drawing and choose Picture. It shows 🖼 instead of abc.

No rows yet: the app will add them.

A picture field · Sound on for the voiceover
Try it yourselfYour edits are saved in this browser.

A table Entries with fields value, note and drawing (drawing set to Picture: it shows 🖼).

    Run your program. This ticks when your code does all of the above.

    BuildWatch the short clip, then do the steps. Your app carries on from the step before.

    Build 2: add a row for each entry

    1. Open the Describe screen's events. In AddButton is clicked, add an action before Go to screen: Tables, Add a row to Entries.
    2. Fill in its fields: value Chosen, note NoteInput.text, drawing Drawing.picture
    3. Run it and add an entry. Watch Entries on the left: a row appears, with a thumbnail.

    The old list and LastDrawing still work for now. You'll tidy them away once the table does their job.

    Try it yourselfYour edits are saved in this browser.

    When Add is clicked, a row is added to Entries with the value, the note and the drawing.

      Run your program. This ticks when your code does all of the above.

      BuildWatch the short clip, then do the steps. Your app carries on from the step before.

      Build 3: show the table, see one big

      1. Open the Journal screen. Click the List and delete it.
      2. + Add object, Table. Rename it EntriesTable, put it where the list was (x 229, y 110, width 342, height 210), and set Shows to Entries.
      3. In On start of screen, change the Count to "Entries: " & count(Entries) and delete Set LastImage picture to the one in LastDrawing.
      4. Add an event: EntriesTable, An item in EntriesTable is clicked → LastImage, Set LastImage picture to the one in ClickedItem.drawing
      5. Run it, add two entries, and click each row.
      A Table, and a click on a row · Sound on for the voiceover
      Try it yourselfYour edits are saved in this browser.

      The Journal shows Entries in a Table, counts Entries, and clicking a row shows that row's drawing in LastImage.

        Run your program. This ticks when your code does all of the above.

        BuildWatch the short clip, then do the steps. Your app carries on from the step before.

        Build 4: remember it, then tidy up

        1. Click the 💾 beside Entries, as in Saving between visits. The entries and their drawings are kept in this browser.
        2. On Describe, in AddButton is clicked, delete the action that adds to the list Journal and the one that sets LastDrawing.
        3. Delete the list Journal and the variable LastDrawing in the sidebar. Nothing uses them now.
        4. Run it, add an entry, then ↻ Restart. Is it still there? Does each row still show its own drawing?

        The drawings are kept in this browser, like the rows. Forget saved data removes both.

        Try it yourselfYour edits are saved in this browser.

        Entries is remembered between visits, and the old Journal list and LastDrawing are gone.

          Run your program. This ticks when your code does all of the above.

          CheckA quick check that the idea has stuck.

          Check: Nib and handing it in

          Nib made the table and the row click, but kept the event from the last lesson.

          A Share link is quick, but what goes inside it?

          Whichever row Nib clicks, the big picture is always the newest drawing. Click the line where Nib goes wrong.

          Kai finishes the journal, adds five entries with drawings, and sends the teacher a Share link. What does the teacher see?

          Make it yoursChange your app on purpose, then try it on someone.

          Hand it in

          1. Add two or three entries with drawings, if you haven't.
          2. Click Save at the top and choose Save to this computer…. When it asks, choose to include what the app kept. You get one file, a .zip, with the app, the rows and the drawings inside.
          3. Hand in the file the way your class usually does. Your teacher opens it with Open in App Builder.

          If your teacher only wants to try the app, Share gives a link instead, without your entries.

          Try it yourselfYour edits are saved in this browser.

          Now you can
          Next lesson6. Search, filter and sortFind songs in a bigger playlist: sort the table by title or by length, search the titles for some typed text, and filter the short songs. Searching and filtering both use the same algorithm: go through every row and copy the ones that match into a second table, so the original songs stay as they are.
          For teachers

          Students give every values-journal entry its own drawing: a table Entries with a picture field, an Add a row action, a Table object on the Journal screen and a row click that shows ClickedItem.drawing big. They remember the table between visits, delete the old list and variable, and hand in a .zip made by Save with what the app kept. About 50 minutes.

          Open the teacher guide: answers, solutions, slides and a worksheet.

          Students will be able to

          Before class

          This lesson continues App Builder apps › Draw how you showed it, which ends with "only the latest drawing is kept". Students who didn't do it can still follow: the first step uses the finished app, and the starting app is the journal with one drawing.

          A picture field holds the name the app gave a drawing (such as media:7f3a09c2); the table shows it as a thumbnail. The drawings themselves are kept in this browser, beside the remembered rows. Forget saved data removes both.

          The code checks can't see a field's type, so they can't tell whether drawing was set to Picture. A text field also shows thumbnails for drawings, so nothing breaks either way, but the 🖼 is the right habit: when students type rows into the sidebar, a picture field gives them a picture picker.

          Handing in: a Share link carries the app, not what it kept while running, so the teacher sees an empty journal. Save asks whether to include what the app kept; yes gives one .zip (the app, the rows and the drawings) that Open brings back. Drawings, not photos, so there are no faces in what's handed in.

          Running the lesson

          1. Try it: ask what changes when you click a different row. (Only the big picture: each row has its own.)
          2. Build 3: checkpoint: two entries, two different thumbnails, each click shows its own.
          3. Build 4: before deleting the old list, ask what still uses it. (Nothing, once Build 3 is done.)
          4. Hand in: show where the Save box asks about what the app kept.

          The hard part (on purpose)

          Build 3 changes three things on one screen (the Table, the count, the row click). Students who skip the count change see 'Entries: 0' forever; students who keep the old LastDrawing action see the newest drawing on every row. Point them back to step 3 of Build 3.

          When students get stuck

          Stretch and support

          Stretch: Add a Remove button: when a row is clicked, remember its index, and Remove deletes that row (as in One table instead). What happens to its drawing?

          Support: Do Build 1 together on the board. Pairs do Builds 2 to 4, one driving, one reading the steps.

          Where it leads

          Next: Search, filter and sort, on the playlist. Students could search their journal by value with the same For each.

          What each step is for