Spaces:
Runtime error
Runtime error
| """ | |
| Progress tracking model - Weekly/Monthly progress reports | |
| """ | |
| from sqlalchemy import Column, Integer, String, ForeignKey, DateTime, Float, JSON, Text, Date | |
| from sqlalchemy.orm import relationship | |
| from sqlalchemy.sql import func | |
| from config.database import Base | |
| class ProgressReport(Base): | |
| __tablename__ = "progress_reports" | |
| id = Column(Integer, primary_key=True) | |
| student_id = Column(Integer, ForeignKey("students.id"), nullable=False) | |
| # Report period | |
| period_type = Column(String, nullable=False) # weekly, monthly | |
| start_date = Column(Date, nullable=False) | |
| end_date = Column(Date, nullable=False) | |
| # Session statistics | |
| total_sessions = Column(Integer, default=0) | |
| total_minutes = Column(Float, default=0.0) | |
| sessions_per_type = Column(JSON) # {conversation: 5, reading: 3, articulation: 2} | |
| # Performance metrics | |
| avg_stutter_frequency = Column(Float) # Average across all sessions | |
| stutter_frequency_trend = Column(String) # improving, stable, declining | |
| avg_fluency_score = Column(Float) | |
| fluency_score_trend = Column(String) | |
| avg_wpm = Column(Float) # Words per minute | |
| wpm_trend = Column(String) | |
| # Detailed analysis | |
| most_struggled_phonemes = Column(JSON) # Top 5 problem sounds | |
| stutter_type_distribution = Column(JSON) # {block: 30%, repetition: 50%, ...} | |
| # Progress indicators | |
| goals_met = Column(JSON) # List of achieved goals | |
| areas_of_improvement = Column(JSON) # List of improvements noted | |
| areas_needing_work = Column(JSON) # List of areas to focus on | |
| # Recommendations | |
| ai_recommendations = Column(Text) # AI-generated recommendations | |
| therapist_notes = Column(Text) # Therapist's manual notes | |
| # Generation info | |
| generated_at = Column(DateTime(timezone=True), server_default=func.now()) | |
| generated_by = Column(String) # 'system' or 'therapist' | |
| # Relationships | |
| student = relationship("Student", back_populates="progress_reports") | |
| def __repr__(self): | |
| return f"<ProgressReport {self.id} - {self.period_type} {self.start_date}>" |