Skip to content

Exams phase 5a: generated subnet questions - #109

Open
A7med7x7 wants to merge 2 commits into
autopilot/exams-4d-tagging-3from
autopilot/exams-5a-generated
Open

A7med7x7 wants to merge 2 commits into
autopilot/exams-4d-tagging-3from
autopilot/exams-5a-generated

Conversation

@A7med7x7

Copy link
Copy Markdown
Member

Stacked on #108 (→ #105 → #104 → #102 → #101). Merge the exam stack in order.

Exam phase 5a from docs/exams.md: generated questions, built from the same logic as the lesson, with fresh numbers every time so they can't be memorised.

How it works

  • QuestionGenerator (src/lib/questions.ts): { id, lesson, section?, generate(random) }. generate returns the prompt, options, answer and explanation.
  • instantiate(generator, seed) seeds the random function, mixing in the generator's id so two generators never share numbers, and fills in id, lesson and section. The id is the same for every seed, so a review card follows the skill ("find a network address"), not one set of numbers.
  • buildOptions(right, wrong, random) drops duplicate distractors and puts the right answer at a random position.
  • src/content/<course>/generators.ts: one optional file per course. loadBank(course, seed) adds one instance of each generator to the fixed bank. The course page offers an exam for any course with a bank or generators.
  • Where they appear: the course exam, with new numbers on every attempt, and /review, with new numbers every session. Module quizzes are unchanged.

The first three: Computer Networks subnets

All three use the lesson's own parseCidr and link to "Network part and host part":

Generator Example Wrong options are…
Usable hosts How many usable hosts in a /27? → 30 2ʰ (forgot the network and broadcast addresses), 2ʰ − 1, the /n−1 answer
Network address 172.30.17.226/19 → 172.30.0.0 first host, broadcast, last octet zeroed, the address itself
Broadcast address same kind of prompt last host, network address, last octet set to 255, the next block

Addresses come from the private ranges, and prefixes avoid octet boundaries so the work happens inside one octet. Each explanation works the steps, for example "/19 splits inside the third octet, where blocks are 32 wide (2⁵). 17 falls in the block starting at 0…", and names the tempting wrong answers.

Tests (src/test/generated-questions.test.ts)

Over 500 seeds per generator:

  • always four distinct options and exactly one right answer;
  • the right answer appears in all four positions;
  • the same seed gives the same question, and different seeds give different ones;
  • ids are stable and never clash with the fixed banks;
  • lesson and section are real;
  • every subnet answer matches an independent 32-bit bit-mask calculation, not parseCidr itself.

exam-page.test.tsx works out answers for generated questions too, since a 20-question networks exam can now draw them.

Checked in the browser: a generated card in /review renders at 390 px with no errors, shows the right answer and the explanation, and links to "Re-read: IP addresses and subnets".

Checks

npm run lint: 0 errors. npm run test: 3,698 passed. npm run build: OK.

Next

  • 5b: Operating Systems CPU scheduling (waiting and turnaround times).
  • 5c: Algorithm Design Big-O. That's your course, so I'll ask before adding anything.

Generated by Claude Code

Questions with fresh numbers every time, so they can't be memorised.
A QuestionGenerator (src/lib/questions.ts) produces a question body
from a seeded random function; instantiate() seeds it, mixing in the
generator's id, and fills in the id, lesson and section. The id stays
the same for every seed, so the review queue tracks the skill.

Each course can keep generators in src/content/<course>/generators.ts.
loadBank adds one instance of each, the exam page draws a fresh seed
per attempt, and review gets fresh numbers every session.

Computer Networks gets the first three, all built on the lesson's own
parseCidr: usable hosts in a /n, and the network and broadcast address
of a random private address with a non-octet prefix. Wrong options are
real mistakes (forgetting the two reserved addresses, the first or last
host, zeroing the wrong octet). Tests run 500 seeds each: four distinct
options, one right answer, every position used, and answers that match
an independent 32-bit mask calculation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EC6Zzt5akQu7TEHdGquZzp
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EC6Zzt5akQu7TEHdGquZzp

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants