diff --git a/app/Actions/Tabulation/AllowForOlympicScoring.php b/app/Actions/Tabulation/AllowForOlympicScoring.php index f60b3af..82bfecc 100644 --- a/app/Actions/Tabulation/AllowForOlympicScoring.php +++ b/app/Actions/Tabulation/AllowForOlympicScoring.php @@ -75,7 +75,8 @@ class AllowForOlympicScoring implements CalculateEntryScore } } // add the bonus points for a seating mode - if ($mode === 'seating') { + if ($mode === 'seating' && $sums) { + $sums[0] += $this->getBonusPoints($entry); } diff --git a/app/Actions/Tabulation/EnterBonusScore.php b/app/Actions/Tabulation/EnterBonusScore.php index 042abe5..67f8570 100644 --- a/app/Actions/Tabulation/EnterBonusScore.php +++ b/app/Actions/Tabulation/EnterBonusScore.php @@ -9,6 +9,7 @@ use App\Models\BonusScore; use App\Models\Entry; use App\Models\User; use Illuminate\Database\Eloquent\Collection; +use Illuminate\Support\Facades\App; class EnterBonusScore { @@ -18,9 +19,10 @@ class EnterBonusScore public function __invoke(User $judge, Entry $entry, int $score): void { + $getRelatedEntries = App::make(GetBonusScoreRelatedEntries::class); $this->basicValidations($judge, $entry); $this->validateJudgeValidity($judge, $entry, $score); - $entries = $this->getRelatedEntries($entry); + $entries = $getRelatedEntries($entry); // Create the score for each related entry foreach ($entries as $relatedEntry) { diff --git a/app/Actions/Tabulation/GetBonusScoreRelatedEntries.php b/app/Actions/Tabulation/GetBonusScoreRelatedEntries.php new file mode 100644 index 0000000..93fbbb1 --- /dev/null +++ b/app/Actions/Tabulation/GetBonusScoreRelatedEntries.php @@ -0,0 +1,29 @@ +getRelatedEntries($entry); + } + + public function getRelatedEntries(Entry $entry): Collection + { + $bonusScore = $entry->audition->bonusScore->first(); + $relatedAuditions = $bonusScore->auditions; + + // Get all entries that have a student_id equal to that of entry and an audition_id in the related auditions + return Entry::where('student_id', $entry->student_id) + ->whereIn('audition_id', $relatedAuditions->pluck('id')) + ->get(); + } +} diff --git a/app/Http/Controllers/Tabulation/BonusScoreController.php b/app/Http/Controllers/Tabulation/BonusScoreController.php new file mode 100644 index 0000000..c1191c6 --- /dev/null +++ b/app/Http/Controllers/Tabulation/BonusScoreController.php @@ -0,0 +1,54 @@ +validate([ + 'entry_id' => 'required|exists:entries,id', + ]); + $entry = Entry::find($validData['entry_id']); + $bonusScoreDefinition = $entry->audition->bonusScore->first(); + $assignedJudges = $bonusScoreDefinition->judges; + $relatedEntries = $getRelatedEntries($entry); + $existingScores = []; + foreach ($relatedEntries as $related) { + $existingScores[$related->id] = BonusScore::where('entry_id', $related->id) + ->with('judge') + ->with('entry') + ->with('originallyScoredEntry') + ->get(); + } + + return view('tabulation.bonus-score-sheet', + compact('entry', 'bonusScoreDefinition', 'assignedJudges', 'existingScores', 'relatedEntries')); + } + + public function saveEntryBonusScoreSheet() + { + + } + + public function destroyBonusScore() + { + + } +} diff --git a/app/Http/Controllers/Tabulation/EntryFlagController.php b/app/Http/Controllers/Tabulation/EntryFlagController.php index 74b582c..bd0aed0 100644 --- a/app/Http/Controllers/Tabulation/EntryFlagController.php +++ b/app/Http/Controllers/Tabulation/EntryFlagController.php @@ -15,8 +15,9 @@ class EntryFlagController extends Controller { $method = 'GET'; $formRoute = 'entry-flags.confirmNoShow'; + $title = 'No Show'; - return view('tabulation.choose_entry', compact('method', 'formRoute')); + return view('tabulation.choose_entry', compact('method', 'formRoute', 'title')); } public function noShowConfirm(Request $request) diff --git a/app/Http/Controllers/Tabulation/ScoreController.php b/app/Http/Controllers/Tabulation/ScoreController.php index 35b1fda..4620418 100644 --- a/app/Http/Controllers/Tabulation/ScoreController.php +++ b/app/Http/Controllers/Tabulation/ScoreController.php @@ -14,8 +14,9 @@ class ScoreController extends Controller { $method = 'GET'; $formRoute = 'scores.entryScoreSheet'; + $title = 'Enter Scores'; - return view('tabulation.choose_entry', compact('method', 'formRoute')); + return view('tabulation.choose_entry', compact('method', 'formRoute', 'title')); } public function destroyScore(ScoreSheet $score) diff --git a/app/Models/Entry.php b/app/Models/Entry.php index bd3ad71..1b6eaee 100644 --- a/app/Models/Entry.php +++ b/app/Models/Entry.php @@ -7,10 +7,10 @@ use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\HasOne; use Illuminate\Database\Eloquent\Relations\HasOneThrough; -use Illuminate\Support\Facades\Cache; class Entry extends Model { @@ -55,6 +55,11 @@ class Entry extends Model } + public function bonusScores(): BelongsToMany + { + return $this->belongsToMany(BonusScore::class); + } + public function advancementVotes(): HasMany { return $this->hasMany(JudgeAdvancementVote::class); diff --git a/resources/views/components/layout/navbar/menus/tabulation.blade.php b/resources/views/components/layout/navbar/menus/tabulation.blade.php index 6a68318..a2e61cd 100644 --- a/resources/views/components/layout/navbar/menus/tabulation.blade.php +++ b/resources/views/components/layout/navbar/menus/tabulation.blade.php @@ -21,6 +21,7 @@
Enter Scores + Enter Bonus Scores Enter No-Shows Audition Status {{ auditionSetting('advanceTo') }} Status diff --git a/resources/views/components/table/table.blade.php b/resources/views/components/table/table.blade.php index b66d47e..4acc656 100644 --- a/resources/views/components/table/table.blade.php +++ b/resources/views/components/table/table.blade.php @@ -11,7 +11,7 @@
@if($with_title_area) -
+
@if($title)

attributes->merge(['class' => 'text-base font-semibold leading-6 text-gray-900']) }}>{{ $title }}

@endif @if($subtitle)

attributes->merge(['class' => 'mt-2 text-sm text-gray-700']) }}>{{ $subtitle }}

@endif diff --git a/resources/views/tabulation/bonus-score-sheet.blade.php b/resources/views/tabulation/bonus-score-sheet.blade.php new file mode 100644 index 0000000..cdf63aa --- /dev/null +++ b/resources/views/tabulation/bonus-score-sheet.blade.php @@ -0,0 +1,69 @@ +@php use Illuminate\Support\Carbon; @endphp + + Enter {{ $bonusScoreDefinition->name }} Score + + + {{ $entry->student->full_name() }} + {{ $entry->student->school->name }} + + +
+ + + Existing Scores +
+ @foreach($relatedEntries as $related) + + + {{ $related->audition->name }} #{{ $related->draw_number }} + + + Entry ID: {{ $related->id }} + + + + Judge + Audition Scored + Score + Timestamp + + + + @foreach($existingScores[$related->id] as $score) + + {{ $score->judge->full_name() }} + {{ $score->originallyScoredEntry->audition->name }} + {{ $score->score }} + {{ Carbon::create($score->created_at)->setTimezone('America/Chicago')->format('m/d/y H:i') }} + + @endforeach + + + @endforeach +
+
+ + + Enter Score +
+ NOTE: Entering score will delete any existing scores for that entry by that judge +
+ + + Judge + @foreach($assignedJudges as $judge) + + @endforeach + + + Scored Audition + @foreach($relatedEntries as $related) + + @endforeach + + + Enter Score + +
+
+
diff --git a/resources/views/tabulation/choose_entry.blade.php b/resources/views/tabulation/choose_entry.blade.php index 2f4c01a..2d08677 100644 --- a/resources/views/tabulation/choose_entry.blade.php +++ b/resources/views/tabulation/choose_entry.blade.php @@ -2,13 +2,14 @@ /** * @var string $method Method for the select form * @var string $formRoute Route for the form action. Should be a route name + * @var string $title Title of the page */ @endphp - Choose Entry + {{ $title }} - Choose Entry + {{ $title }} - Choose Entry
diff --git a/routes/tabulation.php b/routes/tabulation.php index 99f9d98..2a8fe42 100644 --- a/routes/tabulation.php +++ b/routes/tabulation.php @@ -2,13 +2,13 @@ // Tabulation Routes use App\Http\Controllers\Tabulation\AdvancementController; +use App\Http\Controllers\Tabulation\BonusScoreController; use App\Http\Controllers\Tabulation\DoublerDecisionController; use App\Http\Controllers\Tabulation\EntryFlagController; use App\Http\Controllers\Tabulation\ScoreController; use App\Http\Controllers\Tabulation\SeatAuditionFormController; use App\Http\Controllers\Tabulation\SeatingPublicationController; use App\Http\Controllers\Tabulation\SeatingStatusController; -use App\Http\Controllers\Tabulation\TabulationController; use App\Http\Middleware\CheckIfCanTab; use Illuminate\Support\Facades\Route; @@ -22,6 +22,14 @@ Route::middleware(['auth', 'verified', CheckIfCanTab::class])->group(function () Route::delete('/{score}', 'destroyScore')->name('scores.destroy'); }); + // Bonus Score Management + Route::prefix('bonus-scores/')->controller(BonusScoreController::class)->group(function () { + Route::get('/choose_entry', 'chooseEntry')->name('bonus-scores.chooseEntry'); + Route::get('/entry', 'entryBonusScoreSheet')->name('bonus-scores.entryBonusScoreSheet'); + Route::post('/entry/{entry}', 'saveEntryBonusScoreSheet')->name('bonus-scores.saveEntryBonusScoreSheet'); + Route::delete('/{bonusScore}', 'destroyBonusScore')->name('bonus-scores.destroy'); + }); + // Entry Flagging Route::prefix('entry-flags/')->controller(EntryFlagController::class)->group(function () { Route::get('/choose_no_show', 'noShowSelect')->name('entry-flags.noShowSelect');