# Academic Master Audit

**Date:** 2026-02-22

## STEP 1 — AUDIT EXISTING FEATURES

| # | Item | Status | Notes |
|---|------|--------|-------|
| 1 | SubjectModel exists | **OK** | `App\Modules\Academic\Models\SubjectModel` |
| 2 | Subject CRUD API | **Exists but incomplete** | GET only; no POST/PUT/DELETE. No `code` field in DB. |
| 3 | Dashboard page for Subjects | **Missing** | No route `/dashboard/academic/subjects` |
| 4 | Teacher management page | **Missing** | No `/dashboard/academic/teachers` |
| 5 | Users (GURU_MAPEL/WALI_KELAS) manageable via UI | **Missing** | GET /api/users?role= exists; no POST/PUT/DELETE for users; no UI |
| 6 | Lesson Slots page in dashboard | **Missing** | Full CRUD API exists; no dashboard page |
| 7 | Schedule Builder linked from settings | **Missing** | No Academic Settings hub; Schedule Builder only in sidebar |
| 8 | Navigation menu groups academic features | **Exists but incomplete** | Only Classes + Schedule Builder under ADMIN; no group label, no Settings/Subjects/Teachers/Lesson Slots |

---

## Summary (after implementation)

- **OK:** SubjectModel, Classes page, Schedule Builder API & page, Lesson Slots API.
- **Incomplete:** Subject API (GET only), Sidebar (no grouping, missing links).
- **Missing:** Academic Settings hub, Subjects dashboard page, Teachers dashboard + user CRUD API, Lesson Slots dashboard page, Sidebar Academic group with all links.

---

## STEP 6 — IMPLEMENTATION SUMMARY

### What was added

1. **Academic Settings Hub**
   - Route: `GET /dashboard/academic/settings` (filter: `dashboard_admin_page`)
   - View: `app/Views/dashboard/academic_settings.php` — card grid linking to Classes, Subjects, Teachers, Lesson Slots, Schedule Builder

2. **Subject management (full)**
   - Migration: `AddCodeToSubjectsTable` — added `code` VARCHAR(50) NULL to `subjects`
   - SubjectModel + Subject entity: added `code` to allowedFields and validation (optional)
   - API: `POST /api/academic/subjects`, `PUT /api/academic/subjects/{id}`, `DELETE /api/academic/subjects/{id}`
   - Dashboard: `GET /dashboard/academic/subjects`, view `dashboard/subjects.php` — table (Name, Code, Actions), Add/Edit modal, Delete confirm, vanilla JS fetch

3. **Teacher management**
   - API: `GET /api/academic/teachers` — list users with role GURU_MAPEL or WALI_KELAS (with role names)
   - API: `POST /api/users` (body: name, email, password, role_code), `PUT /api/users/{id}`, `DELETE /api/users/{id}` — admin_only
   - Dashboard: `GET /dashboard/academic/teachers`, view `dashboard/teachers.php` — list (name, email, role), Add/Edit (name, email, password, role), Delete confirm

4. **Lesson Slots dashboard page**
   - Route: `GET /dashboard/academic/lesson-slots`
   - View: `dashboard/lesson_slots.php` — table (No, Jam Mulai, Jam Selesai, Actions), Add/Edit modal, Delete confirm; uses existing `/api/academic/lesson-slots` CRUD

5. **Sidebar (Academic group)**
   - Group label "Academic" (ADMIN only)
   - Links: Settings, Classes, Students, Subjects, Teachers, Lesson Slots, Schedule Builder
   - Students still points to `#` (no page yet)

### What was fixed

- Subject API completed with create/update/delete and optional `code` field.
- Navigation: academic features grouped under "Academic" with all management links.

### What was already existing

- SubjectModel, Subject entity, GET /api/academic/subjects.
- Classes: full CRUD API and dashboard page.
- Lesson Slots: full CRUD API (no dashboard page before).
- Schedule Builder: route and page; now linked from Settings hub and sidebar.
- GET /api/users?role= for listing by role.
- Attendance logic, ScheduleResolver, RBAC — not modified.
