pdf-quiz-generator/backend/app/schemas/quiz.py
Daniel 47ba213ae3 Major platform update: pgvector search, multi-provider TTS, settings page, CLI
Features:
- Hybrid semantic + keyword quiz search (pgvector HNSW + PostgreSQL ILIKE)
- AWS Bedrock Titan Embed V2 embeddings via LiteLLM proxy (0.71 cosine sim)
- Multi-provider TTS: OpenAI, AWS Polly (neural), ElevenLabs, Google Cloud TTS
- Unified Settings page (profile, theme, Nextcloud integration, admin shortcuts)
- Good morning/afternoon greeting on dashboard
- manage.py CLI: reset-password, list-users, reembed
- Email verification enforced: register no longer returns JWT for unverified users
- Quiz search with debounced input, semantic/keyword/title modes, highlighted snippets
- TTS button: loading/playing states, voice selector locked during playback
- TTS auto-stops when navigating between questions
- Footer added; mobile quiz nav overflow fixed; markdown theme body selector fixed
- OpenAI Alloy as default TTS voice; favicon added
- SMTP configured via smtp2go; password reset rate limiting (3/hour)
- PostgreSQL upgraded to pgvector/pgvector:pg16

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
2026-03-31 18:03:10 +02:00

56 lines
1.2 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
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
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] = []