Files
breakpilot-lehrer/klausur-service/backend/models/exam.py
Benjamin Boenisch 5a31f52310 Initial commit: breakpilot-lehrer - Lehrer KI Platform
Services: Admin-Lehrer, Backend-Lehrer, Studio v2, Website,
Klausur-Service, School-Service, Voice-Service, Geo-Service,
BreakPilot Drive, Agent-Core

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-11 23:47:26 +01:00

69 lines
1.8 KiB
Python

"""
Klausur-Service Exam Models
Data classes for Klausur and StudentKlausur.
"""
from dataclasses import dataclass, asdict
from datetime import datetime
from typing import Optional, List, Dict, Any
from .enums import KlausurModus, StudentKlausurStatus
@dataclass
class StudentKlausur:
"""A student's exam work."""
id: str
klausur_id: str
student_name: str
student_id: Optional[str]
file_path: Optional[str]
ocr_text: Optional[str]
status: StudentKlausurStatus
criteria_scores: Dict[str, Dict]
gutachten: Optional[Dict]
raw_points: int
grade_points: int
created_at: datetime
def to_dict(self) -> Dict[str, Any]:
"""Convert to dictionary for JSON serialization."""
d = asdict(self)
d['status'] = self.status.value if hasattr(self.status, 'value') else self.status
d['created_at'] = self.created_at.isoformat()
return d
@dataclass
class Klausur:
"""An exam/Klausur with associated student works."""
id: str
title: str
subject: str
modus: KlausurModus
class_id: Optional[str]
year: int
semester: str
erwartungshorizont: Optional[Dict]
students: List[StudentKlausur]
created_at: datetime
teacher_id: str
def to_dict(self) -> Dict[str, Any]:
"""Convert to dictionary for JSON serialization."""
return {
'id': self.id,
'title': self.title,
'subject': self.subject,
'modus': self.modus.value,
'class_id': self.class_id,
'year': self.year,
'semester': self.semester,
'erwartungshorizont': self.erwartungshorizont,
'student_count': len(self.students),
'students': [s.to_dict() for s in self.students],
'created_at': self.created_at.isoformat(),
'teacher_id': self.teacher_id
}