@extends('layouts.master') @section('page_title', 'Tabulation Sheet') @section('content')
Tabulation Sheet
{!! Qs::getPanelOptions() !!}
@csrf
{{--if Selction Has Been Made --}} @if($selected)
Tabulation Sheet for {{ $my_class->name }} {{ $section->name ?? '' }} {{ $ex->name }}
@foreach($subjects as $sub) @endforeach {{--@if($ex->term == 3) @endif--}} @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 @foreach($subjects as $sub) @endforeach @endforeach
# NAMES_OF_STUDENTS_IN_CLASS{{ strtoupper($sub->slug ?: $sub->name) }}1ST TERM TOTAL 2ND TERM TOTAL 3RD TERM TOTAL CUM Total CUM AverageTotal Average Position
{{ $rank }} {{ $s->user->name }} {{ $marks->where('student_id', $s->user_id) ->where('subject_id', $sub->id) ->first()->$tex ?? '-' }} {{ $s->computed_total ?: '-' }} {{ $student_average ?: '-' }} {!! Mk::getSuffix($rank) !!}
{{--Print Button--}}
@endif @endsection