- FastAPI backend with JWT auth, roles (admin/moderator/user) - PDF upload (up to 500MB) with streaming, PyMuPDF text extraction - ChromaDB vectorization per page with metadata - LiteLLM AI question extraction from PDF (not generation) - Image extraction from PDF pages, graceful fallback - Quiz modes: timed (countdown timer) + learning (answers shown inline) - Page-by-page question navigation with dot navigator - TTS endpoint using LiteLLM (Google Vertex / OpenAI voices) - Admin dashboard: AI model management per task, user role management - Moderator role: upload PDFs, create sections, generate quizzes - Spaced repetition reminders via SMTP email (SM-2 intervals) - APScheduler daily reminder jobs - Celery + Redis for background PDF processing - React frontend with all pages - Docker Compose deployment (nginx + backend + celery + redis) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
35 lines
1.3 KiB
Python
35 lines
1.3 KiB
Python
from datetime import datetime
|
|
|
|
from sqlalchemy import Column, Integer, Boolean, String, DateTime, ForeignKey
|
|
from sqlalchemy.orm import relationship
|
|
|
|
from app.database import Base
|
|
|
|
|
|
class QuizAttempt(Base):
|
|
__tablename__ = "quiz_attempts"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
quiz_id = Column(Integer, ForeignKey("quizzes.id"), nullable=False)
|
|
user_id = Column(Integer, ForeignKey("users.id"), nullable=False)
|
|
score = Column(Integer, default=0)
|
|
total_questions = Column(Integer, default=0)
|
|
started_at = Column(DateTime, default=datetime.utcnow)
|
|
completed_at = Column(DateTime, nullable=True)
|
|
|
|
quiz = relationship("Quiz", back_populates="attempts")
|
|
user = relationship("User", back_populates="attempts")
|
|
answers = relationship("AttemptAnswer", back_populates="attempt", cascade="all, delete-orphan")
|
|
|
|
|
|
class AttemptAnswer(Base):
|
|
__tablename__ = "attempt_answers"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
attempt_id = Column(Integer, ForeignKey("quiz_attempts.id"), nullable=False)
|
|
question_id = Column(Integer, ForeignKey("questions.id"), nullable=False)
|
|
user_answer = Column(String, nullable=False)
|
|
is_correct = Column(Boolean, default=False)
|
|
|
|
attempt = relationship("QuizAttempt", back_populates="answers")
|
|
question = relationship("Question")
|