| # |
NAMES_OF_STUDENTS_IN_CLASS |
@foreach($subjects as $sub)
{{ strtoupper($sub->slug ?: $sub->name) }} |
@endforeach
{{--@if($ex->term == 3)
1ST TERM TOTAL |
2ND TERM TOTAL |
3RD TERM TOTAL |
CUM Total |
CUM Average |
@endif--}}
Total |
Average |
Position |
@php
// Sort students descending by total marks
$students = $students->map(function ($s) use ($marks, $tex, $subjects, $exam_id) {
$s->computed_total = $marks
->where('student_id', $s->user_id)
->where('exam_id', $exam_id)
->sum($tex);
return $s;
})->sortByDesc('computed_total')->values();
$prev_total = null;
$rank = 0;
$position = 0;
@endphp
@foreach($students as $index => $s)
@php
// Compare current student's total with previous
if ($s->computed_total !== $prev_total) {
$rank = ++$position;
$prev_total = $s->computed_total;
}
$subject_count = $subjects->count();
$student_average = $subject_count > 0 ? round($s->computed_total / $subject_count, 2) : '-';
@endphp
| {{ $rank }} |
{{ $s->user->name }} |
@foreach($subjects as $sub)
{{ $marks->where('student_id', $s->user_id)
->where('subject_id', $sub->id)
->first()->$tex ?? '-' }}
|
@endforeach
{{ $s->computed_total ?: '-' }} |
{{ $student_average ?: '-' }} |
{!! Mk::getSuffix($rank) !!} |
@endforeach
{{--Print/Export Buttons--}}