新增作文区与 AI 解读开关,修复 CSV 导出。
系统设置可关闭成绩复盘 AI;学生详情增加作文区(OCR/手动题目、方案与范文、历史与 MD 下载);导出改用 UTF-8 文件名响应。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -27,6 +27,18 @@ class WrongQuestionCategory(str, enum.Enum):
|
||||
olympiad = "olympiad"
|
||||
|
||||
|
||||
class CompositionStatus(str, enum.Enum):
|
||||
pending = "pending"
|
||||
generating = "generating"
|
||||
done = "done"
|
||||
failed = "failed"
|
||||
|
||||
|
||||
class CompositionInputMode(str, enum.Enum):
|
||||
manual = "manual"
|
||||
ocr = "ocr"
|
||||
|
||||
|
||||
class AIProvider(str, enum.Enum):
|
||||
ollama = "ollama"
|
||||
openai = "openai"
|
||||
@@ -73,6 +85,9 @@ class Student(Base):
|
||||
wrong_questions: Mapped[list["WrongQuestion"]] = relationship(
|
||||
back_populates="student", cascade="all, delete-orphan"
|
||||
)
|
||||
compositions: Mapped[list["Composition"]] = relationship(
|
||||
back_populates="student", cascade="all, delete-orphan"
|
||||
)
|
||||
|
||||
|
||||
class Subject(Base):
|
||||
@@ -150,11 +165,37 @@ class WrongQuestion(Base):
|
||||
subject: Mapped["Subject"] = relationship(back_populates="wrong_questions")
|
||||
|
||||
|
||||
class Composition(Base):
|
||||
__tablename__ = "compositions"
|
||||
|
||||
id: Mapped[uuid.UUID] = mapped_column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
||||
student_id: Mapped[uuid.UUID] = mapped_column(UUID(as_uuid=True), ForeignKey("students.id"), index=True)
|
||||
topic: Mapped[str] = mapped_column(Text)
|
||||
input_mode: Mapped[CompositionInputMode] = mapped_column(
|
||||
Enum(CompositionInputMode), default=CompositionInputMode.manual
|
||||
)
|
||||
writing_plan: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||||
sample_essay: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||||
error_message: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||||
status: Mapped[CompositionStatus] = mapped_column(
|
||||
Enum(CompositionStatus), default=CompositionStatus.pending
|
||||
)
|
||||
created_at: Mapped[datetime] = mapped_column(
|
||||
DateTime(timezone=True), default=lambda: datetime.now(timezone.utc)
|
||||
)
|
||||
updated_at: Mapped[datetime] = mapped_column(
|
||||
DateTime(timezone=True), default=lambda: datetime.now(timezone.utc)
|
||||
)
|
||||
|
||||
student: Mapped["Student"] = relationship(back_populates="compositions")
|
||||
|
||||
|
||||
class SystemSettings(Base):
|
||||
__tablename__ = "system_settings"
|
||||
|
||||
id: Mapped[int] = mapped_column(Integer, primary_key=True, default=1)
|
||||
registration_enabled: Mapped[bool] = mapped_column(default=True)
|
||||
ai_review_enabled: Mapped[bool] = mapped_column(default=True)
|
||||
ai_provider: Mapped[str] = mapped_column(String(16), default="ollama")
|
||||
ollama_base_url: Mapped[str | None] = mapped_column(String(256), nullable=True)
|
||||
ollama_model: Mapped[str | None] = mapped_column(String(128), nullable=True)
|
||||
|
||||
Reference in New Issue
Block a user