feat: Initial project structure for WebTriviasMulti
- Backend: FastAPI + Python-SocketIO + SQLAlchemy - Models for categories, questions, game sessions, events - AI services for answer validation and question generation (Claude) - Room management with Redis - Game logic with stealing mechanics - Admin API for question management - Frontend: React + Vite + TypeScript + Tailwind - 5 visual themes (DRRR, Retro, Minimal, RGB, Anime 90s) - Real-time game with Socket.IO - Achievement system - Replay functionality - Sound effects per theme - Docker Compose for deployment - Design documentation Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
28
backend/app/models/question.py
Normal file
28
backend/app/models/question.py
Normal file
@@ -0,0 +1,28 @@
|
||||
from sqlalchemy import Column, Integer, String, Text, Date, DateTime, ForeignKey, ARRAY
|
||||
from sqlalchemy.orm import relationship
|
||||
from sqlalchemy.sql import func
|
||||
from app.models.base import Base
|
||||
|
||||
|
||||
class Question(Base):
|
||||
__tablename__ = "questions"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
category_id = Column(Integer, ForeignKey("categories.id"), nullable=False)
|
||||
question_text = Column(Text, nullable=False)
|
||||
correct_answer = Column(String(500), nullable=False)
|
||||
alt_answers = Column(ARRAY(String), default=[])
|
||||
difficulty = Column(Integer, nullable=False) # 1-5
|
||||
points = Column(Integer, nullable=False)
|
||||
time_seconds = Column(Integer, nullable=False)
|
||||
date_active = Column(Date, index=True)
|
||||
status = Column(String(20), default="pending") # pending, approved, used
|
||||
fun_fact = Column(Text)
|
||||
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||
|
||||
# Relationships
|
||||
category = relationship("Category", back_populates="questions")
|
||||
game_events = relationship("GameEvent", back_populates="question")
|
||||
|
||||
def __repr__(self):
|
||||
return f"<Question(id={self.id}, difficulty={self.difficulty}, status='{self.status}')>"
|
||||
Reference in New Issue
Block a user