From 31d56e5b90134954162533e153d0190999a2efd8 Mon Sep 17 00:00:00 2001 From: Matt Young Date: Wed, 15 Oct 2025 14:02:41 -0500 Subject: [PATCH] Show failed prelim scores on seating page --- .../Tabulation/Seating/ShowAuditionSeatingPage.php | 5 +++++ app/Models/Entry.php | 12 ++++++++++++ .../seating-page/failed-prelim-entries.blade.php | 2 ++ 3 files changed, 19 insertions(+) diff --git a/app/Http/Controllers/Tabulation/Seating/ShowAuditionSeatingPage.php b/app/Http/Controllers/Tabulation/Seating/ShowAuditionSeatingPage.php index 79d6b52..7f92acf 100644 --- a/app/Http/Controllers/Tabulation/Seating/ShowAuditionSeatingPage.php +++ b/app/Http/Controllers/Tabulation/Seating/ShowAuditionSeatingPage.php @@ -69,9 +69,14 @@ class ShowAuditionSeatingPage extends Controller $query->where('flag_name', 'failed_prelim'); }) ->with('student.school') + ->with('PrelimScoreSheets') ->orderBy('draw_number') ->get(); + $failed_prelim_entries = $failed_prelim_entries->sortByDesc(function ($entry) { + return $entry->prelimTotalScore(); + }); + // Get Doublers $doublerData = Doubler::where('event_id', $audition->event_id) ->whereIn('student_id', $scored_entries->pluck('student_id')) diff --git a/app/Models/Entry.php b/app/Models/Entry.php index f4207e2..a64e1cf 100644 --- a/app/Models/Entry.php +++ b/app/Models/Entry.php @@ -141,6 +141,18 @@ class Entry extends Model return $this->hasMany(PrelimScoreSheet::class); } + public function prelimTotalScore() + { + return once(function () { + $total = 0; + foreach ($this->prelimScoreSheets as $sheet) { + $total += $sheet->total; + } + + return $total / $this->prelimScoreSheets->count(); + }); + } + public function prelimResult() { if ($this->hasFlag('passed_prelim')) { diff --git a/resources/views/tabulation/seating-page/failed-prelim-entries.blade.php b/resources/views/tabulation/seating-page/failed-prelim-entries.blade.php index 6f76da6..669a390 100644 --- a/resources/views/tabulation/seating-page/failed-prelim-entries.blade.php +++ b/resources/views/tabulation/seating-page/failed-prelim-entries.blade.php @@ -6,6 +6,7 @@ Draw # ID Student + Score @@ -17,6 +18,7 @@ {{ $entry->student->full_name() }} {{ $entry->student->school->name }} + {{ $entry->prelimTotalScore() }} @endforeach