Overview
The Grade model manages student grades, providing methods for recording grades and retrieving grade information in various formats. File:app/models/Grade.php
Methods
getStudentsByCourse
Retrieves all students enrolled in a course along with their grades (if any).Course ID to get students for
Returns array of students with their grades for the course
Uses LEFT JOIN to include students who haven’t received grades yet (grade will be null).
save
Saves or updates a grade for a student in a specific course.Student ID
Course ID
Grade value to save
No return value (throws exception on failure)
Uses
REPLACE INTO which updates the grade if it already exists, or inserts a new record if it doesn’t.getStudentGrades
Retrieves all grades for a specific student with subject information.Student ID to get grades for
Returns array of grades with subject names
getBulletinData
Retrieves comprehensive grade information for a student including subject, teacher, and grade.Student ID to get bulletin data for
Returns array of grade records with full details
This method is typically used for generating student report cards or academic bulletins.
getGradesByStudent
Retrieves all grades for a student with subject and teacher information (identical togetBulletinData).
Student ID to get grades for
Returns array of grade records with full details