Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions data/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from .assignment import Assignment, Submission
from .chat import Chat
from .config import AppConfig
from .feedback import Feedback
Expand All @@ -18,4 +19,6 @@
"AppConfig",
"KnowledgeBase",
"KnowledgeFile",
"Assignment",
"Submission",
]
84 changes: 84 additions & 0 deletions data/models/assignment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
"""Assignment domain models — teacher-authored assignments and student submissions."""

from datetime import datetime

from sqlalchemy import Column, DateTime, ForeignKey, Integer, String, Text
from sqlalchemy.orm import relationship

from data.database import Base


class Assignment(Base):
__tablename__ = "assignments"

id = Column(String(36), primary_key=True)
user_id = Column(String(36), ForeignKey("users.id"), nullable=False, index=True)
title = Column(String(255), nullable=False)
description = Column(Text, nullable=True)
rubric = Column(Text, nullable=False)
due_date = Column(DateTime, nullable=True)
created_at = Column(DateTime, default=datetime.utcnow, nullable=False)
updated_at = Column(
DateTime, default=datetime.utcnow, onupdate=datetime.utcnow, nullable=False
)

user = relationship("User")

def to_dict(self) -> dict:
return {
"id": self.id,
"user_id": self.user_id,
"title": self.title,
"description": self.description,
"rubric": self.rubric,
"due_date": self.due_date.isoformat() if self.due_date else None,
"created_at": self.created_at.isoformat() if self.created_at else None,
"updated_at": self.updated_at.isoformat() if self.updated_at else None,
}


class Submission(Base):
__tablename__ = "submissions"

id = Column(String(36), primary_key=True)
assignment_id = Column(
String(36),
ForeignKey("assignments.id", ondelete="CASCADE"),
nullable=False,
index=True,
)
user_id = Column(String(36), ForeignKey("users.id"), nullable=False, index=True)
filename = Column(String(255), nullable=False)
file_path = Column(String(500), nullable=False)
file_size = Column(Integer, nullable=True)
extracted_text = Column(Text, nullable=True)
ai_score = Column(Integer, nullable=True)
ai_feedback = Column(Text, nullable=True)
teacher_score = Column(Integer, nullable=True)
teacher_feedback = Column(Text, nullable=True)
status = Column(String(20), nullable=False, default="submitted")
created_at = Column(DateTime, default=datetime.utcnow, nullable=False)
updated_at = Column(
DateTime, default=datetime.utcnow, onupdate=datetime.utcnow, nullable=False
)

assignment = relationship("Assignment", backref="submissions")
user = relationship("User")

def to_dict(self) -> dict:
return {
"id": self.id,
"assignment_id": self.assignment_id,
"user_id": self.user_id,
"filename": self.filename,
"file_path": self.file_path,
"file_size": self.file_size,
"extracted_text": self.extracted_text,
"ai_score": self.ai_score,
"ai_feedback": self.ai_feedback,
"teacher_score": self.teacher_score,
"teacher_feedback": self.teacher_feedback,
"status": self.status,
"created_at": self.created_at.isoformat() if self.created_at else None,
"updated_at": self.updated_at.isoformat() if self.updated_at else None,
}
4 changes: 4 additions & 0 deletions gateway/http/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
supports,
users,
)
from .routers import (
assignments as assignments_router,
)
from .routers import (
audio as audio_router,
)
Expand Down Expand Up @@ -164,6 +167,7 @@ async def reject_legacy_realtime_path(request: Request, call_next):
app.include_router(groups_router.router, prefix="/api/v1")
app.include_router(folders_router.router, prefix="/api/v1")
app.include_router(tasks_router.router, prefix="/api/v1")
app.include_router(assignments_router.router, prefix="/api/v1")

# Socket.IO — mounted at /realtime; client uses path='/realtime/socket.io'
app.mount("/realtime", socket_app)
Expand Down
5 changes: 5 additions & 0 deletions gateway/http/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from data.database import get_db
from data.models import User
from governance.self_regulation.service import SelfRegulationService
from learning.assignments.service import AssignmentService
from learning.supports.service import SupportsService

security = HTTPBearer()
Expand Down Expand Up @@ -83,3 +84,7 @@ def get_self_regulation_service(db: Session = Depends(get_db)) -> SelfRegulation

def get_files_service(db: Session = Depends(get_db)) -> FilesService:
return FilesService(db)


def get_assignment_service(db: Session = Depends(get_db)) -> AssignmentService:
return AssignmentService(db)
Loading