Show failed prelim scores on seating page

This commit is contained in:
Matt Young 2025-10-15 14:02:41 -05:00
parent b2d66eb1b8
commit 31d56e5b90
3 changed files with 19 additions and 0 deletions

View File

@ -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'))

View File

@ -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')) {

View File

@ -6,6 +6,7 @@
<x-table.th>Draw #</x-table.th>
<x-table.th>ID</x-table.th>
<x-table.th>Student</x-table.th>
<x-table.th>Score</x-table.th>
</tr>
</thead>
<tbody>
@ -17,6 +18,7 @@
<span>{{ $entry->student->full_name() }}</span>
<span class="text-xs text-gray-400">{{ $entry->student->school->name }}</span>
</x-table.td>
<x-table.td>{{ $entry->prelimTotalScore() }}</x-table.td>
</tr>
@endforeach
</tbody>