pdf-quiz-generator/backend/app/schemas/attempt.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

61 lines
1.1 KiB
Python

from datetime import datetime
from pydantic import BaseModel
class AnswerSubmission(BaseModel):
question_id: int
user_answer: str
class AttemptSubmit(BaseModel):
answers: list[AnswerSubmission]
class AnswerDetail(BaseModel):
question_id: int
question_text: str
question_type: str
options: list[str] | None = None
user_answer: str
correct_answer: str
is_correct: bool
explanation: str | None
class Config:
from_attributes = True
class AttemptResponse(BaseModel):
id: int
quiz_id: int
score: int
total_questions: int
percentage: float
started_at: datetime
completed_at: datetime | None
class Config:
from_attributes = True
class AttemptDetail(AttemptResponse):
answers: list[AnswerDetail] = []
# Stats schemas
class QuizStats(BaseModel):
quiz_id: int
quiz_title: str
attempts_count: int
best_score: float
latest_score: float
average_score: float
class DashboardStats(BaseModel):
total_documents: int
total_quizzes: int
total_attempts: int
average_score: float
quiz_stats: list[QuizStats] = []