338 lines
8.1 KiB
Markdown
338 lines
8.1 KiB
Markdown
# 🚀 Quick Start Guide - Fitur Mata Kuliah dan Absensi
|
|
|
|
## 📌 TL;DR (Too Long; Didn't Read)
|
|
|
|
Fitur baru ditambahkan: **Mata Kuliah** dan **Absen Kehadiran** dengan integrasi N8n dan penyimpanan lokal.
|
|
|
|
---
|
|
|
|
## 🎯 Feature Overview
|
|
|
|
| Fitur | Deskripsi | Status |
|
|
|-------|-----------|--------|
|
|
| Daftar Mata Kuliah | Tampilkan 5 mata kuliah semester 4 | ✅ |
|
|
| Pilih Mata Kuliah | Dialog selector sebelum absensi | ✅ |
|
|
| Absensi dengan MK | Kirim data dengan informasi mata kuliah | ✅ |
|
|
| Riwayat Kehadiran | Lihat history per mata kuliah | ✅ |
|
|
| Laporan Statistik | Persentase dan summary kehadiran | ✅ |
|
|
| Local Storage | SharedPreferences dengan Gson | ✅ |
|
|
| N8n Integration | Send to webhook dengan data lengkap | ✅ |
|
|
|
|
---
|
|
|
|
## 📁 File-File Baru
|
|
|
|
```
|
|
app/src/main/java/id/ac/ubharajaya/sistemakademik/
|
|
├── config/
|
|
│ └── CourseConfig.kt (Konfigurasi mata kuliah)
|
|
├── models/
|
|
│ └── CourseModels.kt (Data models)
|
|
├── utils/
|
|
│ ├── CourseService.kt (CRUD service)
|
|
│ └── AttendanceUtils.kt (Helper utilities)
|
|
├── ui/
|
|
│ ├── components/
|
|
│ │ └── CourseComponents.kt (UI components)
|
|
│ └── screens/
|
|
│ └── CourseScreen.kt (Course detail screens)
|
|
└── MainActivity.kt (Modified - integrated course selection)
|
|
```
|
|
|
|
---
|
|
|
|
## 🔧 Setup (5 Menit)
|
|
|
|
### 1. Gradle Sync
|
|
```bash
|
|
# gradle sync otomatis dilakukan saat membuka project
|
|
```
|
|
|
|
### 2. Build
|
|
```bash
|
|
# Dari Android Studio: Build > Make Project
|
|
```
|
|
|
|
### 3. Run
|
|
```bash
|
|
# Dari Android Studio: Run > Run 'app'
|
|
```
|
|
|
|
---
|
|
|
|
## 💡 Usage Examples
|
|
|
|
### Inisialisasi
|
|
```kotlin
|
|
val courseService = CourseService(context)
|
|
courseService.initializeSampleData() // Load 5 sample courses
|
|
```
|
|
|
|
### Ambil Mata Kuliah
|
|
```kotlin
|
|
val courses = courseService.getCourses()
|
|
val course = courses.first()
|
|
println("${course.courseCode} - ${course.courseName}")
|
|
```
|
|
|
|
### Simpan Kehadiran
|
|
```kotlin
|
|
val attendance = Attendance(
|
|
npm = "202310715082",
|
|
nama = "Fazri Abdurrahman",
|
|
courseId = "COURSE_001",
|
|
courseCode = "PBO2024",
|
|
courseName = "Pemrograman Berorientasi Objek",
|
|
latitude = -6.123456,
|
|
longitude = 106.654321,
|
|
timestamp = System.currentTimeMillis(),
|
|
date = courseService.getCurrentDate(),
|
|
time = courseService.formatTime(System.currentTimeMillis()),
|
|
status = AttendanceStatus.PRESENT,
|
|
isValid = true
|
|
)
|
|
courseService.saveAttendance(attendance)
|
|
```
|
|
|
|
### Buat Laporan
|
|
```kotlin
|
|
val report = courseService.generateAttendanceReport("COURSE_001")
|
|
Log.d("Report", "Attendance: ${report.attendancePercentage}%")
|
|
```
|
|
|
|
---
|
|
|
|
## 🖼️ UI Flow
|
|
|
|
```
|
|
┌─────────────────────┐
|
|
│ Absensi Screen │
|
|
│ (MainActivity) │
|
|
└──────────┬──────────┘
|
|
│
|
|
├─► [Pilih Mata Kuliah] ◄─── Dialog
|
|
│ ↓
|
|
│ [Course Name]
|
|
│ ↓
|
|
├─► [Ambil Foto]
|
|
│ ↓
|
|
│ [Photo Preview]
|
|
│ ↓
|
|
├─► [Get Location]
|
|
│ ↓
|
|
│ [Lat/Long + Validation]
|
|
│ ↓
|
|
└─► [Kirim Absensi]
|
|
↓
|
|
┌────────┴────────┐
|
|
↓ ↓
|
|
N8n Save Local
|
|
(Server) (SharedPreferences)
|
|
↓ ↓
|
|
Google Sheet History View
|
|
```
|
|
|
|
---
|
|
|
|
## 📊 Data Models
|
|
|
|
### Course
|
|
```kotlin
|
|
Course(
|
|
courseId = "COURSE_001",
|
|
courseCode = "PBO2024",
|
|
courseName = "Pemrograman Berorientasi Objek",
|
|
lecturer = "Dr. Imam Riadi",
|
|
credits = 3,
|
|
schedule = "Senin 08:00-09:30",
|
|
room = "A-101",
|
|
semester = 4,
|
|
isActive = true
|
|
)
|
|
```
|
|
|
|
### Attendance
|
|
```kotlin
|
|
Attendance(
|
|
npm = "202310715082",
|
|
nama = "Fazri Abdurrahman",
|
|
courseId = "COURSE_001",
|
|
courseCode = "PBO2024",
|
|
courseName = "Pemrograman Berorientasi Objek",
|
|
latitude = -6.123456,
|
|
longitude = 106.654321,
|
|
date = "2025-01-14",
|
|
time = "08:15:30",
|
|
status = AttendanceStatus.PRESENT,
|
|
isValid = true
|
|
)
|
|
```
|
|
|
|
---
|
|
|
|
## 🧪 Quick Test
|
|
|
|
### Test 1: Lihat Mata Kuliah
|
|
```
|
|
1. Buka app
|
|
2. Scroll down di "Absensi Screen"
|
|
3. Lihat "Pilih Mata Kuliah" button
|
|
4. Klik button
|
|
5. Dialog muncul dengan 5 mata kuliah
|
|
✅ PASS jika 5 mata kuliah terlihat
|
|
```
|
|
|
|
### Test 2: Pilih Mata Kuliah
|
|
```
|
|
1. Dari dialog, pilih "Pemrograman Mobile"
|
|
2. Dialog tutup
|
|
3. Lihat card "Pilih Mata Kuliah"
|
|
4. Lihat "MOBILE2024" dan lecturer
|
|
✅ PASS jika info mata kuliah benar
|
|
```
|
|
|
|
### Test 3: Absensi Lengkap
|
|
```
|
|
1. Pilih mata kuliah
|
|
2. Ambil foto
|
|
3. Tunggu lokasi terdeteksi
|
|
4. Klik "Kirim Absensi"
|
|
5. Tunggu response sukses
|
|
✅ PASS jika pesan sukses muncul
|
|
```
|
|
|
|
---
|
|
|
|
## 🔍 Debugging
|
|
|
|
### Check Local Database
|
|
```kotlin
|
|
val courseService = CourseService(context)
|
|
val courses = courseService.getCourses()
|
|
val attendances = courseService.getAttendances()
|
|
Log.d("DEBUG", "Courses: ${courses.size}")
|
|
Log.d("DEBUG", "Attendances: ${attendances.size}")
|
|
```
|
|
|
|
### View SharedPreferences
|
|
```
|
|
Android Studio > Device Explorer > data > data >
|
|
id.ac.ubharajaya.sistemakademik > shared_prefs >
|
|
course_attendance_db.xml
|
|
```
|
|
|
|
### Enable Logging
|
|
```kotlin
|
|
// Di CourseService.kt atau AttendanceUtils.kt
|
|
Log.d("CourseService", "Save attendance: ${attendance.date}")
|
|
Log.d("AttendanceUtils", "Validate: ${validateAttendance(attendance)}")
|
|
```
|
|
|
|
---
|
|
|
|
## ⚙️ Konfigurasi Penting
|
|
|
|
### Ubah Mata Kuliah
|
|
Edit `CourseConfig.kt`:
|
|
```kotlin
|
|
fun getSampleCourses(): List<Course> {
|
|
return listOf(
|
|
Course(
|
|
courseId = "COURSE_001",
|
|
courseCode = "PBO2024",
|
|
// ... ubah di sini
|
|
),
|
|
// ...
|
|
)
|
|
}
|
|
```
|
|
|
|
### Ubah Threshold Kehadiran
|
|
Edit `CourseConfig.kt`:
|
|
```kotlin
|
|
const val MINIMUM_ATTENDANCE_PERCENTAGE = 80.0
|
|
const val MAX_EXCUSED_ABSENCES = 3
|
|
```
|
|
|
|
### Ubah Webhook URL
|
|
Edit `AttendanceConfig.kt`:
|
|
```kotlin
|
|
const val WEBHOOK_PRODUCTION = "https://n8n.lab.ubharajaya.ac.id/webhook/..."
|
|
const val WEBHOOK_TEST = "https://n8n.lab.ubharajaya.ac.id/webhook-test/..."
|
|
```
|
|
|
|
---
|
|
|
|
## 🐛 Common Issues
|
|
|
|
| Issue | Cause | Solution |
|
|
|-------|-------|----------|
|
|
| "Tidak ada mata kuliah" | Data tidak di-initialize | Panggil `courseService.initializeSampleData()` |
|
|
| Kehadiran tidak tersimpan | SharedPreferences permission | Cek logcat, restart app |
|
|
| Data tidak terkirim N8n | Network error atau webhook URL salah | Cek network, verifikasi webhook |
|
|
| Laporan tidak update | Cache stale | Clear app data atau restart |
|
|
| Dialog mata kuliah tidak muncul | Courses list kosong | Lihat issue pertama |
|
|
|
|
---
|
|
|
|
## 📱 Dependencies
|
|
|
|
```gradle
|
|
implementation("com.google.code.gson:gson:2.10.1")
|
|
implementation("com.google.android.gms:play-services-location:21.0.1")
|
|
```
|
|
|
|
---
|
|
|
|
## 🔗 Related Files
|
|
|
|
| File | Purpose |
|
|
|------|---------|
|
|
| `COURSE_ATTENDANCE_FEATURE.md` | Dokumentasi lengkap fitur |
|
|
| `IMPLEMENTATION_SUMMARY.md` | Ringkasan implementasi |
|
|
| `SAMPLE_DATA.md` | Sample data dan contoh |
|
|
| `ARCHITECTURE.md` | Arsitektur sistem |
|
|
| `DOKUMENTASI.md` | Dokumentasi awal project |
|
|
|
|
---
|
|
|
|
## ✅ Checklist
|
|
|
|
- [x] CourseModels.kt dibuat
|
|
- [x] CourseConfig.kt dibuat
|
|
- [x] CourseService.kt dibuat
|
|
- [x] AttendanceUtils.kt dibuat
|
|
- [x] CourseComponents.kt dibuat
|
|
- [x] CourseScreen.kt dibuat
|
|
- [x] MainActivity.kt diupdate
|
|
- [x] N8nService.kt diupdate dengan method submitAttendanceWithCourse
|
|
- [x] Gson dependency ditambahkan
|
|
- [x] Dokumentasi lengkap dibuat
|
|
|
|
---
|
|
|
|
## 🚀 Next Steps
|
|
|
|
1. **Test UI** - Pastikan semua komponen tampil dengan benar
|
|
2. **Test Data Flow** - Verify data tersimpan dan terkirim
|
|
3. **Test Integration** - Check N8n webhook response
|
|
4. **Customize** - Ubah mata kuliah sesuai kebutuhan
|
|
5. **Deploy** - Build APK dan push ke device
|
|
|
|
---
|
|
|
|
## 📞 Support
|
|
|
|
Jika ada pertanyaan atau issue:
|
|
1. Baca file dokumentasi yang relevan
|
|
2. Check logcat untuk error details
|
|
3. Verify SharedPreferences content di Device Explorer
|
|
4. Test dengan webhook test URL dulu sebelum production
|
|
|
|
---
|
|
|
|
**Last Updated**: 14 Januari 2026
|
|
**Version**: 1.0
|
|
**Status**: ✅ Ready for Testing
|
|
|