forge
Explore
Log in

Don't you dare go Hollow

Commits

Commits on mainFiltered to src/db/question_image.rsClear filter

2026-09-16

✨ feat: the class×course instance is the academic anchor (K-12 remodel)Ahmet Kaan Gümüş · ae84034
✨ feat: the class×course instance is the academic anchor (K-12 remodel)

`course` was a school-wide singleton: enrollment, exams, sessions,
roll-call and homework all keyed on it, so two class sections teaching the same
course shared one roster, one exam set and one timetable. This moves the
academic anchor to `class_course` — the per-class instance — and rebuilds
the academic model around Turkish K-12.

Schema (migrations/school/20260916000001_k12_remodel.sql): `class_course`
becomes an instance (ders_saati, counts_toward_karne, enrollment_count,
class_course_teacher); enrollment re-keys to (class_course, app_user);
exam carries class_course + term (+ exam_audience for shared exams);
course_session / session_attendance / homework re-key; `class_member` is a
soft-leave history table (uuid PK, joined_at/left_at, partial unique index
on the live stint); `academic_year` sits above `term`; `class_group` links
a year, not a term; new `course_membership` (clubs/study), `karne_snapshot`;
settings gain branches/excuse_kinds/absence limits/timezone; profile gains
branch. Drops/recreates the identity-changing tables (pre-customer; the
migration resets every counter on a kept table that pointed at a dropped
one).

Layers: domain/db/service/web rewritten to the instance seam, with
`ensure_instance_teacher` gating instance writes (D10), the report card computed per
instance and weighted by ders_saati, an absence report, `/instances`
and `/academic-years` nests, and `/classes/{id}/instances`. Capacity and
the seat-claim 409 are gone; detach sweeps the whole instance subtree and
unlinks its blob keys.

Gates: cargo check --all-targets, SQLX_OFFLINE check (cache regenerated),
doc_sync, spec_bounds, limits_completeness, clippy -D warnings all green;
cargo nextest run 1370/1370.

2026-09-12

🗃️ feat!: port exams domain to sqlx/PostgresAhmet Kaan Gümüş · 381e16c
🗃️ feat!: port exams domain to sqlx/Postgres

- db/{exam,exam_question,exam_attempt,exam_answer,exam_result,question_image,answer_image}:
  SurrealQL -> static query!/query_as! (PagedList exemption kept for
  exam_question listing); composite natural PKs (exam,user,seq) everywhere;
  sitting scoping via key.rs wire helpers unchanged.
- Freeze gate: write_unfrozen/IndexedResults/FROZEN_SLOT deleted; freeze is
  a shared in-tx freeze_gate() (exam row FOR UPDATE + EXISTS(attempts)) run
  inside each question/image write's own tx_with_retry.
- EXAM_LOCK deleted: sitting create re-judges sittable/window gates on the
  locked exam row (guard_start) then claims exam_sat_total in one CTE;
  exam delete locks the exam row before its ordered cascade and collects
  blob keys inside the tx; answer/answer-image saves lock the exam row
  ahead of their upserts (bump-and-restore touch tricks deleted).
- PRESENCE_LOCK deleted: join = unconditional left_at clear; last-out =
  single conditional stamp_left_if_running (left_at IS NULL AND
  finished_at IS NULL AND live-schedule in-progress); ExamPresence map
  mutex stays for counts.
- Grade tx: exam row FOR UPDATE, draft gate in-tx, kind_ref claim
  (retired=false), 4-counter first-vs-regrade precedence preserved exactly;
  remove() refunds via data-modifying CTE.
- THROW markers -> early returns: exam_redraft, questions_frozen, no_exam,
  question_subject_gone, question_row_gone, question_stale_move,
  exam_missing, exam_draft, kind_retired.
- cfg(test) mods left for wave 3.

2026-09-11