Overview
The Course Management system allows administrators to create courses by linking teachers with subjects. Courses form the foundation for enrollments, grade tracking, and timetable scheduling.Course Creation
Link teachers with subjects to create courses
Course Listing
View all active courses with teacher and subject details
Course Deletion
Remove courses and cascade-delete related data
Teacher Assignment
Assign specific teachers to courses
What is a Course?
A course represents a specific subject taught by a specific teacher. For example:- “Mathematics taught by Mr. Smith”
- “Physics taught by Dr. Johnson”
- “English taught by Ms. Williams”
Course Components:
- Subject: The academic subject (e.g., Mathematics, Physics)
- Teacher: The assigned instructor for this course instance
- Unique Instance: Each teacher-subject combination is a separate course
Course Architecture
Database Schema
courses table creates relationships between subjects and teachers, enabling:
- Multiple teachers teaching the same subject
- One teacher teaching multiple subjects
- Flexible course assignment
Course Operations
Viewing All Courses
Administrators can view all courses with detailed information:Query Explanation
Query Explanation
This query performs three JOINs:
- courses → subjects: Get the subject name
- courses → teachers: Link to teacher records
- teachers → users: Get teacher’s actual name and details
Creating Courses
Course creation requires selecting a subject and teacher:Creation Workflow:
- Admin navigates to course creation page
- System loads all available subjects and teachers
- Admin selects subject from dropdown
- Admin selects teacher from dropdown
- System creates course linking the two
Deleting Courses
Deleting a course removes it and all related data:Cascade Effects:
Deleting a course automatically removes:
- All student enrollments in this course
- All grades associated with this course
- All timetable entries for this course
ON DELETE CASCADE.Teacher-Specific Course Queries
Getting Courses by Teacher
Teachers can view only their assigned courses:Verifying Course Ownership
Security check to ensure teachers can only access their own courses:Security Pattern:
Always verify course ownership before allowing teachers to:
- View enrolled students
- Enter or modify grades
- Access course-specific data
Timetable Integration
Getting Courses for Timetable
Special query for timetable creation with full course details:- Course ID (for database operations)
- Subject name (e.g., “Mathematics”)
- Teacher name (e.g., “Mr. Smith”)
- Sorted alphabetically by subject
Finding Course Details
Retrieve complete course information:Course Model Complete Reference
API Endpoints
| Method | Endpoint | Access | Description |
|---|---|---|---|
| GET | /courses | Admin | List all courses |
| GET | /courses/create | Admin | Show course creation form |
| POST | /courses/create | Admin | Create new course |
| GET | /courses/delete?id={id} | Admin | Delete course |
| GET | /grades | Teacher | View teacher’s courses |
Use Cases
Scenario 1: Creating a Mathematics Course
Scenario 1: Creating a Mathematics Course
Steps:
- Admin navigates to
/courses/create - Selects “Mathematics” from subjects dropdown
- Selects “Mr. Smith” from teachers dropdown
- Submits form
- System creates course with
subject_idandteacher_id - Course appears in listings as “Mathematics - Mr. Smith”
Scenario 2: Teacher Viewing Their Courses
Scenario 2: Teacher Viewing Their Courses
Steps:
- Teacher logs in and navigates to grades section
- System calls
getByTeacher()with teacher’s ID - Returns only courses assigned to this teacher
- Teacher sees list: “Mathematics”, “Algebra”, etc.
- Teacher can select course to view enrolled students
Scenario 3: Deleting a Course
Scenario 3: Deleting a Course
Steps:
- Admin views course list
- Clicks delete on “Physics - Dr. Johnson”
- System deletes course record
- Database automatically cascades:
- Removes all enrollments
- Removes all grades
- Removes timetable entries
- Students no longer see this course
Relationship Diagram
Courses are the central entity connecting subjects, teachers, students,
grades, and timetables. All academic activities flow through courses.