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 @@
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 +