Skip to content

Teacher Substitution

Overview

The Teacher Substitution feature manages class coverage when teachers are absent. It supports two integrated mechanisms:

MechanismScopeModel
SubstituteAssignmentDaily class-level — specific subject, time slot, classEducator\SubstituteManagement\SubstituteAssignment
LeaveSubstituteLeave-based — covers the full duration of a teacher's leaveLeaveManagement\LeaveSubstitute\LeaveSubstitute

Key Entities

EntityDescription
Original TeacherThe teacher who is absent and needs coverage
Substitute TeacherThe teacher who covers the class
SubstituteAssignmentA specific assignment covering one class session (subject + time + class)
LeaveSubstituteLinks a leave request to a substitute employee for the leave duration
Assignment Statuspending, confirmed, completed, cancelled

Concept

Two-Tier Substitution Model

The system uses a two-tier approach to handle teacher absence:

  1. Leave Level — When a teacher requests leave, a LeaveSubstitute record can be created to assign coverage for the entire leave period. This provides a high-level view of who is covering during the absence.

  2. Class Level — For each class session that needs coverage during the absence, a SubstituteAssignment is created. This captures the specific subject, class, time slot, and date. Multiple assignments can be created for a single leave period.

Assignment Lifecycle

  1. Pending — Assignment created, substitute notified
  2. Confirmed — Substitute accepts the assignment
  3. Completed — Assignment has been fulfilled
  4. 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:

  1. When a teacher is absent, the system determines if it's planned leave or an emergency.
  2. For planned leave, a leave request is submitted first, then a LeaveSubstitute is created.
  3. For emergencies, the admin can create assignments directly without a leave request.
  4. For each affected class session, a SubstituteAssignment is created with the specific class, subject, and time slot.
  5. The substitute receives a pending assignment and can confirm or decline.
  6. 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

ColumnTypeDescription
original_teacher_iduuid FKAbsent teacher
substitute_teacher_iduuid FKCovering teacher
school_class_iduuid FKClass being covered
subject_iduuid FKSubject being taught
assignment_datedateDate of substitution
start_time / end_timetimeTime slot
statusenumpending, confirmed, completed, cancelled

leave_substitutes

ColumnTypeDescription
leave_request_iduuid FKAssociated leave request
substitute_employee_iduuid FKCovering employee
start_date / end_datedateCoverage period
statusstringApproval 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