From a59a4c1d2bbaa9b9cca2c15a2f62721e12045438 Mon Sep 17 00:00:00 2001 From: Matt Young Date: Wed, 10 Jul 2024 03:26:49 -0500 Subject: [PATCH] Seating page implemented other than doublers --- app/Actions/Tabulation/AllJudgesCount.php | 4 +-- .../Tabulation/SeatAuditionController.php | 29 +++++++++++++++---- app/Http/Controllers/TestController.php | 9 ++++-- .../auditionSeating-results-table.blade.php | 22 +++++++------- .../tabulation/auditionSeating.blade.php | 22 +++++++------- resources/views/test.blade.php | 2 +- 6 files changed, 53 insertions(+), 35 deletions(-) diff --git a/app/Actions/Tabulation/AllJudgesCount.php b/app/Actions/Tabulation/AllJudgesCount.php index 2e2655a..15ba4c8 100644 --- a/app/Actions/Tabulation/AllJudgesCount.php +++ b/app/Actions/Tabulation/AllJudgesCount.php @@ -58,8 +58,8 @@ class AllJudgesCount implements CalculateEntryScore protected function areAllJudgesValid(Entry $entry): void { - $validJudgeIds = $entry->audition->judges->pluck('id')->sort()->toArray(); - $existingJudgeIds = $entry->scoreSheets->pluck('user_id')->sort()->toArray(); + $validJudgeIds = $entry->audition->judges->sort()->pluck('id')->toArray(); + $existingJudgeIds = $entry->scoreSheets->sort()->pluck('user_id')->toArray(); if ($validJudgeIds !== $existingJudgeIds) { throw new TabulationException('Score exists from a judge not assigned to this audition'); } diff --git a/app/Http/Controllers/Tabulation/SeatAuditionController.php b/app/Http/Controllers/Tabulation/SeatAuditionController.php index 5b0a95f..3f13d7c 100644 --- a/app/Http/Controllers/Tabulation/SeatAuditionController.php +++ b/app/Http/Controllers/Tabulation/SeatAuditionController.php @@ -2,26 +2,43 @@ namespace App\Http\Controllers\Tabulation; +use App\Actions\Tabulation\CalculateEntryScore; +use App\Exceptions\TabulationException; use App\Http\Controllers\Controller; +use App\Models\Audition; use App\Models\Entry; use Illuminate\Http\Request; class SeatAuditionController extends Controller { - /** - * Handle the incoming request. - */ - public function __invoke(Request $request) + protected CalculateEntryScore $calc; + + public function __construct(CalculateEntryScore $calc) + { + $this->calc = $calc; + } + + public function __invoke(Request $request, Audition $audition) { $entryData = []; - $entries = Entry::forSeating()->with('student.school')->get(); + $entries = Entry::forSeating()->with('student.school')->where('audition_id', $audition->id)->get(); foreach ($entries as $entry) { + try { + $totalScore = $this->calc->calculate('seating', $entry); + } catch (TabulationException $ex) { + $totalScore[0] = $ex->getMessage(); + } $entryData[] = [ - 'rank' => 'xx', + 'rank' => 'not implemented', 'id' => $entry->id, 'studentName' => $entry->student->full_name(), 'schoolName' => $entry->student->school->name, + 'drawNumber' => $entry->draw_number, + 'totalScore' => $totalScore[0], ]; } + + //dd($entryData); + return view('tabulation.auditionSeating', ['entryData' => $entryData, 'audition' => $audition]); } } diff --git a/app/Http/Controllers/TestController.php b/app/Http/Controllers/TestController.php index 21b2b16..0d68144 100644 --- a/app/Http/Controllers/TestController.php +++ b/app/Http/Controllers/TestController.php @@ -3,8 +3,10 @@ namespace App\Http\Controllers; use App\Actions\Tabulation\CalculateEntryScore; +use App\Actions\Tabulation\CalculateScoreSheetTotal; use App\Exceptions\TabulationException; use App\Models\Entry; +use App\Models\User; class TestController extends Controller { @@ -16,7 +18,7 @@ class TestController extends Controller public function flashTest() { - $entries = Entry::forSeating()->with('student')->where('audition_id', 19)->get(); + $entries = Entry::forSeating()->with('student')->where('audition_id', 17)->get(); $rows = []; foreach ($entries as $entry) { try { @@ -29,7 +31,8 @@ class TestController extends Controller 'totalScore' => $totalScore, ]; } - + $scoreCalc = new CalculateScoreSheetTotal; + $bam = $scoreCalc('seating', Entry::find(916), User::find(65))[0]; // try { // $test = $this->bigCalc->calculate('seating', Entry::find(1061))[0]; // } catch (TabulationException $ex) { @@ -39,6 +42,6 @@ class TestController extends Controller - return view('test', compact('rows')); + return view('test', compact('rows', 'bam')); } } diff --git a/resources/views/tabulation/auditionSeating-results-table.blade.php b/resources/views/tabulation/auditionSeating-results-table.blade.php index 2877e03..4b47689 100644 --- a/resources/views/tabulation/auditionSeating-results-table.blade.php +++ b/resources/views/tabulation/auditionSeating-results-table.blade.php @@ -16,23 +16,23 @@ - @foreach($entries as $entry) + @foreach($entryData as $entry) - {{ $entry->rank }} - {{ $entry->id }} - {{ $entry->draw_number }} + {{ $entry['rank'] }} + {{ $entry['id'] }} + {{ $entry['drawNumber'] }} - {{ $entry->student->full_name() }} - {{ $entry->student->school->name }} + {{ $entry['studentName'] }} + {{ $entry['schoolName'] }} - @if($doublerService->studentIsDoubler($entry->student_id)) - @include('tabulation.auditionSeating-doubler-block') - @endif +{{-- @if($doublerService->studentIsDoubler($entry->student_id))--}} +{{-- @include('tabulation.auditionSeating-doubler-block')--}} +{{-- @endif--}} - {{ number_format($entry->final_score_array[0] ?? 0,4) }} + {{ $entry['totalScore'] }} - @if($entry->scoring_complete) + @if(is_numeric($entry['totalScore'])) @endif diff --git a/resources/views/tabulation/auditionSeating.blade.php b/resources/views/tabulation/auditionSeating.blade.php index c916ff8..17292b9 100644 --- a/resources/views/tabulation/auditionSeating.blade.php +++ b/resources/views/tabulation/auditionSeating.blade.php @@ -9,21 +9,19 @@
@include('tabulation.auditionSeating-results-table')
-
- @if($audition->hasFlag('seats_published')) - @include('tabulation.auditionSeating-show-published-seats') - @elseif(! $auditionComplete) - @include('tabulation.auditionSeating-unable-to-seat-card') - @else - @include('tabulation.auditionSeating-fill-seats-form') - @include('tabulation.auditionSeating-show-proposed-seats') - @endif +{{--
--}} +{{-- @if($audition->hasFlag('seats_published'))--}} +{{-- @include('tabulation.auditionSeating-show-published-seats')--}} +{{-- @elseif(! $auditionComplete)--}} +{{-- @include('tabulation.auditionSeating-unable-to-seat-card')--}} +{{-- @else--}} +{{-- @include('tabulation.auditionSeating-fill-seats-form')--}} +{{-- @include('tabulation.auditionSeating-show-proposed-seats')--}} +{{-- @endif--}} -
+{{--
--}} - -{{--TODO deal with unlikely scenario of a doubler is entered for seating on some auditions but not others--}} diff --git a/resources/views/test.blade.php b/resources/views/test.blade.php index f891ab6..ff56041 100644 --- a/resources/views/test.blade.php +++ b/resources/views/test.blade.php @@ -6,7 +6,7 @@ @inject('seatingService','App\Services\SeatingService') @inject('drawService', 'App\Services\DrawService') - Test Page + Test Page - {{ $bam ?? '' }} @foreach($rows as $row) {{ $row['name'] }} - {{ $row['totalScore'] }}
@endforeach