Spaces:
Runtime error
Runtime error
| """ | |
| Assignment model - Tasks assigned by therapists to students | |
| """ | |
| from sqlalchemy import Column, Integer, String, ForeignKey, DateTime, JSON, Text, Boolean | |
| from sqlalchemy.orm import relationship | |
| from sqlalchemy.sql import func | |
| from config.database import Base | |
| class Assignment(Base): | |
| __tablename__ = "assignments" | |
| id = Column(Integer, primary_key=True) | |
| therapist_id = Column(Integer, ForeignKey("therapists.id"), nullable=False) | |
| student_id = Column(Integer, ForeignKey("students.id"), nullable=False) | |
| # Assignment details | |
| title = Column(String, nullable=False) | |
| description = Column(Text) | |
| practice_type = Column(String, nullable=False) # conversation, reading, articulation | |
| technique = Column(String, nullable=False) # normal, prolonged_speech, easy_onset | |
| # Requirements | |
| target_sessions = Column(Integer, default=1) # Number of sessions to complete | |
| target_duration_minutes = Column(Integer) # Minimum minutes per session | |
| # Specific parameters | |
| parameters = Column(JSON) # {topic, difficulty, target_sounds, etc.} | |
| # Schedule | |
| assigned_date = Column(DateTime(timezone=True), server_default=func.now()) | |
| due_date = Column(DateTime(timezone=True)) | |
| # Status | |
| is_completed = Column(Boolean, default=False) | |
| completed_sessions = Column(Integer, default=0) | |
| completed_date = Column(DateTime(timezone=True)) | |
| # Relationships | |
| therapist = relationship("Therapist", back_populates="assignments") | |
| student = relationship("Student", back_populates="assignments") | |
| sessions = relationship("PracticeSession", back_populates="assignment") | |
| def __repr__(self): | |
| return f"<Assignment {self.id} - {self.title}>" |