Penambahan Akses Laman Dosen dab perbaikan fix

This commit is contained in:
Ariyutta
2026-11-09 12:01:30 +07:00
parent 33bc1233f7
commit ef46b84da8
48 changed files with 3018 additions and 131 deletions
+41 -3
View File
@@ -2,16 +2,34 @@
namespace App\Http\Controllers\Dosen;
use App\Http\Controllers\Dosen\Concerns\UsesLegacyLecturer;
use App\Http\Controllers\Prototype\ResourceController;
use App\Support\Legacy\LecturerClasses;
use App\Support\Prototype\DosenData;
use Illuminate\Contracts\View\View;
use Illuminate\Support\Collection;
class KelasController extends ResourceController
{
use UsesLegacyLecturer;
/** Kelas dosen DB lama pada periodenya (kosong bila tidak ada kelas). */
private function legacyClasses(): Collection
{
$classes = app(LecturerClasses::class);
$periode = $classes->period($this->lecturerId());
return $periode === null ? collect() : $classes->classes($this->lecturerId(), $periode['id']);
}
protected function rows(): Collection
{
return DosenData::kelas();
return $this->isLegacy() ? $this->legacyClasses() : DosenData::kelas();
}
protected function satuStyle(): bool
{
return true;
}
protected function routeBase(): string
@@ -36,6 +54,11 @@ class KelasController extends ResourceController
protected function filters(): array
{
// Kelas DB lama bisa bertemu di beberapa hari, jadi filter hari hanya untuk data prototipe.
if ($this->isLegacy()) {
return [];
}
return [['name' => 'hari', 'label' => 'Hari', 'options' => array_combine(['Senin', 'Selasa', 'Rabu', 'Kamis', 'Jumat'], ['Senin', 'Selasa', 'Rabu', 'Kamis', 'Jumat'])]];
}
@@ -45,9 +68,9 @@ class KelasController extends ResourceController
['label' => 'Kode', 'key' => 'kode'],
['label' => 'Mata kuliah', 'value' => fn (array $r): string => "{$r['matkul']} ({$r['kelas']})"],
['label' => 'SKS', 'key' => 'sks', 'class' => 'num'],
['label' => 'Jadwal', 'value' => fn (array $r): string => "{$r['hari']}, {$r['jam']}"],
['label' => 'Jadwal', 'value' => fn (array $r): string => $r['jadwal'] ?? "{$r['hari']}, {$r['jam']}"],
['label' => 'Ruang', 'key' => 'ruang'],
['label' => 'Peserta', 'value' => fn (array $r): string => "{$r['peserta']} / {$r['kapasitas']}", 'class' => 'num'],
['label' => 'Peserta', 'value' => fn (array $r): string => $r['peserta'].(($r['kapasitas'] ?? null) ? " / {$r['kapasitas']}" : ''), 'class' => 'num'],
];
}
@@ -59,6 +82,21 @@ class KelasController extends ResourceController
public function show(string $record): View
{
$kelas = $this->find($record);
if ($this->isLegacy()) {
$students = app(LecturerClasses::class)->students($kelas['id']);
$terisi = $students->whereNotNull('hadir');
return view('dosen.kelas.show-legacy', [
'kelas' => $kelas,
'peserta' => $students,
'batas' => DosenData::BATAS_HADIR,
'rataHadir' => $kelas['pertemuan'] === null || $terisi->isEmpty()
? null
: (int) round($terisi->avg(fn (array $s): float => min($s['hadir'] / $kelas['pertemuan'] * 100, 100))),
]);
}
$tab = request()->query('tab') === 'pertemuan' ? 'pertemuan' : 'peserta';
$rekap = DosenData::rekap($kelas);