Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 15 additions & 22 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,21 @@ specs are in git history.
- [x] **Everyone's current boards:** replaces only each board's **background**, never the student's ink.
Done (Nov 2026): Live Grid → **Send worksheet…** sends up to four variants (A–D) to selected boards of the
viewed round (same / rotate / by name-stamp corner), via `teacher:set-background-multi`.
- [ ] **A prepared breakout round** (see below): sets that round's worksheet template, so students who enter
it later get it.
- [ ] **Set up worksheet variants (A–D) before class, on a prepared round.** Today variants can only be sent
from Live Grid → **Send worksheet…**, after the round is live and students already have boards.
- In the prepared-round form (Breakout manager → **Save for later** / **Edit**), let the teacher upload up to
four variants and pick the distribution: same for all / deal out in turn / by name-stamp corner.
- On **Launch**, the server gives each new board its variant. Corner mode reads the main board's stamps at
launch time. Late joiners get their variant by the same rule, not always A.
- Save variants and the distribution rule **on the round**, so they survive a restart.
- **Lesson packs must carry all of it.** Anything a teacher sets up ahead of time (prepared rounds, their
variants A–D, the distribution rule, the corner mapping, per-student overrides, the late-joiner rule) must
go into **Save lesson…** (`.allaboard`) and come back intact with **Load lesson…**. Per-student overrides
only make sense in the same class, so on load, match them by student name and drop the ones that don't
match. Add a round-trip test: save a pack, load it into a fresh room, and check that every prepared field
matches.
- [ ] **Make a sent distribution editable.** Reopening **Send worksheet…** starts empty: the uploaded variants
and who got which are forgotten, so changing one student's card means uploading everything again.
- Remember each round's variants and assignments, and reopen the modal with them filled in.
- Allow changing one board's letter, swapping a variant's file, or switching the distribution rule, and send
only the boards whose worksheet actually changes.
- Keep the existing rule: ink stays and only the worksheet underneath changes. Warn about boards that
already have work, as the modal does now.
- [x] **A prepared breakout round** (see below): sets that round's worksheet template, so students who enter
it later get it. Done: the prepared-round form's worksheet is the round's template, and **Edit** changes it.
- [x] **Set up worksheet variants (A–D) before class, on a prepared round.**
Done (Nov 2026): the prepared-round form (individual rounds) adds worksheets B–D, the rule (same / deal out in
turn / by name-stamp corner, with the corner map) and the late-joiner rule. On **Launch** the server deals them
out alphabetically by student, or reads Main's name stamps; late joiners get theirs by the same rule (or A).
Stored on the room as teacher-only `roundVariants` (`src/lib/roundVariants.ts`), so they survive restarts and
room saves. Lesson packs carry them; per-student picks (matched by name) go in only when the teacher ticks
"include student picks", and who-got-which never does. Tests: `tests/roundVariantsServer.test.ts`.
Group rounds have no variants yet.
- [x] **Make a sent distribution editable.**
Done (Nov 2026): **Send worksheet…** reopens with the round's A–D files, rule, corner map and per-student picks.
Each board keeps the letter it has until the teacher changes the rule; changing one board's letter or a file
sends only the boards whose worksheet changes. Individual rounds save it all (`teacher:set-round-variants`),
so late joiners get their variant too.
- **Server:** a teacher-only path that applies `internBackground` once and then reuses the same asset URL for
every board. With content-addressed assets, 30 boards cost one stored image.

Expand Down
2 changes: 2 additions & 0 deletions docs/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ Cloud Run service "allaboard" ── one container :3000 (node server.ts, Build
| `breakoutConfig` | `mode` (`main`/`individual`/`groups`, i.e. where students are **now**), `activeRoundId`, `rounds[]`, `allowSelfSelect`, `chatScope`, `userBoardOverrides` |
| `roundTemplates[roundId]` | The worksheet each round's boards start with (copied to late joiners). Sent to **teachers only** (`init`, `breakout-sync`, `round-templates-sync`) and saved in room exports. |
| `roundTemplateInk[roundId]` | **Template ink**: teacher Main ink (no name stamps) a round copies onto each of its boards, with new ids and the teacher as author so students can't erase it. Individual boards get it as they're made (late joiners too); group boards at launch. Set by `copyInk` with `copyWorksheet` on `new-round` / `edit-prepared`. Teachers only, like `roundTemplates`; in room exports and lesson packs (`LessonRound.ink`). |
| `roundVariants[roundId]` | **Worksheet variants** for an individual round: worksheets B–D (A is always `roundTemplates[roundId]`), the rule (`same` / `rotate` / `corner` + corner map), the late-joiner rule, per-student picks by lowercased name, and `assigned` (userId → letter, session data). Used when each board is made (`provisionIndividualBoard`; launch deals out alphabetically). Set by `variants` on `new-round` / `edit-prepared` and by `teacher:set-round-variants` (Send worksheet…). Teachers only; in room exports and lesson packs without `assigned` (picks only when the teacher opts in). |
| `timer`, `lockedNames`, `bannedUsers`, `isCanvasLocked`, `hideStudentCursors`, `teacherPin`, `lastActiveAt` | As named |
| `usersByUserId` | **Runtime only** (not persisted): roster, `sockets` set, `isTeacher`, student status |

Expand Down Expand Up @@ -153,6 +154,7 @@ Cloud Run service "allaboard" ── one container :3000 (node server.ts, Build
- Room and identity: `check-room` (ack, no side effects), `join-room`, `update-profile`, `user:set-status`, `cursor-move`, `disconnect`
- Teacher actions: `teacher:auth`, `teacher:step-down`, `teacher:configure-breakout` (actions above), `teacher:set-background`,
`teacher:set-background-multi` (one worksheet to many boards; optional `roundTemplateFor` sets the round template),
`teacher:set-round-variants` (ack; an individual round's worksheets B–D, rule and picks, `src/lib/roundVariants.ts`),
`teacher:update-background`, `teacher:rename-user`, `teacher:delete-message`, `teacher:unban-user`,
`teacher:purge-user-contributions`, `teacher:set-lock`, `teacher:set-hide-cursors`, `teacher:set-one-name-stamp`, `teacher:clear-status`, `teacher:spotlight-board`, `laser-pulse`, `teacher:clear-all`, `teacher:import-room`
- Lesson packs (teacher-only, ack; `src/lib/lessonPack.ts`): `teacher:export-lesson` (server builds the skeleton,
Expand Down
60 changes: 60 additions & 0 deletions e2e/preparedRounds.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,63 @@ test('a prepared individual round moves nobody until the teacher launches it', a

for (const u of [teacher, alex]) await u.context.close();
});

async function labeledPng(page: Page, label: string) {
const b64 = await page.evaluate((text) => {
const c = document.createElement('canvas');
c.width = 400;
c.height = 300;
const ctx = c.getContext('2d')!;
ctx.fillStyle = '#ffffff';
ctx.fillRect(0, 0, 400, 300);
ctx.fillStyle = '#111827';
ctx.font = '64px sans-serif';
ctx.fillText(text, 40, 120);
return c.toDataURL('image/png').split(',')[1];
}, label);
return { name: `card_${label}.png`, mimeType: 'image/png', buffer: Buffer.from(b64, 'base64') };
}

test('a prepared round deals out worksheets A and B when it launches', async ({ browser }) => {
test.setTimeout(60_000);
const room = uniqueRoom('prepvar');
const teacher = await newUser(browser);
const alex = await newUser(browser);
const bea = await newUser(browser);
await joinRoom(teacher.page, room, 'Ms T', PIN);
await joinRoom(alex.page, room, 'Alex');
await joinRoom(bea.page, room, 'Bea');

await teacher.page.getByTitle('Assign individual student boards or breakout group rooms').click();
await teacher.page.getByLabel('Round name (optional):').fill('Cards');
await teacher.page.getByLabel('Upload a worksheet file for this round').setInputFiles(await labeledPng(teacher.page, 'A'));
await expect(teacher.page.getByText('Uploaded: card_A.png')).toBeVisible();

const editor = teacher.page.getByTestId('variants-editor');
await editor.getByRole('button', { name: 'Add worksheet B' }).click();
await editor.getByLabel('Worksheet B', { exact: true }).setInputFiles(await labeledPng(teacher.page, 'B'));
await expect(editor.getByText(/card_B\.png · 1 page/)).toBeVisible();
await editor.getByLabel(/Deal out A, B in turn/).check();
await teacher.page.getByRole('button', { name: 'Save for later' }).click();

const list = teacher.page.getByTestId('prepared-rounds');
await expect(list.getByText(/\+ worksheet B \(dealt out in turn\)/)).toBeVisible();
await expect(alex.page.getByText(/Active Board:/)).toHaveCount(0);

await list.getByRole('button', { name: 'Launch' }).click();
await expect(teacher.page.getByText(/Live Classroom Boards Overview/)).toBeVisible();
const alexImg = teacher.page.getByAltText("Alex's Board");
const beaImg = teacher.page.getByAltText("Bea's Board");
await expect(alexImg).toHaveAttribute('src', /^\/api\/assets\//);
await expect(beaImg).toHaveAttribute('src', /^\/api\/assets\//);
expect(await alexImg.getAttribute('src')).not.toEqual(await beaImg.getAttribute('src'));

// Send worksheet… starts from what the round handed out.
await teacher.page.getByRole('button', { name: 'Send worksheet…' }).click();
const dialog = teacher.page.getByRole('dialog');
await expect(dialog.getByText(/card_B\.png · 1 page/)).toBeVisible();
await expect(dialog.getByLabel("Worksheet for Alex's Board")).toHaveValue('A');
await expect(dialog.getByLabel("Worksheet for Bea's Board")).toHaveValue('B');

for (const u of [teacher, alex, bea]) await u.context.close();
});
22 changes: 20 additions & 2 deletions e2e/sendWorksheet.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,25 @@ test('Send worksheet rotates A/B across individual boards', async ({ browser })
const beaImg = teacher.page.getByAltText("Bea's Board");
await expect(alexImg).toHaveAttribute('src', /^\/api\/assets\//);
await expect(beaImg).toHaveAttribute('src', /^\/api\/assets\//);
expect(await alexImg.getAttribute('src')).not.toEqual(await beaImg.getAttribute('src'));
const aSrc = await alexImg.getAttribute('src');
expect(aSrc).not.toEqual(await beaImg.getAttribute('src'));

for (const u of [teacher, alex, bea]) await u.context.close();
// Reopening starts from what was sent: both files, and each board keeps its letter.
await teacher.page.getByRole('button', { name: 'Send worksheet…' }).click();
await expect(dialog.getByText(/card_A\.png · 1 page/)).toBeVisible();
await expect(dialog.getByText(/card_B\.png · 1 page/)).toBeVisible();
await expect(dialog.getByLabel("Worksheet for Alex's Board")).toHaveValue('A');
await expect(dialog.getByLabel("Worksheet for Bea's Board")).toHaveValue('B');
// Change one board by hand and send again: only Bea's board changes.
await dialog.getByLabel("Worksheet for Bea's Board").selectOption('A');
await dialog.getByRole('button', { name: 'Send', exact: true }).click();
await expect(dialog).toHaveCount(0);
await expect(beaImg).toHaveAttribute('src', aSrc!);

// A late joiner gets the next letter in turn: Alex A, Bea A (picked), so Cal gets A (2 handed out, 2 letters).
const cal = await newUser(browser);
await joinRoom(cal.page, room, 'Cal');
await expect(teacher.page.getByAltText("Cal's Board")).toHaveAttribute('src', /^\/api\/assets\//);

for (const u of [teacher, alex, bea, cal]) await u.context.close();
});
Loading
Loading