refactor: remove unused chart and table widgets for assignment completion and attendance ratio

This commit is contained in:
Yoga Pangestu 2026-03-31 19:52:32 +07:00
parent 6d36fd84af
commit 2f0d8395ed
3 changed files with 0 additions and 226 deletions

View File

@ -1,74 +0,0 @@
<?php
namespace App\Filament\Widgets;
use App\Models\Assignment;
use Filament\Widgets\ChartWidget;
use Illuminate\Database\Eloquent\Builder;
class MyAssignmentCompletionChart extends ChartWidget
{
protected static ?int $sort = 3;
protected ?string $heading = 'Status Penyelesaian Tugas';
protected ?string $maxHeight = '275px';
public static function canView(): bool
{
return auth()->user()?->student !== null;
}
protected function getData(): array
{
$studentId = auth()->user()?->student?->id;
$baseQuery = Assignment::query()
->whereHas('assignmentTargets', function (Builder $query) use ($studentId) {
$query->where('student_id', $studentId)
->orWhereIn('study_group_id', function ($q) use ($studentId) {
$q->select('study_group_id')->from('study_group_members')->where('student_id', $studentId);
})
->orWhereIn('study_group_id', function ($q) use ($studentId) {
$q->select('id')->from('study_groups')->where('leader_id', $studentId);
});
});
$submittedCount = (clone $baseQuery)->whereHas('assignmentSubmissions', function (Builder $query) use ($studentId) {
$query->where('student_id', $studentId)
->orWhereIn('study_group_id', function ($q) use ($studentId) {
$q->select('study_group_id')->from('study_group_members')->where('student_id', $studentId);
})
->orWhereIn('study_group_id', function ($q) use ($studentId) {
$q->select('id')->from('study_groups')->where('leader_id', $studentId);
});
})->count();
$totalCount = $baseQuery->count();
$notSubmittedCount = $totalCount - $submittedCount;
return [
'datasets' => [
[
'label' => 'Tugas',
'data' => [$submittedCount, $notSubmittedCount],
'backgroundColor' => [
'rgba(59, 130, 246, 0.8)', // Blue 500
'rgba(245, 158, 11, 0.8)', // Amber 500
],
'borderColor' => [
'rgba(59, 130, 246, 1)',
'rgba(245, 158, 11, 1)',
],
],
],
'labels' => ['Sudah Dikerjakan', 'Belum Dikerjakan'],
];
}
protected function getType(): string
{
return 'doughnut';
}
}

View File

@ -1,57 +0,0 @@
<?php
namespace App\Filament\Widgets;
use App\Models\Attendance;
use Filament\Widgets\ChartWidget;
class MyAttendanceRatioChart extends ChartWidget
{
protected static ?int $sort = 2;
protected ?string $heading = 'Persentase Presensi';
protected ?string $maxHeight = '275px';
public static function canView(): bool
{
return auth()->user()?->student !== null;
}
protected function getData(): array
{
$studentId = auth()->user()?->student?->id;
$presentCount = Attendance::where('student_id', $studentId)
->whereNotNull('attended_at')
->count();
$absentCount = Attendance::where('student_id', $studentId)
->whereNull('attended_at')
->where('date', '<=', today())
->count();
return [
'datasets' => [
[
'label' => 'Presensi',
'data' => [$presentCount, $absentCount],
'backgroundColor' => [
'rgba(16, 185, 129, 0.8)', // Emerald 500
'rgba(244, 63, 94, 0.8)', // Rose 500
],
'borderColor' => [
'rgba(16, 185, 129, 1)',
'rgba(244, 63, 94, 1)',
],
],
],
'labels' => ['Hadir', 'Tidak / Belum Hadir'],
];
}
protected function getType(): string
{
return 'doughnut';
}
}

View File

@ -1,95 +0,0 @@
<?php
namespace App\Filament\Widgets;
use App\Models\Assignment;
use Filament\Actions\Action;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
use Filament\Widgets\TableWidget as BaseWidget;
use Illuminate\Database\Eloquent\Builder;
class MyPendingAssignmentsTable extends BaseWidget
{
protected static ?int $sort = 4;
protected int|string|array $columnSpan = 'full';
protected static ?string $heading = 'Tugas Mendatang yang Belum Selesai';
public static function canView(): bool
{
return auth()->user()?->student !== null;
}
public function table(Table $table): Table
{
$studentId = auth()->user()?->student?->id;
return $table
->query(
Assignment::query()
->whereHas('assignmentTargets', function (Builder $query) use ($studentId) {
$query->where('student_id', $studentId)
->orWhereIn('study_group_id', function ($q) use ($studentId) {
$q->select('study_group_id')
->from('study_group_members')
->where('student_id', $studentId);
})
->orWhereIn('study_group_id', function ($q) use ($studentId) {
$q->select('id')
->from('study_groups')
->where('leader_id', $studentId);
});
})
->whereDoesntHave('assignmentSubmissions', function (Builder $query) use ($studentId) {
$query->where('student_id', $studentId)
->orWhereIn('study_group_id', function ($q) use ($studentId) {
$q->select('study_group_id')
->from('study_group_members')
->where('student_id', $studentId);
})
->orWhereIn('study_group_id', function ($q) use ($studentId) {
$q->select('id')
->from('study_groups')
->where('leader_id', $studentId);
});
})
->where('due_date', '>=', now())
->orderBy('due_date', 'asc')
)
->columns([
TextColumn::make('title')
->label('Judul Tugas')
->searchable()
->sortable()
->wrap(),
TextColumn::make('course.name')
->label('Mata Kuliah')
->searchable()
->sortable()
->wrap(),
TextColumn::make('type')
->label('Jenis')
->badge(),
TextColumn::make('due_date')
->label('Tenggat Waktu')
->dateTime('d M Y H:i')
->sortable()
->color(fn (Assignment $record) => $record->due_date < now()->addDays(2) ? 'danger' : 'warning'),
])
->recordActions([
Action::make('kerjakan')
->label('Lihat Detail & Kerjakan')
->url(fn (Assignment $record): string => '/admin/learning/assignments/'.$record->id.'/submit')
->icon('heroicon-m-arrow-top-right-on-square')
->button()
->color('primary'),
])
->emptyStateHeading('Tidak Ada Tugas')
->emptyStateDescription('Semua tugas telah diselesaikan atau tidak ada tugas mendatang.');
}
}