File size: 1,740 Bytes
d646f8a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
"""
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}>"