@extends('layouts.main_dashboard.app') @section('title', $child->name) @section('skip_page_hero', true) @php $isArabic = app()->getLocale() === 'ar'; @endphp @section('content')
{{-- Header --}}

{{ $child->name }}

{{ $child->schoolClass->map->name->join(' / ') }}

{{-- Summary Cards --}} @php $avgMark = $marks->whereNotNull('mark')->avg('mark'); $submittedCount = collect($assignments)->where('submitted', true)->count(); $totalAssignments = collect($assignments)->count(); $quizAvg = $quizResults->whereNotNull('pct')->avg('pct'); @endphp

{{ $avgMark ? number_format($avgMark, 1) : '—' }}

{{ $isArabic ? 'متوسط الدرجات' : 'Avg. Mark' }}

{{ $attendanceSummary['pct'] !== null ? $attendanceSummary['pct'].'%' : '—' }}

{{ $isArabic ? 'نسبة الحضور' : 'Attendance' }}

{{ $submittedCount }}/{{ $totalAssignments }}

{{ $isArabic ? 'الواجبات المسلّمة' : 'Assignments' }}

{{ $quizAvg ? number_format($quizAvg, 0).'%' : '—' }}

{{ $isArabic ? 'متوسط الاختبارات' : 'Quiz Avg.' }}

{{-- Marks Trend Chart --}} @if($marksTrend->isNotEmpty())

{{ $isArabic ? 'مسار الدرجات' : 'Marks Trend' }}

@endif {{-- Per-Subject Breakdown --}} @if($marksBySubject->isNotEmpty())

{{ $isArabic ? 'الأداء حسب المادة' : 'Performance by Subject' }}

@foreach($marksBySubject as $subject => $data)

{{ $subject }}

{{ $data['count'] }} {{ $isArabic ? 'درجة' : 'marks' }}

@php $pct = min(100, max(0, ($data['avg'] / 100) * 100)); @endphp
{{ $data['avg'] }}
@endforeach
@endif {{-- Attendance Summary --}}

{{ $isArabic ? 'الحضور والغياب' : 'Attendance' }}

{{ $attendanceSummary['total'] }}

{{ $isArabic ? 'إجمالي الحصص' : 'Total' }}

{{ $attendanceSummary['present'] }}

{{ $isArabic ? 'حاضر' : 'Present' }}

{{ $attendanceSummary['absent'] }}

{{ $isArabic ? 'غائب' : 'Absent' }}

{{ $attendanceSummary['pct'] !== null ? $attendanceSummary['pct'].'%' : '—' }}

{{ $isArabic ? 'نسبة الحضور' : 'Rate' }}

{{-- Quiz Results --}} @if($quizResults->isNotEmpty())

{{ $isArabic ? 'نتائج الاختبارات' : 'Quiz Results' }}

@foreach($quizResults as $qr)

{{ $qr['title'] }}

{{ $qr['subject'] }} · {{ $qr['date'] }}

{{ $qr['score'] }}/{{ $qr['max'] }} {{ $qr['pct'] !== null ? $qr['pct'].'%' : '—' }}
@endforeach
@endif {{-- Marks List --}}

{{ $isArabic ? 'الدرجات التفصيلية' : 'Detailed Marks' }}

@if($marks->isEmpty())
{{ $isArabic ? 'لا توجد درجات منشورة.' : 'No published marks yet.' }}
@else
@foreach($marks->sortByDesc(fn($ms) => $ms->mark->date) as $ms)

{{ $ms->mark->title }}

{{ $ms->mark->course?->subject?->name }} @if($ms->mark->date) · {{ $ms->mark->date->format('Y-m-d') }} @endif

@if($ms->absent) {{ $isArabic ? 'غائب' : 'Absent' }} @else {{ $ms->mark }} @endif
@endforeach
@endif
{{-- Assignments --}}

{{ $isArabic ? 'الواجبات' : 'Assignments' }}

@if(collect($assignments)->isEmpty())
{{ $isArabic ? 'لا توجد واجبات.' : 'No assignments.' }}
@else
@foreach($assignments as $a)

{{ $a['title'] }}

{{ $a['subject'] }} @if($a['due_date']) · {{ $a['due_date']->format('Y-m-d') }} @endif

@if($a['submitted']) {{ $isArabic ? 'تم التسليم' : 'Submitted' }} @elseif($a['late']) {{ $isArabic ? 'متأخر' : 'Late' }} @else {{ $isArabic ? 'بانتظار التسليم' : 'Pending' }} @endif
@endforeach
@endif
{{-- Export --}} @php $childCourseIds = \App\Models\Course::whereIn('school_class_id', $child->schoolClass->pluck('id'))->pluck('id'); @endphp

{{ $isArabic ? 'تصدير التقارير' : 'Export Reports' }}

{{ $isArabic ? 'تقرير شامل' : 'Full Report' }} @foreach(\App\Models\Course::whereIn('id', $childCourseIds)->with('subject')->get() as $c) @endforeach
@endsection @if($marksTrend->isNotEmpty()) @push('scripts') @endpush @endif