Overview
The Timetable model manages class scheduling, including schedule creation, conflict detection, and personalized timetable retrieval for students and teachers. File:app/models/Timetable.php
Methods
getAll
Retrieves all timetable entries with course, subject, and teacher information. SQL Query:Returns array of all timetable entries ordered by day and time
create
Creates a new timetable entry for a course.Course ID to schedule
Day of week (e.g., “Monday”, “Tuesday”)
Start time in HH:MM format (e.g., “09:00”)
End time in HH:MM format (e.g., “10:30”)
Returns
true if creation was successful, false otherwiseUse
teacherHasConflict() before creating to prevent scheduling conflicts.teacherHasConflict
Checks if a teacher has a scheduling conflict for the specified time slot.Teacher ID to check
Day of week
Start time in HH:MM format
End time in HH:MM format
Returns
true if there is a conflict, false if the time slot is availableThe conflict detection checks for overlapping time periods, not just exact matches.
delete
Deletes a timetable entry by ID.Timetable entry ID to delete
Returns
true if deletion was successful, false otherwisegetForStudent
Retrieves a personalized timetable for a specific student based on their enrollments.Student ID to get timetable for
Returns array of timetable entries for the student’s enrolled courses
getForTeacher
Retrieves a personalized timetable for a specific teacher.Teacher ID to get timetable for
Returns array of timetable entries for the teacher’s courses