{{ app()->getLocale() === 'ar' ? 'المقرر: ' : 'Course: ' }}{{ $course->name }}
{{ app()->getLocale() === 'ar' ? 'المادة: ' : 'Subject: ' }}{{ $course->subject?->name ?? '—' }}
{{ app()->getLocale() === 'ar' ? 'الفصل: ' : 'Class: ' }}{{ $course->schoolClass?->name ?? '—' }}
{{ app()->getLocale() === 'ar' ? 'عدد الجلسات: ' : 'Sessions: ' }}{{ $attendances->count() }}
@php
$totalSessions = $attendances->count();
$totalStudents = $students->count();
$totalAbsences = $absentMap->sum(fn($ids) => $ids->count());
$avgAttendance = $totalStudents > 0 && $totalSessions > 0
? round((($totalStudents * $totalSessions - $totalAbsences) / ($totalStudents * $totalSessions)) * 100)
: 100;
$perfectAttendance = $students->filter(fn($s) => ($absentMap[$s->id] ?? collect())->isEmpty())->count();
@endphp