0841b1a103
- 前端:Vue3 + TS + Element Plus,24 个页面路由(课件/组题/教案/动画/思维导图/作文批改/命题/课堂/资源/社区等) - 后端:FastAPI + SQLAlchemy + SQLite,17 个路由模块,AI 服务层含降级模板 - AI:glm-5.x 推理模型已禁用思维链,确保输出真实内容 - 修复:ai_service 两处请求体注入 enable_thinking/thinking disabled - 测试账号:13900999999 / test1234
45 lines
1.7 KiB
Python
45 lines
1.7 KiB
Python
from sqlalchemy import Column, Integer, String, Text, DateTime, JSON, ForeignKey, Enum as SAEnum
|
|
from sqlalchemy.orm import relationship
|
|
from sqlalchemy.sql import func
|
|
from database import Base
|
|
|
|
|
|
class Exercise(Base):
|
|
__tablename__ = "exercises"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
user_id = Column(Integer, ForeignKey("users.id"), nullable=False)
|
|
title = Column(String(200), nullable=False)
|
|
exercise_type = Column(
|
|
SAEnum(
|
|
"game_snake", "game_match", "game_adventure",
|
|
"choice", "fill_blank", "true_false", "drag_sort", "matching",
|
|
name="exercise_type",
|
|
),
|
|
default="choice",
|
|
)
|
|
subject = Column(String(50), default="")
|
|
knowledge_points = Column(JSON, default=list)
|
|
questions = Column(JSON, default=list)
|
|
settings = Column(JSON, default=dict)
|
|
created_at = Column(DateTime, server_default=func.now())
|
|
updated_at = Column(DateTime, server_default=func.now(), onupdate=func.now())
|
|
|
|
author = relationship("User", back_populates="exercises")
|
|
attempts = relationship("ExerciseAttempt", back_populates="exercise", lazy="selectin")
|
|
|
|
|
|
class ExerciseAttempt(Base):
|
|
__tablename__ = "exercise_attempts"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
exercise_id = Column(Integer, ForeignKey("exercises.id"), nullable=False)
|
|
student_name = Column(String(50), default="")
|
|
answers = Column(JSON, default=list)
|
|
score = Column(Integer, default=0)
|
|
total = Column(Integer, default=0)
|
|
duration = Column(Integer, default=0)
|
|
created_at = Column(DateTime, server_default=func.now())
|
|
|
|
exercise = relationship("Exercise", back_populates="attempts")
|