The objective did almost nothing It scoped question counts and nothing else, which is why changing it appeared to have no effect. An exam now carries a family (USMLE, COMLEX, boards), a description, and the article views it offers, and `/exams/` reports what the current objective actually changes rather than leaving the learner to guess. Reading follows from it: an article returns only the views its objective allows, so someone revising a basic-science step is never shown bedside dosing they must not act on — a view you can open but must never use is worse than one you were never offered. An editor still gets the whole article, because they cannot edit what they cannot see. An objective configured to show nothing falls back to all three; that is a configuration mistake, not a preference worth honouring. Unused figures deleted, at the user's request 3,262 figures — 334 MB — that nothing had ever used. "Unused" was defined by exclusion and every exclusion was checked rather than assumed: kept if any question uses it as a stem or explanation image, if any question version mentions it, or if it appears in article prose or a flashcard. 440 kept, and five question figures spot-checked as still readable afterwards. MinIO is now 596 objects, 520 MB, down from 3,858 and 854 MB. This is not reversible from the application; the nightly borg backup of the volume is the only way back, and that is stated in the script rather than assumed. For the record, since it was asked: the extraction is PyMuPDF, with an MD5 skip list for repeated branding images. It pulled every embedded image from all 18 source PDFs, which is why one 767-page document alone produced 908 of them. 208 backend tests green. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TqXevQJhxFrM7jJg82cgZN
40 lines
1.8 KiB
Python
40 lines
1.8 KiB
Python
from datetime import datetime
|
|
|
|
from sqlalchemy import JSON, Column, DateTime, ForeignKey, Integer, String, UniqueConstraint
|
|
|
|
from app.database import Base
|
|
|
|
|
|
class Exam(Base):
|
|
"""A study objective — the top of the hierarchy, above systems and disciplines.
|
|
|
|
A question can sit under more than one exam (paediatric cardiology counts for
|
|
both a paediatrics board and a step exam), so membership is a link table
|
|
rather than a column on the question.
|
|
"""
|
|
|
|
__tablename__ = "exams"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
slug = Column(String(80), unique=True, nullable=False, index=True)
|
|
name = Column(String(160), nullable=False)
|
|
sort_order = Column(Integer, default=100)
|
|
is_active = Column(Integer, default=1) # 0 hides it from the switcher
|
|
# Objectives are picked from families — USMLE, COMLEX, boards — because a
|
|
# flat list of every exam is not a choice anyone can make.
|
|
family = Column(String(80), nullable=True)
|
|
description = Column(String(300), nullable=True)
|
|
# Which article views this objective shows. Someone revising a basic-science
|
|
# step has no use for bedside dosing, and a view they can open but must never
|
|
# act on is worse than one they were never offered. Null means all of them.
|
|
article_views = Column(JSON, nullable=True)
|
|
created_at = Column(DateTime, default=datetime.utcnow)
|
|
|
|
|
|
class QuestionExamLink(Base):
|
|
__tablename__ = "question_exam_links"
|
|
__table_args__ = (UniqueConstraint("question_id", "exam_id", name="uq_question_exam"),)
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
question_id = Column(Integer, ForeignKey("questions.id", ondelete="CASCADE"), nullable=False, index=True)
|
|
exam_id = Column(Integer, ForeignKey("exams.id", ondelete="CASCADE"), nullable=False, index=True)
|