# Dapodik Sync — Pre-Implementation Audit

| # | Item | Status | Notes |
|---|------|--------|-------|
| 1 | Students dashboard page + API | **EXISTS** | GET/POST/PUT/DELETE /api/academic/students; GET /dashboard/academic/students |
| 2 | Existing Dapodik service code | **MISSING** | No DapodikClient or sync logic; only comments in migrations/model |
| 3 | Existing mapping table | **MISSING** | No dapodik_rombel_mappings or similar |
| 4 | Settings page link for Dapodik | **MISSING** | No Dapodik card in Academic Settings hub |

**Summary:** Students management exists and is ready. Dapodik integration (client, mapping table, settings link) is missing and will be implemented.

---

## Implemented (post-implementation)

- Migration `dapodik_rombel_mappings`, DapodikClient, DapodikSyncService, DapodikSyncController, dashboard Dapodik page, Students UNMAPPED badge + filter.

### Required .env (add to backend/.env)

```
DAPODIK_BASE_URL=http://192.168.7.5:5774/WebService
DAPODIK_TOKEN=bt5ON1LZPSsaJ6h
DAPODIK_NPSN=20227474
```

### Brief test steps

**1) cURL — Sync (requires valid token + base URL)**

```bash
# Login as ADMIN first; use session cookie or pass auth.
curl -X POST "http://localhost/sman1/backend/public/api/academic/dapodik/sync/students" \
  -H "Content-Type: application/json" \
  -H "X-Requested-With: XMLHttpRequest" \
  -d "{\"limit\":50,\"max_pages\":2}" \
  --cookie "ci_session=YOUR_SESSION"
```

**2) cURL — List rombel mappings**

```bash
curl "http://localhost/sman1/backend/public/api/academic/dapodik/rombels" \
  -H "X-Requested-With: XMLHttpRequest" \
  --cookie "ci_session=YOUR_SESSION"
```

**3) cURL — Update mapping**

```bash
curl -X PUT "http://localhost/sman1/backend/public/api/academic/dapodik/rombels/1" \
  -H "Content-Type: application/json" \
  -H "X-Requested-With: XMLHttpRequest" \
  -d "{\"class_id\":1}" \
  --cookie "ci_session=YOUR_SESSION"
```

**4) UI**

- Login as ADMIN → Academic → Settings → open **Dapodik** card.
- Click **Jalankan Sinkronisasi**; check summary in pre block and toast.
- In **Mapping Rombel**, set "Kelas (internal)" and click **Simpan** per row; toggle **Hanya unmapped**.
- Go to **Siswa** → tick **Hanya unmapped** to see only unmapped students; confirm **UNMAPPED** badge in Kelas column when class_id is null.
