Overview
TheCourseController manages course records, linking subjects with teachers. All operations require administrator privileges.
File Location: app/controllers/CourseController.php
Dependencies:
CoursemodelSubjectmodelTeachermodelAuthhelper
Methods
index()
Displays list of all courses with their associated subjects and teachers. Authorization: Admin only Behavior:- Retrieves all course records with related data
- Renders course listing view
app/views/courses/index.php
create()
Displays course creation form and handles course creation. Authorization: Admin onlyID of the subject for this course (POST request)
ID of the teacher assigned to this course (POST request)
- GET request: Loads available subjects and teachers, displays form
- POST request: Creates new course linking subject and teacher
- GET: Renders creation form with subject and teacher dropdowns
- POST: Redirects to
/courses
delete()
Deletes a course record. Authorization: Admin onlyCourse ID to delete (from GET query parameter)
- Validates admin authorization
- Deletes course from database
- Redirects to course listing
/courses
Usage Examples
Creating a Course
Deleting a Course
Notes
- A course represents a subject taught by a specific teacher
- Multiple courses can exist for the same subject (different teachers/sections)
- Courses are referenced by enrollments and timetables
- Deleting a course may affect enrollments and grades