Architecture:
- Questions are primary objects in a bank, tagged with question categories
- QuestionCategory is a separate taxonomy from QuizCategory (different concepts)
- Extraction → questions added to bank, optionally tagged to a question category
- Quizzes can be created from: individual question selection, question category, or PDF extraction
Backend:
- QuestionCategory model + question_categories table
- question_category_id column on questions table (nullable, SET NULL on delete)
- GET/POST/PATCH/DELETE /api/question-categories/
- POST /api/question-categories/{id}/create-quiz — create quiz from all questions in a category
- PATCH /api/questions/{id}/category — assign single question to category
- PATCH /api/questions/bulk-category — assign multiple questions at once
- GET /api/questions/bank?category_id=&uncategorized= — filter by category
- QuizCreate schema now accepts question_category_id for extraction
- quiz_service.create_quiz_from_section accepts question_category_id param
Frontend:
- DocumentDetailPage: Add to Bank Category dropdown in Quiz Settings (optional)
Labels extracted questions with the selected category on creation
- QuestionBankPage: full rewrite
- Category chips for filtering (All / Uncategorized / named categories)
- Create category button inline
- Checkbox multi-select with bulk category assignment
- Create Quiz modal: choose from selected questions OR all from a category
- Each question shows its category badge and quiz source
- Study modal with instant answer feedback
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
58 lines
1.3 KiB
Python
58 lines
1.3 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
|
|
|
|
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] = []
|