diff --git a/app/Http/Controllers/DashboardRplController.php b/app/Http/Controllers/DashboardRplController.php index 6c7040e..396014c 100644 --- a/app/Http/Controllers/DashboardRplController.php +++ b/app/Http/Controllers/DashboardRplController.php @@ -101,6 +101,36 @@ public function index(Request $request) ], ]; + + $siswaDataLearning = Siswa::where('user_id', $userId) + ->where('kategori', 'Learning') + ->get() + ->groupBy('materi_id') + ->map(function ($items) use ($totalWaktuLearning) { + $totalTime = $items->sum(function ($item) { + if ($item->waktu_mulai && $item->waktu_selesai) { + $waktuMulai = Carbon::parse($item->waktu_mulai); + $waktuSelesai = Carbon::parse($item->waktu_selesai); + return $waktuSelesai->greaterThan($waktuMulai) ? $waktuSelesai->diffInSeconds($waktuMulai) : 0; + } + return 0; + }); + + $percentage = $totalWaktuLearning ? ($totalTime / $totalWaktuLearning) * 100 : 0; + return ['totalTime' => $totalTime, 'percentage' => $percentage]; + }); + + $learningChartData = [ + 'labels' => $materiNamesLearning->values(), + 'datasets' => [ + [ + 'data' => $siswaDataLearning->pluck('percentage')->values(), + 'backgroundColor' => ['#FF6384', '#36A2EB', '#FFCE56', '#4BC0C0', '#9966FF'], + ] + ] + ]; + + $activityData = $jumlahAktivitasLearning; return view('dashboardrpl', compact( @@ -109,11 +139,13 @@ public function index(Request $request) 'totalWaktu', 'persentaseLearning', 'persentaseProject', + 'chartData', + 'learningChartData', + 'activityData', 'aktivitasNames', 'siswaData', 'chartData', 'activityData' )); - } } diff --git a/resources/views/dashboardrpl.blade.php b/resources/views/dashboardrpl.blade.php index 15c509f..2a3552d 100644 --- a/resources/views/dashboardrpl.blade.php +++ b/resources/views/dashboardrpl.blade.php @@ -116,10 +116,10 @@ class="btn btn-sm btn-outline-dark d-flex align-items-center">
Persentase Waktu Per Learning
- +
-
@@ -128,7 +128,7 @@ class="btn btn-sm btn-outline-dark d-flex align-items-center">
Persentase Waktu Per Project
- +
-
@@ -146,6 +145,35 @@ class="btn btn-sm btn-outline-dark d-flex align-items-center"> diff --git a/resources/views/monitoring_siswa/siswarpl.blade.php b/resources/views/monitoring_siswa/siswarpl.blade.php index ee52589..1bc8e94 100644 --- a/resources/views/monitoring_siswa/siswarpl.blade.php +++ b/resources/views/monitoring_siswa/siswarpl.blade.php @@ -500,10 +500,4 @@ function toggleMateriDropdown(selectId, materi2Id) { } } - - - - - -