Skip to content

exams: a subject without marks parts never grades A+ — Tier B - #71

Open
omerFixesBugs wants to merge 4 commits into
mainfrom
fix/exams-partless-subject
Open

omerFixesBugs wants to merge 4 commits into
mainfrom
fix/exams-partless-subject

Conversation

@omerFixesBugs

@omerFixesBugs omerFixesBugs commented Nov 30, 2026 •

Copy link
Copy Markdown
Owner

Found on main by today's review of #66 (Aliya). Not for merging today: it changes exam behaviour the owner did not ask for, so it stays a draft for the owner to decide, even though it is Tier B.

The bug

A subject whose marks parts were never set has full marks 0. In NONE rounding every band's "at least min% of 0" held, so subjectResult gave it A+ (5.0) and a pass; with ROUND_HALF_UP or CEIL it threw instead (a 500 on the preview and the publish check). NCTB classes 1–5, the coaching templates, and Aliya's Ibtedayi and Alim have no default parts.

What it did on main. The new e2e test was run on main first, and every step below happened:

  • the sheet preview showed "0/0 · A+" for every student, and the live tabulation showed 5.00;
  • a part-less sheet with students could not be saved at all (409 ROSTER_CHANGED), so the office saw "not locked" sheets with no reason given;
  • a part-less sheet submitted while its section was still empty could be locked. Once students joined through roster sync, the class published A+ / 5.00 for everyone, and that reached guardians, report cards and the result SMS.

The fix

  • shared: a subject with full marks 0 is INCOMPLETE (no letter or point, not passed). It counts like a missing subject: the student gets no GPA, pass, division or place. gradeForMarks now refuses full marks 0 in every rounding mode.
  • api: the publish check has a new blocker, subjectsWithoutMarks, for subjects someone on the roster sits that have no parts. Publish refuses these first with 422 SUBJECT_WITHOUT_MARKS and names the subjects. Saving or submitting a part-less sheet gets the same 422, so a sheet is never locked empty. Creating and opening an exam are unchanged.
  • web: the results screen names the part-less subjects and keeps Publish off, and the refusal toast names them (bn and en). The sheet screen explains that the parts are not set, keeps Submit off, counts nobody as entered and previews "অসম্পূর্ণ / Incomplete".
  • Published snapshots are not recomputed. A class published on main keeps its stored values until it is republished. That is tested, and decisions-pending EX-6 has a read-only query to find such classes.
  • No migration. No change to roles, grants, RLS or auth.

Decisions made alone (day run 30 Nov 2026), for the owner to confirm: docs/decisions-pending.md → "Exams: a subject without marks parts" (EX-1 to EX-7). Docs: docs/exams.md.

Tests

  • Failing first (commit f080350): shared unit tests (exams.test.ts, exams-results.test.ts) and the API e2e test apps/api/test/exams-partless.e2e-spec.ts. On main, 7 unit tests and all 5 e2e tests failed.
  • Local runs after the fix (scratch DB):
    • shared: 1122 tests passed;
    • API e2e for exams (part-less, results, division, marks, marksheets, guardian, privacy, structure, setup, admit cards), notices and promotion: all passed;
    • web exam and i18n unit tests passed;
    • typecheck and lint passed for shared, api and web.
  • Not run locally: Playwright, which runs in CI. No new spec was added, because the e2e seed has no part-less exam.

Tier

Tier B: exam logic only. It touches no auth, money, roles, RLS, CI or CLAUDE.md.

Review (day run 30 Nov 2026, on 1eba881): no must-fix, no should-fix

  • No normal case changes. Full marks 0 happens only for a subject with no parts (zod and a DB
    CHECK keep each part at 1 or more). Parts, absent students, both COMBINED papers, optional and
    4th subjects, and every rounding mode are untouched. A part-less 4th subject makes the student
    incomplete; on main its A+ added a GPA bonus.
  • No new 500 or page crash. The throw in gradeForMarks is reached by no caller now. On main,
    ROUND_HALF_UP and CEIL crashed the sheet preview and gave the tabulation a 500.
  • The refusals block no valid publish. On main a part-less sheet with students could not be
    saved at all.
  • The messages are in bn and en, in the route's namespaces.
  • Nits: a part-less row shows its Absent button pressed, and tapping it autosaves into a 422;
    one unit test's toThrow(RangeError) also passes on main for two rounding modes.
  • For the owner's rollout (EX-6): a class published on main with a part-less subject keeps its
    stored A+. It can still send that in a result SMS until it is republished. Run the read-only
    query in EX-6 and unpublish or republish what it finds. Alternatively, a follow-up could refuse
    the SMS while a snapshot holds a subject with full marks 0.

Left as a draft for the owner: it changes exam behaviour that was not asked for.

🤖 Generated with Claude Code

omerFixesBugs and others added 4 commits November 30, 2026 20:37
…irst)

On main a subject with no parts has full marks 0, and every band's "at least
min% of 0" holds, so it grades A+ (5.0) and passes in NONE rounding (and the
ROUND_HALF_UP and CEIL schemes throw instead). The e2e test reproduces the
whole path on main: an empty section's part-less sheets submit and lock,
students join by roster sync, the preview shows 5.00 and publish stores A+.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- shared: subjectResult treats full marks 0 (no parts) as INCOMPLETE, like a
  blank part: no letter, no point, not passed, so the student has no GPA,
  pass or division and no place. gradeForMarks refuses full marks 0 in every
  rounding mode (NONE gave the top band; the others threw by accident).
- api: the publish check lists subjectsWithoutMarks (subjects someone sits
  that have no parts) as a blocker, and publish refuses them first with 422
  SUBJECT_WITHOUT_MARKS naming the subjects. Saving or submitting a
  part-less sheet is refused with the same code, so an empty sheet can no
  longer be submitted and locked. Opening an exam is unchanged.
- web: the results panel lists the part-less subjects and keeps Publish off;
  the refusal toast names them; the sheet explains that the parts are not
  set, keeps Submit off, counts nobody as entered and previews "Incomplete".

Published snapshots are not recomputed: they keep their stored values.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The web names the subjects only for a refused publish; a refused sheet save
shows the sheet's own words.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
omerFixesBugs added a commit that referenced this pull request Nov 30, 2026
…k, the clean-up

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@omerFixesBugs
omerFixesBugs marked this pull request as ready for review November 30, 2026 16:58
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.

1 participant