Critical bug fix:
- DELETE /quizzes/{id} was returning 500 due to {\"quiz_id\": None} update using
the DB column name instead of Python attribute name (source_quiz_id).
Fixed with {QuestionModel.source_quiz_id: None, synchronize_session=False}
Extraction fix:
- Two-phase extraction was incorrectly triggering for PREP 2012/2014 format
documents that have 'Preferred Response:' in their explanation text.
Fix: check for inline 'Correct Answer:' first — if found, always use standard
extraction regardless of 'Preferred Response:' appearing elsewhere.
Quiz trash bin:
- DELETE /quizzes/{id} now soft-deletes (sets deleted_at)
- GET /quizzes/trash — list deleted quizzes (moderator)
- PATCH /quizzes/{id}/restore — restore from trash
- DELETE /quizzes/{id}/permanent — permanent delete (must be in trash first)
- TrashPage.jsx — accessible via Settings → Admin → Trash
Hide/publish quizzes:
- is_published column on quizzes (1=visible, 0=hidden)
- PATCH /quizzes/{id}/publish?published=false — hide from regular users
- Moderators see all quizzes; regular users only see published
- 👁/🙈 toggle button per quiz card (moderators only)
Quiz progress resume (cross-browser via Redis):
- POST /attempts/progress — save {answers, current_idx, mode} to Redis (7 days)
- GET /attempts/progress?quiz_id=N — retrieve saved progress
- DELETE /attempts/progress/{quiz_id} — clear on submit
- QuizPage auto-saves to Redis every 1.5s (debounced) while in progress
- ModeSelectScreen loads saved progress from server, shows Resume button
- Works across browsers, devices, and after logout
Delete attempt:
- DELETE /attempts/{id} — user can delete own attempt + clears reminders for that quiz
ConfirmButton component:
- Replaces all window.confirm() / window.prompt() across the app
- Double-click pattern: first click shows [Confirm] [Cancel] inline
- Applied to: QuizzesPage, DocumentDetailPage, QuizEditPage, QuestionBankPage
Category delete (QuestionBankPage):
- window.prompt() replaced with inline modal dialog with select dropdown
- User chooses where to move questions before deletion
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
60 lines
1.4 KiB
Python
60 lines
1.4 KiB
Python
from datetime import datetime
|
|
|
|
from pydantic import BaseModel
|
|
|
|
|
|
class QuizCreate(BaseModel):
|
|
section_id: int
|
|
title: str
|
|
mode: str = "timed" # timed, learning
|
|
time_limit_minutes: int | None = None
|
|
model_id: str | None = None # override extraction model
|
|
question_category_id: int | None = None # assign extracted questions to this bank category
|
|
|
|
|
|
class QuestionResponse(BaseModel):
|
|
id: int
|
|
question_text: str
|
|
question_type: str
|
|
options: list[str] | None
|
|
image_path: str | None = None
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class QuestionWithAnswer(QuestionResponse):
|
|
correct_answer: str
|
|
explanation: str | None
|
|
page_reference: int | None
|
|
|
|
|
|
class QuizResponse(BaseModel):
|
|
id: int
|
|
section_id: int
|
|
user_id: int
|
|
title: str
|
|
questions_count: int
|
|
mode: str
|
|
time_limit_minutes: int | None
|
|
skipped_questions: str | None = None
|
|
category_id: int | None = None
|
|
created_at: datetime
|
|
deleted_at: datetime | None = None
|
|
is_published: int = 1
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class QuizDetail(QuizResponse):
|
|
questions: list[QuestionResponse] = []
|
|
|
|
|
|
class QuizLearningDetail(QuizResponse):
|
|
"""Learning mode — includes answers and explanations."""
|
|
questions: list[QuestionWithAnswer] = []
|
|
|
|
|
|
class QuizReview(QuizResponse):
|
|
questions: list[QuestionWithAnswer] = []
|