Suggest a sibling problem for a practice focus

Merged
PE
3h ago
+650-79

Problem and behavior

"Practice this" carries a report's improvement to the lobby as the practice focus, but the next problem had no relation to the report it came from: a due review offered the same problem again a day later, and otherwise the random draw ignored it. After this change, a focus chosen from a report on a problem with a sibling the candidate has not passed shows one line beside the selected problem, where the sequel offer appears, for example "Try your practice focus on a new problem: Chargeback Pair Match (Easy)." with a "Practice it" button that selects it.

practice next from the report
image

recommendation on the problem list
image

Selected problem
image

Approach

Read in this order:

  1. problem-bank/problems.json and scripts/problem_bank/bank.py: an optional sibling names another problem at the same level using the same technique. The generator refuses one that is missing, the problem itself, at another level, or not naming this problem back. 14 pairs, each naming the other, from the table in #798. The flag that skips these checks for task sets is renamed from sequels to lobby_links, since it now covers both.
  2. scripts/gen-problem-cards.py: cards carry data-sibling by page name, like data-sequel, so no problem id or topic reaches the initial page.
  3. web/problem-picker.js: the stored focus keeps the page of the report's problem (practiceFocusFrom(item, problemId)), and siblingSuggestion returns that problem's sibling unless it is already passed. Both offers decide a pass through one helper, passedProblem, which reads a report as the progress panel does (normalizeProgressEntry through sanitizeReport): a HIRE that is not incomplete and whose contract reportContractStatus does not call unsupported. This also changes the sequel: an incomplete HIRE, or one recorded under an older rubric, no longer offers the sequel or hides it. pickProblem keeps its own rule, as pickerEntry in web/progress.js explains. A focus without a problem offers nothing, so the automatic Carry forward focus, which aggregates several reports, never does.
  4. web/interview.js, web/replay.js, web/app.js: the report page, the replay and Past attempts pass the page of the report they show; the replay falls back to the stored row's problemId when the payload has none, as web/progress.js does. The lobby renders the offer beside the sequel's and both buttons share one handler, so the sibling is selected the way the sequel is: across the level filters, focus left on the random draw, disabled while history is refreshing. Each button's aria-label names the problem it selects (Practice it: <title>), since both offers can show at once.

The offer selects nothing until pressed, and Strict hides it with the other pickers. Each interview stays one problem, so the interview contract, report schema and history format are unchanged.

Validation

  • tests/browser/problem-picker.test.js: the focus keeps its problem through the session storage handoff (and drops a missing or non-string one), the sibling is offered for a chosen focus, not for a focus without a problem, a problem without a sibling or a sibling with no card, and not once the sibling is passed. A further test takes its expected answer from normalizeProgressEntry for a legacy, a supported, an unsupported-contract and an incomplete HIRE, and checks the sequel trigger, the sequel's passed check and the sibling's passed check against it; removing the contract check, the incomplete check, or restoring the raw sequel trigger each fails it.

  • tests/browser/lobby.test.js: no offer before Practice this; Practice this in Past attempts shows it and pressing it selects the sibling and keeps focus on a visible control; a focus handed over from the report page shows it and Strict hides it; a passed sibling is not offered; when a pass on two-sum shows both offers, each button's accessible name names the problem it selects; the sibling button is disabled while an account refresh is pending, as the sequel's is.

  • tests/browser/interview-lifecycle.test.js and tests/browser/replay-practice-focus.test.js assert that the report page and the replay store the report's page with the item, including a replay row that keeps problemId outside the payload.

  • tests/test_gen_problems.py: the sibling rule, including a one-way link, and a card naming its sibling by page.

  • ./scripts/test.sh browser (3684 pass, 0 fail) passes at e47e07a7, whose code cc31272c keeps (it only corrects docs/adding-a-problem.md), and ./scripts/test.sh rust passes at cc31272c; the rust run reports:

    not checked by this run:
      desktop clippy and tests: libwebkit2gtk-4.1-dev builds desktop/
      cargo-deny: `cargo install cargo-deny` checks dependency licenses and sources
    

    The full ./scripts/test.sh passes every other gate except review-memory-tests, which fails the same way on main here because my gh 2.46 lacks the attestation flags, and shell-syntax, where the local shellcheck 0.11.0 warns about scripts/git-post-commit.sh, which this change does not touch.

  • Checked by hand in the lobby with a stubbed history holding one report with a plan. Not checked: a live interview reaching the report page with real providers; the report page and the replay are covered by the tests above.

Close #798


Summary by cubic

"Practice this" keeps the problem a report was about, so the lobby can offer that problem's sibling as a new problem to try the practice focus on. Previously the focus carried no problem, so the next problem was unrelated.

  • An optional sibling field in problems.json names another problem at the same level; the generator validates it and cards carry it by page name.
  • The stored focus keeps the report problem's page from the report page, replays, and past attempts; the offer selects nothing until pressed and hides once the sibling is passed or the focus has no problem.
  • The sibling and sequel offers share one handler and one pass rule that reads a report as the progress panel does, so an incomplete HIRE or an unsupported contract neither triggers the sequel nor hides either offer.
  • The sequels flag is renamed lobby_links since it now covers both sequels and siblings.

Closes #798.