Gym induction
A new member’s induction: a welcome, two lesson pages on how the gym works and how to behave on the floor, then a three-question quiz. The person moves on from a question only once they have answered it right. It declares no business object, so it works in any host with no wiring beyond page routing.
An agent built this document from one request (see
Built by the agent,
which also shows the follow-up that added a fourth question); it has since
moved onto option notes and Steps counters. The request:
A micro-app that teaches users how to use the gym; at the end they pass a little quiz on the do’s and don’ts.
Try this
Section titled “Try this”- Press Start the tour and read through the two lesson pages.
- On the first question, pick a wrong answer. A hint under it explains why, and there is no Next question button.
- Pick the right answer. Correct! shows under it and Next question appears.
- Answer all three to reach the passed page, then press Start again: the answers are cleared.
How it works
Section titled “How it works”One state record for the answers
Section titled “One state record for the answers”{ "state": { "quiz": { "q1": "", "q2": "", "q3": "" } }}Each question gates its own Next
Section titled “Each question gates its own Next”Each answer is a radio Choice bound to its path in /quiz. Every option
carries a note, shown under the option once it is chosen: the hint on a
wrong answer, Correct! on the right one. The Next button shows only while
the answer is right:
{ "q1": { "type": "Choice", "props": { "label": "What do you do next?", "display": "radio", "options": [ { "value": "leave", "label": "Leave it — the cleaners will handle it", "note": "Not quite: wipe it right away so the next person gets a clean bench." }, { "value": "wipe", "label": "Wipe it down with a towel or spray", "note": "Correct!" }, { "value": "later", "label": "Wipe it at the end of my workout", "note": "Not quite: wipe it right away so the next person gets a clean bench." } ], "required": false, "helpText": null, "value": { "$bindState": "/quiz/q1" } }, "children": [] }, "q1-next": { "type": "Button", "props": { "label": "Next question", "variant": "solid", "size": "md", "disabled": false, "fullWidth": false }, "children": [], "on": { "press": [ { "action": "goToPage", "params": { "page": "page-q2" } } ] }, "visible": { "$state": "/quiz/q1", "eq": "wipe" } }}The step and question counters are Steps elements, counted from the pages
they list, so adding a question changes no counter.
Gating each question on its own right answer means the passed page can only be reached with every answer right, so no “fail if any answer is wrong” condition is needed.
Start again
Section titled “Start again”One setState writes the whole answer record back to empty before returning
to the welcome page:
{ "done-again": { "type": "Button", "props": { "label": "Start again", "variant": "ghost", "size": "md", "disabled": false, "fullWidth": false }, "children": [], "on": { "press": [ { "action": "setState", "params": { "statePath": "/quiz", "value": { "q1": "", "q2": "", "q3": "" } } }, { "action": "goToPage", "params": { "page": "page-welcome" } } ] } }}Where grading belongs
Section titled “Where grading belongs”The right answers are in the document, so anyone can read them in the JSON.
That is fine for practice. If the gym records who passed, the grading belongs
to the host: send the answers with a create and show the result the host
returns (see the playbook).
Complete document — examples/documents/gym-induction.json
{ "envelopeVersion": 1, "ui": { "root": "app", "elements": { "app": { "type": "PageStack", "props": { "name": "Gym basics" }, "children": [ "page-welcome", "page-basics", "page-etiquette", "page-q1", "page-q2", "page-q3", "page-done" ] }, "stack-1": { "type": "Stack", "props": { "direction": "vertical", "gap": "lg", "align": "stretch", "justify": "start", "wrap": false, "padding": "xl", "surface": null }, "children": [ "text-1", "heading-1", "text-2", "stack-2" ] }, "text-1": { "type": "Text", "props": { "content": "NEW MEMBER GUIDE", "size": "sm", "tone": "inverse", "align": "left", "italic": false }, "children": [] }, "heading-1": { "type": "Heading", "props": { "content": "Your first week at the gym", "level": "1", "align": "left", "accent": true }, "children": [] }, "text-2": { "type": "Text", "props": { "content": "A five-minute tour of how the floor works, what to do and what to avoid. Finish with a short quiz to show you're ready.", "size": "lg", "tone": "inverse", "align": "left", "italic": false }, "children": [] }, "stack-2": { "type": "Stack", "props": { "direction": "horizontal", "gap": "md", "align": "stretch", "justify": "start", "wrap": false, "padding": "none", "surface": null }, "children": [ "welcome-start" ] }, "welcome-start": { "type": "Button", "props": { "label": "Start the tour", "variant": "solid", "size": "lg", "disabled": false, "fullWidth": false }, "children": [], "on": { "press": [ { "action": "goToPage", "params": { "page": "page-basics" } } ] } }, "page-welcome": { "type": "Page", "props": { "title": "Welcome", "background": "ink" }, "children": [ "stack-1" ] }, "stack-3": { "type": "Stack", "props": { "direction": "vertical", "gap": "lg", "align": "stretch", "justify": "start", "wrap": false, "padding": "lg", "surface": null }, "children": [ "lesson-steps-1", "heading-2", "grid-1", "stack-4" ] }, "lesson-steps-1": { "type": "Steps", "props": { "format": "STEP {n} OF {total}", "pages": [ "page-basics", "page-etiquette", "page-q1" ] }, "children": [] }, "heading-2": { "type": "Heading", "props": { "content": "Getting started", "level": "1", "align": "left", "accent": false }, "children": [] }, "grid-1": { "type": "Grid", "props": { "columns": 2, "gap": "md", "padding": "none", "minCellWidth": 180 }, "children": [ "section-1", "section-2", "section-3", "section-4" ] }, "section-1": { "type": "Section", "props": { "eyebrow": "BEFORE YOU TRAIN", "title": "Come prepared", "tone": "outlined", "padding": "lg" }, "children": [ "text-4", "text-5" ] }, "text-4": { "type": "Text", "props": { "content": "Bring a towel, a water bottle and clean indoor shoes.", "size": "md", "tone": "default", "align": "left", "italic": false }, "children": [] }, "text-5": { "type": "Text", "props": { "content": "Warm up for 5–10 minutes: light cardio and a few mobility moves.", "size": "sm", "tone": "muted", "align": "left", "italic": false }, "children": [] }, "section-2": { "type": "Section", "props": { "eyebrow": "MACHINES", "title": "Set it up for you", "tone": "outlined", "padding": "lg" }, "children": [ "text-6", "text-7" ] }, "text-6": { "type": "Text", "props": { "content": "Adjust the seat and pads so the joint lines up with the pivot point.", "size": "md", "tone": "default", "align": "left", "italic": false }, "children": [] }, "text-7": { "type": "Text", "props": { "content": "Start with a light weight and move slowly and in control.", "size": "sm", "tone": "muted", "align": "left", "italic": false }, "children": [] }, "section-3": { "type": "Section", "props": { "eyebrow": "FREE WEIGHTS", "title": "Safety first", "tone": "outlined", "padding": "lg" }, "children": [ "text-8", "text-9" ] }, "text-8": { "type": "Text", "props": { "content": "Use collars on barbells and ask for a spotter on heavy bench presses.", "size": "md", "tone": "default", "align": "left", "italic": false }, "children": [] }, "text-9": { "type": "Text", "props": { "content": "Keep a clear space around you when lifting.", "size": "sm", "tone": "muted", "align": "left", "italic": false }, "children": [] }, "section-4": { "type": "Section", "props": { "eyebrow": "CARDIO", "title": "Find your pace", "tone": "outlined", "padding": "lg" }, "children": [ "text-10", "text-11" ] }, "text-10": { "type": "Text", "props": { "content": "Clip on the safety key and start at a gentle speed.", "size": "md", "tone": "default", "align": "left", "italic": false }, "children": [] }, "text-11": { "type": "Text", "props": { "content": "Most machines have a time limit at busy hours — check the sign.", "size": "sm", "tone": "muted", "align": "left", "italic": false }, "children": [] }, "stack-4": { "type": "Stack", "props": { "direction": "horizontal", "gap": "md", "align": "stretch", "justify": "between", "wrap": false, "padding": "none", "surface": null }, "children": [ "basics-back", "basics-next" ] }, "basics-back": { "type": "Button", "props": { "label": "Back", "variant": "ghost", "size": "md", "disabled": false, "fullWidth": false }, "children": [], "on": { "press": [ { "action": "goToPage", "params": { "page": "page-welcome" } } ] } }, "basics-next": { "type": "Button", "props": { "label": "Next: do's and don'ts", "variant": "solid", "size": "md", "disabled": false, "fullWidth": false }, "children": [], "on": { "press": [ { "action": "goToPage", "params": { "page": "page-etiquette" } } ] } }, "page-basics": { "type": "Page", "props": { "title": "Getting started", "background": "paper" }, "children": [ "stack-3" ] }, "stack-5": { "type": "Stack", "props": { "direction": "vertical", "gap": "lg", "align": "stretch", "justify": "start", "wrap": false, "padding": "lg", "surface": null }, "children": [ "lesson-steps-2", "heading-3", "grid-2", "stack-6" ] }, "lesson-steps-2": { "type": "Steps", "props": { "format": "STEP {n} OF {total}", "pages": [ "page-basics", "page-etiquette", "page-q1" ] }, "children": [] }, "heading-3": { "type": "Heading", "props": { "content": "Do's and don'ts", "level": "1", "align": "left", "accent": false }, "children": [] }, "grid-2": { "type": "Grid", "props": { "columns": 2, "gap": "md", "padding": "none", "minCellWidth": 180 }, "children": [ "section-5", "section-6" ] }, "section-5": { "type": "Section", "props": { "eyebrow": "PLEASE", "title": "Do", "tone": "raised", "padding": "lg" }, "children": [ "text-13", "text-14", "text-15", "text-16" ] }, "text-13": { "type": "Text", "props": { "content": "✓ Wipe down benches and machines after use.", "size": "md", "tone": "default", "align": "left", "italic": false }, "children": [] }, "text-14": { "type": "Text", "props": { "content": "✓ Put weights and plates back on the rack.", "size": "md", "tone": "default", "align": "left", "italic": false }, "children": [] }, "text-15": { "type": "Text", "props": { "content": "✓ Let others work in between your sets.", "size": "md", "tone": "default", "align": "left", "italic": false }, "children": [] }, "text-16": { "type": "Text", "props": { "content": "✓ Ask staff when you're unsure how something works.", "size": "md", "tone": "default", "align": "left", "italic": false }, "children": [] }, "section-6": { "type": "Section", "props": { "eyebrow": "PLEASE DON'T", "title": "Don't", "tone": "outlined", "padding": "lg" }, "children": [ "text-17", "text-18", "text-19", "text-20" ] }, "text-17": { "type": "Text", "props": { "content": "✗ Drop dumbbells or slam the weight stack.", "size": "md", "tone": "default", "align": "left", "italic": false }, "children": [] }, "text-18": { "type": "Text", "props": { "content": "✗ Hog a machine while scrolling your phone.", "size": "md", "tone": "default", "align": "left", "italic": false }, "children": [] }, "text-19": { "type": "Text", "props": { "content": "✗ Walk in front of someone lifting at a mirror.", "size": "md", "tone": "default", "align": "left", "italic": false }, "children": [] }, "text-20": { "type": "Text", "props": { "content": "✗ Film other members without asking.", "size": "md", "tone": "default", "align": "left", "italic": false }, "children": [] }, "stack-6": { "type": "Stack", "props": { "direction": "horizontal", "gap": "md", "align": "stretch", "justify": "between", "wrap": false, "padding": "none", "surface": null }, "children": [ "etiquette-back", "etiquette-next" ] }, "etiquette-back": { "type": "Button", "props": { "label": "Back", "variant": "ghost", "size": "md", "disabled": false, "fullWidth": false }, "children": [], "on": { "press": [ { "action": "goToPage", "params": { "page": "page-basics" } } ] } }, "etiquette-next": { "type": "Button", "props": { "label": "Take the quiz", "variant": "solid", "size": "md", "disabled": false, "fullWidth": false }, "children": [], "on": { "press": [ { "action": "goToPage", "params": { "page": "page-q1" } } ] } }, "page-etiquette": { "type": "Page", "props": { "title": "Do's and don'ts", "background": "paper" }, "children": [ "stack-5" ] }, "heading-4": { "type": "Heading", "props": { "content": "Quick quiz", "level": "1", "align": "left", "accent": false }, "children": [] }, "section-7": { "type": "Section", "props": { "eyebrow": null, "title": "You just finished on the bench", "tone": "outlined", "padding": "lg" }, "children": [ "q1-steps", "q1", "stack-7" ] }, "q1-steps": { "type": "Steps", "props": { "format": "QUESTION {n} OF {total}", "pages": [ "page-q1", "page-q2", "page-q3" ] }, "children": [] }, "q1": { "type": "Choice", "props": { "label": "What do you do next?", "display": "radio", "options": [ { "value": "leave", "label": "Leave it — the cleaners will handle it", "note": "Not quite: wipe it right away so the next person gets a clean bench." }, { "value": "wipe", "label": "Wipe it down with a towel or spray", "note": "Correct!" }, { "value": "later", "label": "Wipe it at the end of my workout", "note": "Not quite: wipe it right away so the next person gets a clean bench." } ], "required": false, "helpText": null, "value": { "$bindState": "/quiz/q1" } }, "children": [] }, "stack-7": { "type": "Stack", "props": { "direction": "horizontal", "gap": "md", "align": "stretch", "justify": "between", "wrap": false, "padding": "none", "surface": null }, "children": [ "q1-back", "q1-next" ] }, "q1-back": { "type": "Button", "props": { "label": "Review the guide", "variant": "ghost", "size": "md", "disabled": false, "fullWidth": false }, "children": [], "on": { "press": [ { "action": "goToPage", "params": { "page": "page-etiquette" } } ] } }, "q1-next": { "type": "Button", "props": { "label": "Next question", "variant": "solid", "size": "md", "disabled": false, "fullWidth": false }, "children": [], "on": { "press": [ { "action": "goToPage", "params": { "page": "page-q2" } } ] }, "visible": { "$state": "/quiz/q1", "eq": "wipe" } }, "page-q1": { "type": "Page", "props": { "title": "Quiz question 1", "background": "mist" }, "children": [ "heading-4", "section-7" ] }, "heading-5": { "type": "Heading", "props": { "content": "Quick quiz", "level": "1", "align": "left", "accent": false }, "children": [] }, "section-8": { "type": "Section", "props": { "eyebrow": null, "title": "Done with your dumbbells", "tone": "outlined", "padding": "lg" }, "children": [ "q2-steps", "q2", "stack-8" ] }, "q2-steps": { "type": "Steps", "props": { "format": "QUESTION {n} OF {total}", "pages": [ "page-q1", "page-q2", "page-q3" ] }, "children": [] }, "q2": { "type": "Choice", "props": { "label": "Where do they go?", "display": "radio", "options": [ { "value": "floor", "label": "On the floor next to the bench", "note": "Not quite: weights left out are a trip hazard and hard for others to find." }, { "value": "rack", "label": "Back on the rack, in their spot", "note": "Correct!" }, { "value": "drop", "label": "Drop them — that's what the floor is for", "note": "Not quite: weights left out are a trip hazard and hard for others to find." } ], "required": false, "helpText": null, "value": { "$bindState": "/quiz/q2" } }, "children": [] }, "stack-8": { "type": "Stack", "props": { "direction": "horizontal", "gap": "md", "align": "stretch", "justify": "between", "wrap": false, "padding": "none", "surface": null }, "children": [ "q2-back", "q2-next" ] }, "q2-back": { "type": "Button", "props": { "label": "Back", "variant": "ghost", "size": "md", "disabled": false, "fullWidth": false }, "children": [], "on": { "press": [ { "action": "goToPage", "params": { "page": "page-q1" } } ] } }, "q2-next": { "type": "Button", "props": { "label": "Next question", "variant": "solid", "size": "md", "disabled": false, "fullWidth": false }, "children": [], "on": { "press": [ { "action": "goToPage", "params": { "page": "page-q3" } } ] }, "visible": { "$state": "/quiz/q2", "eq": "rack" } }, "page-q2": { "type": "Page", "props": { "title": "Quiz question 2", "background": "mist" }, "children": [ "heading-5", "section-8" ] }, "heading-6": { "type": "Heading", "props": { "content": "Quick quiz", "level": "1", "align": "left", "accent": false }, "children": [] }, "section-9": { "type": "Section", "props": { "eyebrow": null, "title": "Someone is waiting for your machine", "tone": "outlined", "padding": "lg" }, "children": [ "q3-steps", "q3", "stack-9" ] }, "q3-steps": { "type": "Steps", "props": { "format": "QUESTION {n} OF {total}", "pages": [ "page-q1", "page-q2", "page-q3" ] }, "children": [] }, "q3": { "type": "Choice", "props": { "label": "You still have three sets to go. What do you do?", "display": "radio", "options": [ { "value": "ignore", "label": "Keep going and check my phone between sets", "note": "Not quite: sharing during your rest keeps everyone moving." }, { "value": "share", "label": "Offer to let them work in between my sets", "note": "Correct!" }, { "value": "leave", "label": "Leave my towel on it and go to the water fountain", "note": "Not quite: sharing during your rest keeps everyone moving." } ], "required": false, "helpText": null, "value": { "$bindState": "/quiz/q3" } }, "children": [] }, "stack-9": { "type": "Stack", "props": { "direction": "horizontal", "gap": "md", "align": "stretch", "justify": "between", "wrap": false, "padding": "none", "surface": null }, "children": [ "q3-back", "q3-next" ] }, "q3-back": { "type": "Button", "props": { "label": "Back", "variant": "ghost", "size": "md", "disabled": false, "fullWidth": false }, "children": [], "on": { "press": [ { "action": "goToPage", "params": { "page": "page-q2" } } ] } }, "q3-next": { "type": "Button", "props": { "label": "Finish the quiz", "variant": "solid", "size": "md", "disabled": false, "fullWidth": false }, "children": [], "on": { "press": [ { "action": "goToPage", "params": { "page": "page-done" } } ] }, "visible": { "$state": "/quiz/q3", "eq": "share" } }, "page-q3": { "type": "Page", "props": { "title": "Quiz question 3", "background": "mist" }, "children": [ "heading-6", "section-9" ] }, "stack-10": { "type": "Stack", "props": { "direction": "vertical", "gap": "lg", "align": "stretch", "justify": "start", "wrap": false, "padding": "lg", "surface": "citrus" }, "children": [ "heading-7", "text-21" ] }, "heading-7": { "type": "Heading", "props": { "content": "You passed — welcome to the floor!", "level": "1", "align": "left", "accent": true }, "children": [] }, "text-21": { "type": "Text", "props": { "content": "You know the do's and don'ts. Warm up, wipe down, rack your weights and share the equipment.", "size": "lg", "tone": "default", "align": "left", "italic": false }, "children": [] }, "stack-11": { "type": "Stack", "props": { "direction": "horizontal", "gap": "md", "align": "stretch", "justify": "start", "wrap": false, "padding": "md", "surface": null }, "children": [ "done-review", "done-again" ] }, "done-review": { "type": "Button", "props": { "label": "Review the guide", "variant": "outline", "size": "md", "disabled": false, "fullWidth": false }, "children": [], "on": { "press": [ { "action": "goToPage", "params": { "page": "page-basics" } } ] } }, "done-again": { "type": "Button", "props": { "label": "Start again", "variant": "ghost", "size": "md", "disabled": false, "fullWidth": false }, "children": [], "on": { "press": [ { "action": "setState", "params": { "statePath": "/quiz", "value": { "q1": "", "q2": "", "q3": "" } } }, { "action": "goToPage", "params": { "page": "page-welcome" } } ] } }, "page-done": { "type": "Page", "props": { "title": "Quiz passed", "background": "paper" }, "children": [ "stack-10", "stack-11" ] } }, "state": { "quiz": { "q1": "", "q2": "", "q3": "" } } }, "meta": { "pack": { "id": "mica.core", "version": "1.0.0" } }}