Teacher Substitution
Overview
The Teacher Substitution feature manages class coverage when teachers are absent. It supports two integrated mechanisms:
| Mechanism | Scope | Model |
|---|---|---|
| SubstituteAssignment | Daily class-level — specific subject, time slot, class | Educator\SubstituteManagement\SubstituteAssignment |
| LeaveSubstitute | Leave-based — covers the full duration of a teacher's leave | LeaveManagement\LeaveSubstitute\LeaveSubstitute |
Key Entities
| Entity | Description |
|---|---|
| Original Teacher | The teacher who is absent and needs coverage |
| Substitute Teacher | The teacher who covers the class |
| SubstituteAssignment | A specific assignment covering one class session (subject + time + class) |
| LeaveSubstitute | Links a leave request to a substitute employee for the leave duration |
| Assignment Status | pending, confirmed, completed, cancelled |
Concept
Two-Tier Substitution Model
The system uses a two-tier approach to handle teacher absence:
Leave Level — When a teacher requests leave, a
LeaveSubstituterecord can be created to assign coverage for the entire leave period. This provides a high-level view of who is covering during the absence.Class Level — For each class session that needs coverage during the absence, a
SubstituteAssignmentis created. This captures the specific subject, class, time slot, and date. Multiple assignments can be created for a single leave period.
Assignment Lifecycle
- Pending — Assignment created, substitute notified
- Confirmed — Substitute accepts the assignment
- Completed — Assignment has been fulfilled
- Cancelled — Assignment is no longer needed
Flowchart
Teacher Substitution Flow
The following flowchart illustrates how a substitution is created when a teacher is absent:
Explanation:
- When a teacher is absent, the system determines if it's planned leave or an emergency.
- For planned leave, a leave request is submitted first, then a
LeaveSubstituteis created. - For emergencies, the admin can create assignments directly without a leave request.
- For each affected class session, a
SubstituteAssignmentis created with the specific class, subject, and time slot. - The substitute receives a pending assignment and can confirm or decline.
- Once confirmed and taught, the assignment is marked as completed.
Data Flow Diagram
Level 0 — Substitution Context
Activity Diagram — Substitution Lifecycle
Database
Entity Relationship Diagram
Key Tables
substitute_assignments
| Column | Type | Description |
|---|---|---|
original_teacher_id | uuid FK | Absent teacher |
substitute_teacher_id | uuid FK | Covering teacher |
school_class_id | uuid FK | Class being covered |
subject_id | uuid FK | Subject being taught |
assignment_date | date | Date of substitution |
start_time / end_time | time | Time slot |
status | enum | pending, confirmed, completed, cancelled |
leave_substitutes
| Column | Type | Description |
|---|---|---|
leave_request_id | uuid FK | Associated leave request |
substitute_employee_id | uuid FK | Covering employee |
start_date / end_date | date | Coverage period |
status | string | Approval status |
Key Files
app/Models/Educator/
├── Teacher/Teacher.php # Teacher with substitution relations
└── SubstituteManagement/
└── SubstituteAssignment/
├── SubstituteAssignment.php # Class-level substitution model
└── Concerns/
├── HasRelations.php # Relationships
└── HasScopes.php # Query scopes
app/Models/LeaveManagement/
└── LeaveSubstitute/
└── LeaveSubstitute.php # Leave-based substitution
app/Enums/Educator/SubstituteManagement/
└── AssignmentStatus.php # Status enum
database/migrations/
├── v1_2_0/003_create_substitute_assignments_table.php # Substitute assignments table
└── v1_2_0/004_add_leave_request_id_to_substitute_assignments.php