diff --git a/app/Actions/Entries/GetEntrySeatingResult.php b/app/Actions/Entries/GetEntrySeatingResult.php new file mode 100644 index 0000000..054c06f --- /dev/null +++ b/app/Actions/Entries/GetEntrySeatingResult.php @@ -0,0 +1,40 @@ +getResult($entry); + } + + public function getResult(Entry $entry): string + { + if ($entry->hasFlag('no_show')) { + return 'No Show'; + } + + if ($entry->hasFlag('declined')) { + return 'Declined'; + } + + if ($entry->hasFlag('failed_prelim')) { + return 'Did not pass prelim'; + } + + $seat = Seat::where('entry_id', $entry->id)->first(); + if ($seat) { + return $seat->ensemble->name.' '.$seat->seat; + } + + return 'Entry not seated'; + } +} diff --git a/app/Actions/Tabulation/RankAuditionEntries.php b/app/Actions/Tabulation/RankAuditionEntries.php index f5619dd..7071ff2 100644 --- a/app/Actions/Tabulation/RankAuditionEntries.php +++ b/app/Actions/Tabulation/RankAuditionEntries.php @@ -66,8 +66,10 @@ class RankAuditionEntries return 0; }); $rank = 1; + $rawRank = 1; foreach ($entries as $entry) { $entry->rank = $rank; + $entry->raw_rank = $rawRank; // We don't really get a rank for seating if we have certain flags if ($mode === 'seating') { if ($entry->hasFlag('declined')) { @@ -82,6 +84,7 @@ class RankAuditionEntries if (is_numeric($entry->rank)) { $rank++; } + $rawRank++; } return $entries; diff --git a/app/Http/Controllers/DashboardController.php b/app/Http/Controllers/DashboardController.php index b9f93c6..39233ae 100644 --- a/app/Http/Controllers/DashboardController.php +++ b/app/Http/Controllers/DashboardController.php @@ -2,6 +2,9 @@ namespace App\Http\Controllers; +use App\Actions\Entries\GetEntrySeatingResult; +use App\Actions\Tabulation\CalculateEntryScore; +use App\Actions\Tabulation\RankAuditionEntries; use App\Models\School; use App\Services\Invoice\InvoiceDataService; use Illuminate\Support\Facades\Auth; @@ -22,9 +25,31 @@ class DashboardController extends Controller return view('dashboard.profile'); } - public function dashboard() - { - return view('dashboard.dashboard'); + public function dashboard( + CalculateEntryScore $scoreCalc, + GetEntrySeatingResult $resultGenerator, + RankAuditionEntries $ranker + ) { + $entries = Auth::user()->entries; + $entries = $entries->filter(function ($entry) { + return $entry->audition->hasFlag('seats_published'); + }); + $entries = $entries->sortBy(function ($entry) { + return $entry->student->full_name(true); + }); + $scores = []; + $results = []; + $ranks = []; + foreach ($entries as $entry) { + $results[$entry->id] = $resultGenerator->getResult($entry); + if (! $entry->hasFlag('no_show') && ! $entry->hasFlag('failed_prelim')) { + $scores[$entry->id] = $scoreCalc->calculate('seating', $entry); + $auditionResults = $ranker->rank('seating', $entry->audition); + $ranks[$entry->id] = $auditionResults->firstWhere('id', $entry->id)->raw_rank; + } + } + + return view('dashboard.dashboard', compact('entries', 'scores', 'results', 'ranks')); } public function my_school() diff --git a/app/Http/Controllers/Tabulation/EntryFlagController.php b/app/Http/Controllers/Tabulation/EntryFlagController.php index bd0aed0..fdbe9fe 100644 --- a/app/Http/Controllers/Tabulation/EntryFlagController.php +++ b/app/Http/Controllers/Tabulation/EntryFlagController.php @@ -3,7 +3,9 @@ namespace App\Http\Controllers\Tabulation; use App\Http\Controllers\Controller; +use App\Models\CalculatedScore; use App\Models\Entry; +use App\Models\ScoreSheet; use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; @@ -79,7 +81,8 @@ class EntryFlagController extends Controller DB::table('score_sheets')->where('entry_id', $entry->id)->delete(); $entry->addFlag('no_show'); - + ScoreSheet::where('entry_id', $entry->id)->delete(); + CalculatedScore::where('entry_id', $entry->id)->delete(); $msg = 'No Show has been entered for '.$entry->audition->name.' #'.$entry->draw_number.' (ID: '.$entry->id.').'; return to_route('entry-flags.noShowSelect')->with('success', $msg); diff --git a/resources/views/dashboard/dashboard.blade.php b/resources/views/dashboard/dashboard.blade.php index a75d84f..0b0905a 100644 --- a/resources/views/dashboard/dashboard.blade.php +++ b/resources/views/dashboard/dashboard.blade.php @@ -2,7 +2,8 @@ Dashboard @if(! Auth::user()->school_id) - You aren't currently associated with a school. Click here to choose or create one. + You aren't currently associated with a school. Click + here to choose or create one. @endif {{-- Column 1 --}} @@ -29,6 +30,15 @@ + @if(Auth::user()->school_id) + {{-- Column 2 Results --}} + + My Results + @include('dashboard.results-table') + + + @endif + diff --git a/resources/views/dashboard/results-table.blade.php b/resources/views/dashboard/results-table.blade.php new file mode 100644 index 0000000..8fd40f6 --- /dev/null +++ b/resources/views/dashboard/results-table.blade.php @@ -0,0 +1,24 @@ + + + Student + Audition + Score + Rank + Result + + + @foreach($entries as $entry) + + {{ $entry->student->full_name() }} + {{ $entry->audition->name }} + @if(! $entry->audition->hasFlag('seats_published')) + Results not available + @else + {{ $scores[$entry->id ][0] }} + {{ $ranks[$entry->id ] }} + {{ $results[$entry->id ] }} + @endif + + @endforeach + +
You aren't currently associated with a school. Click here to choose or create one.
You aren't currently associated with a school. Click + here to choose or create one.