@php
$totalDepartmentsScore = 0;
$departmentsCount = count($departments);
@endphp
@foreach ($departments as $department)
@php
$totalStandardScore = 0;
$totalStandards = $department->standards->count();
foreach ($department->standards as $standard) {
$totalIndicatorScore = 0;
$totalIndicators = $standard->indicators->count();
foreach ($standard->indicators as $indicator) {
$totalParagraphScore = 0;
$totalParagraphs = $indicator->paragraphs->count();
foreach ($indicator->paragraphs as $paragraph) {
$totalRequirementsScore = 0;
$totalRequirements = $paragraph->requirements->count();
foreach ($paragraph->requirements as $requirement) {
$documentExists = $requirement->files
->where('school_id', auth()->user()->school_id)
->first()
? 1
: 0;
$score = $documentExists ? 4 : 0;
$totalRequirementsScore += $score;
}
$paragraphScore =
$totalRequirements > 0
? $totalRequirementsScore / $totalRequirements
: 0;
$totalParagraphScore += $paragraphScore;
}
$indicatorScore =
$totalParagraphs > 0 ? $totalParagraphScore / $totalParagraphs : 0;
$totalIndicatorScore += $indicatorScore;
}
$standardScore =
$totalIndicators > 0 ? $totalIndicatorScore / $totalIndicators : 0;
$totalStandardScore += $standardScore;
}
$departmentScore = $totalStandards > 0 ? $totalStandardScore / $totalStandards : 0;
$totalDepartmentsScore += $departmentScore;
// تحديد لون شريط التقدم بناءً على الدرجة
if ($departmentScore < 1) {
$color = '#dc3545'; // أحمر
} elseif ($departmentScore < 2) {
$color = '#ffc107'; // أصفر
} elseif ($departmentScore < 3) {
$color = '#17a2b8'; // أزرق
} else {
$color = '#28a745'; // أخضر
}
@endphp
{{ $department->name }}
{{ number_format(($departmentScore / 4) * 100, 1) }}%
{{ number_format($departmentScore, 1) }} / 4
@endforeach
{{-- بطاقة الدرجة العامة للمدرسة --}}
الدرجة العامة للمدرسة
@if ($departmentsCount > 0)
@php
$averageSchoolScore = $totalDepartmentsScore / $departmentsCount;
if ($averageSchoolScore < 1) {
$color = '#dc3545'; // أحمر
} elseif ($averageSchoolScore < 2) {
$color = '#ffc107'; // أصفر
} elseif ($averageSchoolScore < 3) {
$color = '#17a2b8'; // أزرق
} else {
$color = '#28a745'; // أخضر
}
@endphp
{{ number_format(($averageSchoolScore / 4) * 100, 1) }}%
{{ number_format($averageSchoolScore, 1) }} / 4
@else
0 / 4
@endif
{{-- نهاية بطاقة الدرجة العامة للمدرسة --}}