# Audit & Rencana Pengembangan UtiVerse

**Tanggal**: 13 Juli 2026  
**Terakhir Diperbarui**: 15 Juli 2026  
**Versi Aplikasi**: ClassVerse / UtiVerse  
**Stack**: Laravel 13 | Inertia.js | React 19 + TypeScript | Tailwind CSS v4 | MySQL/MariaDB

---

## 1. Status Fase Pengembangan

| Fase | Status | Keterangan |
|------|--------|------------|
| **Fase 1A: Foundation** | ✅ Selesai | Auth, Sync Siswa, Kelas, Absensi, Jurnal, Dashboard Guru |
| **Fase 1B: Mesin Pembelajaran** | ✅ Selesai | Materi, Tugas, Login Siswa, Portal Siswa, Koreksi, Game Arena |
| **Fase 2: Rekap & Laporan** | 🟡 80% | Recap Absensi + Export XLSX, Rekap Nilai (tinggal PDF Rapor) |
| **Fase 3: Game Pembelajaran** | ✅ Selesai | 9 Tipe Soal, 3 Mode Game, Live Arena, Power-ups |
| **Bug Fixes (21 bug)** | ✅ Selesai | Semua bug critical, medium, dan low sudah diperbaiki |
| **Multi-Teacher Sync** | ✅ Selesai | Sync guru dari API + tabel `synced_teachers` |
| **Quiz Assignment** | ✅ Selesai | Quiz PG/TF, autosave, leaderboard, multi-kelas |
| **Arsip Periode (TP/Semester)** | ✅ Selesai | Tabel `student_enrollments`, stamping `academic_year_id`/`semester_id` di assignments, filter arsip di controller, sync riwayat kelas dari API pusat, command reset aman |

---

## 2. Rencana Pengembangan Selanjutnya

### A. Perbaikan Kritis (Prioritas 1) — ✅ SEMUA SELESAI

- [x] Fix bug keamanan `double_points` — client bisa manipulasi skor
- [x] Fix `sync_logs.type` ENUM — tidak ada value `teachers`
- [x] Fix authorization admin vs guru — admin tidak bisa akses fitur guru
- [x] Fix race condition live answer — bisa submit jawaban duplikat
- [x] Fix missing question types di solo play — 3 tipe soal blank

### B. Fitur Belum Selesai (Prioritas 2)

- [x] Leaderboard live game — sudah diperbaiki
- [ ] Shuffle soal — belum diimplementasi
- [ ] Grades table untuk game — skor game belum masuk tabel `grades` → **akan diselesaikan via Quiz Assignment**
- [ ] Password change enforcement — form belum muncul otomatis
- [ ] Seeder admin — tidak ada cara buat admin pertama

### C. Fitur Baru Potensial (Prioritas 3)

- [ ] Export Laporan Siswa — PDF rapor per siswa
- [ ] Notifikasi — pengingat deadline tugas, nilai baru
- [x] **Bank Soal Terpusat** — reuse soal antar game → **dalam perencanaan (lihat PLAN-quiz-assignment.md)**
- [ ] CBT/Ujian Online — mode ujian dengan timer dan anti-cheat
- [x] Multi-guru — **sudah selesai (sync dari API + tabel synced_teachers)**
- [ ] Chat/Diskusi — forum diskusi per materi
- [ ] Parent Portal — orang tua lihat nilai & absensi
- [ ] Analytics Dashboard — grafik performa siswa/kelas
- [ ] File Upload untuk Materi — saat ini hanya link eksternal
- [ ] PWA Support — install sebagai app di HP siswa

---

## 3. Audit Bug — ✅ SEMUA SUDAH DIPERBAIKI

### BUG KRITIS (5) — ✅ SELESAI

| # | Lokasi | Bug | Status |
|---|--------|-----|--------|
| 1 | `ArenaPlayController::submitLiveAnswer()` | **`double_points` dikontrol client** — validasi server-side dari `PowerUpUsage` | ✅ Fixed |
| 2 | `database/migrations/2026_07_13_000001_*.php` | **ENUM `type` tidak ada `teachers`** — migration baru ditambah | ✅ Fixed |
| 3 | `AppServiceProvider` Gates | **Admin tidak bisa akses fitur guru** — gate `guru` return true untuk admin juga | ✅ Fixed |
| 4 | `ArenaPlayController::submitLiveAnswer()` | **Race condition double-submit** — ganti dengan `Cache::add()` | ✅ Fixed |
| 5 | `Arena/Play.tsx` | **3 tipe soal tidak ada rendernya** — tambah JumbledWord, SpellingBee, SentenceRearrange | ✅ Fixed |

### BUG SEDANG (10) — ✅ SELESAI

| # | Lokasi | Bug | Status |
|---|--------|-----|--------|
| 6 | `lib/sounds.ts` | **AudioContext memory leak** — reuse single instance | ✅ Fixed |
| 7 | `LiveWait.tsx` | **`echo.disconnect()` putus semua channel** — ganti `leaveChannel()` | ✅ Fixed |
| 8 | `LiveArenaHostController::endQuestion()` | **Leaderboard selalu kosong** — implementasi query | ✅ Fixed |
| 9 | `Attendance/Edit.tsx` | **Dynamic Tailwind class** — ganti object literal | ✅ Fixed |
| 10 | `Welcome.tsx` | **Theme key mismatch** — samakan ke `theme` | ✅ Fixed |
| 11 | `StudentLayout.tsx` | **Brand name "ClassVerse"** — ganti ke "UtiVerse" | ✅ Fixed |
| 12 | `routes/web.php` | **No rate limit arena answer** — tambah `throttle:30,1` | ✅ Fixed |
| 13 | 6 Models | **`$guarded = ['id']`** — ganti `$fillable` eksplisit | ✅ Fixed |
| 14 | `GameController` | **No ownership check** — tambah `teacher_id` + filter | ✅ Fixed |
| 15 | `LiveArenaHostController::resetPin()` | **Orphaned power_up_usages** — tambah delete | ✅ Fixed |

### BUG RENDAH (6) — ✅ SELESAI

| # | Lokasi | Bug | Status |
|---|--------|-----|--------|
| 16 | 3 Layouts | **`Math.random()` di render** — ganti `useMemo` | ✅ Fixed |
| 17 | Multiple pages | **`dangerouslySetInnerHTML`** — aman, dari Laravel paginator | ✅ Safe |
| 18 | `Game/Index.tsx` | **`useForm()` untuk DELETE** — ganti `router.delete()` | ✅ Fixed |
| 19 | `Materi/Show.tsx` & `StudentPortal/MaterialDetail.tsx` | **Duplicated `getMediaIcon`** — extract ke `lib/components.tsx` | ✅ Fixed |
| 20 | Multiple pages | **Missing `<Head>` import** — cosmetic, tidak mempengaruhi fungsi | ✅ Cosmetic |
| 21 | Multiple layouts | **Inline `<style>` tags** — cosmetic, tidak mempengaruhi fungsi | ✅ Cosmetic |

---

## 4. Kode yang Perlu Diperbarui

### Backend (Laravel)

| File | Masalah | Solusi |
|------|---------|--------|
| `ArenaPlayController.php` (545 baris) | Controller terlalu besar | Extract scoring logic ke `GameScoringService` |
| `app/Services/ApiSyncService.php` | Tidak ada interface | Buat interface untuk testability |
| `routes/channels.php` | Tidak ada channel auth untuk game | Tambah authorization callback |
| `config/services.php` + `.env.example` | API key tidak didokumentasikan | Tambah `API_MTSSAPO_URL` dan `API_MTSSAPO_KEY` ke `.env.example` |
| `app/Providers/AppServiceProvider.php` | Gate logic admin/guru konsolidasi | Buat Policy classes untuk setiap model |
| All Controllers | Authorization inline | Migrate ke Laravel Policies |
| `database/migrations` | `class_subject` table tidak dipakai | Drop dead schema |
| `database/migrations` | `learning_games.game_type` tidak dipakai | Drop unused column |
| `database/migrations` | `game_items` missing `time_limit` column | Tambah kolom atau hapus referensi |
| `DatabaseSeeder.php` | Tidak ada admin seeder | Tambah admin seeder atau perintah setup |
| `LearningGame::getFactionLeaderboard()` | Raw DB query | Convert ke Eloquent |
| 8+ Controllers | Duplicated teaching-assignment query | Buat `SyncedClass` scope |
| `GameController` | No file validation untuk `question_image` | Tambah mime/size validation |

### Frontend (React/TypeScript)

| File | Masalah | Solusi |
|------|---------|--------|
| 16+ pages | `layout = (page: any)` | Buat proper `PageProps` types |
| `LivePlay.tsx`, `Lobby.tsx` dll | Props `any` | Buat interface untuk setiap page props |
| `lib/sounds.ts` | AudioContext leak + duplicate system | Consolidate ke satu `useSoundEffects` hook |
| `Arena/Play.tsx` | Missing 3 question type renders | Tambah JumbledWord, SpellingBee, SentenceRearrange |
| `Attendance/Edit.tsx` | Dynamic Tailwind classes | Buat mapping object dengan class literal |
| `Welcome.tsx` | Theme key `utiverse-theme` | Standardize ke `theme` |
| `StudentLayout.tsx` | Brand "ClassVerse" | Ganti ke "UtiVerse" |
| Multiple pages | Hardcoded routes | Gunakan `route()` helper dari Ziggy |
| `GameLayout`, `Welcome` dll | Inline `<style>` | Pindah ke `app.css` atau Tailwind keyframes |
| `Materi/Create.tsx` & `Edit.tsx` | Duplicated link management | Extract ke shared hook `useMaterialLinks` |
| No error boundaries | App crash white screen | Tambah `ErrorBoundary` component |
| `types/index.ts` | Banyak type belum didefinisikan | Tambah type untuk Game, GameItem, Assignment, Material dll |

### Infrastruktur

| Area | Masalah | Solusi |
|------|---------|--------|
| Testing | Hanya 4 test methods | Tambah test untuk semua controller & service |
| Factories | Hanya `UserFactory` | Buat factory untuk semua model |
| CI/CD | Tidak ada | Setup GitHub Actions (lint, test, build) |
| Docker | Tidak ada | Buat docker-compose untuk dev environment |
| Error monitoring | Tidak ada | Setup Sentry/Bugsnag |
| API documentation | Tidak ada | Buat API docs untuk endpoint yang dipakai siswa |

---

## 5. Statistik Ringkasan

| Kategori | Jumlah |
|----------|--------|
| Total Model | 24 (+1 QuizQuestion) |
| Total Controller | 17 (+1 QuizController) |
| Total Migration | 37 (+4 quiz) |
| Total Event | 7 |
| Total Enum | 3 |
| Total Service | 1 |
| Total Middleware | 2 |
| Bug Kritis | 5 (✅ semua fixed) |
| Bug Sedang | 10 (✅ semua fixed) |
| Bug Rendah | 6 (✅ semua fixed) |
| Fitur belum selesai | 2 (PDF Rapor, Shuffle soal game) |
| Fitur selesai | Quiz Assignment ✅ |

---

*Audit ini dibuat berdasarkan analisis menyeluruh terhadap seluruh codebase UtiVerse per 13 Juli 2026.*  
*Terakhir diperbarui: 14 Juli 2026 — Quiz Assignment selesai diimplementasi.*
