Overview
TheBulletinController generates and displays student grade reports (bulletins), calculating averages and validation status. Supports both admin and student access.
File Location: app/controllers/BulletinController.php
Dependencies:
GrademodelUsermodelAuthhelper
Methods
index()
Displays list of all students for bulletin selection. Authorization: Admin only Behavior:- Retrieves all student records
- Renders student selection view for bulletin access
app/views/bulletin/index.php
show()
Generates and displays a student’s bulletin with all grades, average, and validation status. Authorization: Any authenticated userStudent ID (required for admin/teacher, ignored for students)
- Students: View their own bulletin (uses session user ID)
- Admin/Teachers: Can view any student’s bulletin (requires
student_idparameter)
- Determines target student ID based on user role
- Retrieves student information and all grades
- Calculates total, average, and validation status
- Renders bulletin view with calculations
app/views/bulletin/show.php
Calculations:
- Total: Sum of all grades
- Average:
total / count(rounded to 2 decimals) - Status:
VALIDÉif average ≥ 10, otherwiseNON VALIDÉ
Usage Examples
Student Viewing Their Own Bulletin
Admin Viewing a Student’s Bulletin
Bulletin Data Structure
The bulletin displays:Validation Logic
Pass/Fail Determination
- VALIDÉ (Validated): Average grade ≥ 10/20
- NON VALIDÉ (Not Validated): Average grade < 10/20
Edge Cases
- No grades: Average = 0, Status = NON VALIDÉ
- Division by zero: Protected by
$count > 0check
Security Features
Auth::check()- Ensures user is authenticated- Role-based access: Students see only their own bulletin
- Admin/teachers require explicit
student_idparameter - Dies with error if admin doesn’t provide
student_id