Auditionadmin 68 #85
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
namespace App\Actions\Entries;
|
||||
|
||||
use App\Models\Entry;
|
||||
use App\Models\Seat;
|
||||
|
||||
class GetEntrySeatingResult
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public function __invoke(Entry $entry): string
|
||||
{
|
||||
return $this->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';
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -2,7 +2,8 @@
|
|||
<x-layout.app>
|
||||
<x-slot:page_title>Dashboard</x-slot:page_title>
|
||||
@if(! Auth::user()->school_id)
|
||||
<p class="pb-5">You aren't currently associated with a school. <a href="/my_school" class="text-blue-600">Click here to choose or create one.</a></p>
|
||||
<p class="pb-5">You aren't currently associated with a school. <a href="/my_school" class="text-blue-600">Click
|
||||
here to choose or create one.</a></p>
|
||||
@endif
|
||||
<div class="grid sm:grid-cols-2 md:grid-cols-4">
|
||||
<div>{{-- Column 1 --}}
|
||||
|
|
@ -29,6 +30,15 @@
|
|||
</x-card.list.body>
|
||||
</x-card.card>
|
||||
</div>
|
||||
@if(Auth::user()->school_id)
|
||||
<div class="md:col-span-3 pl-3">{{-- Column 2 Results --}}
|
||||
<x-card.card>
|
||||
<x-card.heading>My Results</x-card.heading>
|
||||
@include('dashboard.results-table')
|
||||
</x-card.card>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
|
||||
</div>
|
||||
</x-layout.app>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
<x-table.table>
|
||||
<thead>
|
||||
<x-table.th>Student</x-table.th>
|
||||
<x-table.th>Audition</x-table.th>
|
||||
<x-table.th>Score</x-table.th>
|
||||
<x-table.th>Rank</x-table.th>
|
||||
<x-table.th>Result</x-table.th>
|
||||
</thead>
|
||||
<x-table.body>
|
||||
@foreach($entries as $entry)
|
||||
<tr>
|
||||
<x-table.td>{{ $entry->student->full_name() }}</x-table.td>
|
||||
<x-table.td>{{ $entry->audition->name }}</x-table.td>
|
||||
@if(! $entry->audition->hasFlag('seats_published'))
|
||||
<x-table.td colspan="3">Results not available</x-table.td>
|
||||
@else
|
||||
<x-table.td> {{ $scores[$entry->id ][0] }}</x-table.td>
|
||||
<x-table.td> {{ $ranks[$entry->id ] }}</x-table.td>
|
||||
<x-table.td> {{ $results[$entry->id ] }}</x-table.td>
|
||||
@endif
|
||||
</tr>
|
||||
@endforeach
|
||||
</x-table.body>
|
||||
</x-table.table>
|
||||
Loading…
Reference in New Issue