Create Class
Endpoint:manage_classes.php
Method: POST
Authentication: Teacher session required
Request Parameters
Must be set to
create_className of the class to create
Database Operation
teacher_id- From session ($_SESSION['teacher_id'])name- Class name from request
Response
Success:manage_classes.php
Each class is owned by the teacher who created it. The teacher_id is automatically set from the session.
Add Student to Class
Endpoint:manage_classes.php
Method: POST
Authentication: Teacher session required
Request Parameters
Must be set to
add_studentID of the class to add student to
Student identifier to add
Validation Process
-
Verify Class Ownership:
-
Check Student Exists:
-
Check Existing Enrollment:
-
Add to Class:
Enrollment Rules
Response Messages
Success:- “Invalid class selected” - Class doesn’t belong to teacher
- “Student ID not found” - Student doesn’t exist in database
- “Student is already enrolled in this class”
- “Student is already enrolled in your class: [class_name]. A student can only be enrolled in one class per teacher.”
Remove Student from Class
Endpoint:manage_classes.php
Method: POST
Authentication: Teacher session required
Request Parameters
Must be set to
remove_studentID of the class
Student identifier to remove
Database Operation
Response
Success:Removing a student from a class does NOT delete their attendance history.
Delete Class
Endpoint:manage_classes.php
Method: POST
Authentication: Teacher session required
Request Parameters
Must be set to
delete_classID of the class to delete
Deletion Process
Uses database transaction to ensure data integrity:Cascade Deletions
Deleting a class removes:- All attendance records for the class
- All class schedules
- All student enrollments
- The class itself
Response Messages
Success:- “You don’t have permission to delete this class”
- “Error deleting class: [exception message]”
View Class Students
Query: Get all students enrolled in a classResponse Fields
Unique student identifier
Student’s full name
Student’s email address
Excel Import
Endpoint:manage_classes.php
Method: POST
Authentication: Teacher session required
Requirement: PhpSpreadsheet library must be installed
Request Parameters
Must be set to
importID of the class to import students into
Excel or CSV file (.xlsx, .xls, .csv)
Set to “1” if file has header row (default: checked)
File Format
Column Structure:| Column A | Column B | Column C |
|---|---|---|
| Student ID | Full Name | |
| 12345 | John Doe | [email protected] |
| 67890 | Jane Smith | [email protected] |
.xlsx- Excel 2007+.xls- Excel 97-2003.csv- Comma-separated values
Import Process
-
Validate File:
-
Read File:
-
Process Each Row:
- Skip header row if
has_headeris checked - Skip empty rows
- Check if student exists
- Create new student if data is complete
- Check for existing enrollment with this teacher
- Add to class
- Skip header row if
Auto-Create Students
If a student_id doesn’t exist but name and email are provided:New students created during import get the default password:
changeme123Response Messages
Success:- “Error uploading file. Please try again.”
- “Invalid class selected”
- “Invalid file format. Please upload an Excel file (.xlsx, .xls) or CSV file.”
- “Error processing file: [exception message]“
Excel Export
Endpoint:manage_classes.php
Method: POST
Authentication: Teacher session required
Requirement: PhpSpreadsheet library must be installed
Request Parameters
Must be set to
exportID of the class to export
Export Process
-
Validate Class Ownership:
-
Get Students:
-
Create Spreadsheet:
-
Output File:
File Output
Filename:{class_name}_roster.xlsx
Example: Computer_Science_101_roster.xlsx
Format: Excel 2007+ (.xlsx)
Columns:
- A: Student ID
- B: Name
- C: Email
- Auto-sized columns
- Header row included
- Sorted by student name
Response
File is downloaded directly to the browser. No page redirect. Error:PhpSpreadsheet library must be installed via Composer for import/export functionality.