diff --git a/app/Http/Controllers/Judging/BonusScoreEntryListController.php b/app/Http/Controllers/Judging/BonusScoreEntryListController.php
new file mode 100644
index 0000000..ae5f30c
--- /dev/null
+++ b/app/Http/Controllers/Judging/BonusScoreEntryListController.php
@@ -0,0 +1,32 @@
+bonusScore()->first();
+ if (! $bonusScore->judges->contains(auth()->id())) {
+ return redirect()->route('dashboard')->with('error', 'You are not assigned to judge this bonus score');
+ }
+ $entries = $audition->entries()->orderBy('draw_number')->get();
+ $entries = $entries->reject(fn ($entry) => $entry->hasFlag('no_show'));
+ $entries->each(fn ($entry) => $entry->audition = $audition);
+
+ $scores = BonusScore::where('user_id', Auth::user()->id)
+ ->with('entry.audition')
+ ->with('originallyScoredEntry.audition')
+ ->get()
+ ->keyBy('entry_id');
+
+ return view('judging.bonus_score_entry_list', compact('audition', 'entries', 'scores'));
+ }
+}
diff --git a/app/Http/Controllers/JudgingController.php b/app/Http/Controllers/Judging/JudgingController.php
similarity index 98%
rename from app/Http/Controllers/JudgingController.php
rename to app/Http/Controllers/Judging/JudgingController.php
index 257d611..84f6fab 100644
--- a/app/Http/Controllers/JudgingController.php
+++ b/app/Http/Controllers/Judging/JudgingController.php
@@ -1,10 +1,11 @@
belongsTo(Entry::class);
+ }
+
+ public function judge(): BelongsTo
+ {
+ return $this->belongsTo(User::class, 'user_id');
+ }
+
+ public function originallyScoredEntry(): BelongsTo
+ {
+ return $this->belongsTo(Entry::class, 'originally_scored_entry');
+ }
}
diff --git a/resources/views/judging/bonus_score_entry_list.blade.php b/resources/views/judging/bonus_score_entry_list.blade.php
new file mode 100644
index 0000000..c5bed92
--- /dev/null
+++ b/resources/views/judging/bonus_score_entry_list.blade.php
@@ -0,0 +1,30 @@
+@php use Carbon\Carbon; @endphp
+
+ Judging Dashboard - Bonus Scores
+
+ {{ $audition->name }} - Bonus Score
+
+
+
+ Entry
+ Score
+ Scored On
+ Score Timestamp
+
+
+
+ @foreach($entries as $entry)
+
+ {{ $audition->name }} {{ $entry->draw_number }}
+ @if($scores->has($entry->id))
+ {{ $scores[$entry->id]->score }}
+ {{ $scores[$entry->id]->originallyScoredEntry->audition->name }}
+ {{ Carbon::create($scores[$entry->id]->created_at)->setTimezone('America/Chicago')->format('m/d/y H:i') }}
+
+ @endif
+
+ @endforeach
+
+
+
+
diff --git a/resources/views/judging/index.blade.php b/resources/views/judging/index.blade.php
index 43a655f..5d371f4 100644
--- a/resources/views/judging/index.blade.php
+++ b/resources/views/judging/index.blade.php
@@ -22,7 +22,7 @@
{{ $bonusScore->name }}
@foreach($bonusScore->auditions as $audition)
-
+
{{ $audition->name }}
diff --git a/routes/judging.php b/routes/judging.php
index 978434f..6dae2e7 100644
--- a/routes/judging.php
+++ b/routes/judging.php
@@ -1,6 +1,8 @@
prefix('judging
Route::post('/entry/{entry}', 'saveScoreSheet')->name('judging.saveScoreSheet');
Route::patch('/entry/{entry}', 'updateScoreSheet')->name('judging.updateScoreSheet');
});
+
+// Bonus score judging routes
+Route::middleware(['auth', 'verified', CheckIfCanJudge::class])->prefix('judging/bonus_scores')->group(function () {
+ Route::get('/{audition}', BonusScoreEntryListController::class)->name('judging.bonusScore.EntryList');
+});
diff --git a/routes/web.php b/routes/web.php
index c63f5b9..a0ad9ec 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -1,19 +1,7 @@
middleware('auth', 'verified');
-
Route::view('/', 'welcome')->middleware('guest')->name('home');
Route::get('/results', [App\Http\Controllers\ResultsPage::class, '__invoke'])->name('results');
diff --git a/tests/Feature/Pages/JudgingBonusScoreEntryListTest.php b/tests/Feature/Pages/JudgingBonusScoreEntryListTest.php
new file mode 100644
index 0000000..9cb598d
--- /dev/null
+++ b/tests/Feature/Pages/JudgingBonusScoreEntryListTest.php
@@ -0,0 +1,67 @@
+get(route('judging.bonusScore.EntryList', 1));
+ $response->assertRedirect(route('home'));
+});
+it('denies access to a user not assigned to judge this bonus score', function () {
+ $bonusScore = BonusScoreDefinition::factory()->create();
+ $audition = Audition::factory()->create();
+ $audition->bonusScore()->attach($bonusScore->id);
+ $room = Room::factory()->create();
+ $user = User::factory()->create();
+ $room->addJudge($user->id);
+ actingAs($user);
+ $this->get(route('judging.bonusScore.EntryList', $audition->id))
+ ->assertRedirect(route('dashboard'))
+ ->assertSessionHas('error', 'You are not assigned to judge this bonus score');
+});
+it('shows all entries to an authorized judge', function () {
+ // Arrange
+ $bonusScore = BonusScoreDefinition::factory()->create();
+ $audition = Audition::factory()->create();
+ $audition->bonusScore()->attach($bonusScore->id);
+ $entries[1] = Entry::factory()->create(['audition_id' => $audition->id, 'draw_number' => 1]);
+ $entries[2] = Entry::factory()->create(['audition_id' => $audition->id, 'draw_number' => 2]);
+ $entries[3] = Entry::factory()->create(['audition_id' => $audition->id, 'draw_number' => 3]);
+ $entries[4] = Entry::factory()->create(['audition_id' => $audition->id, 'draw_number' => 4]);
+ $entries = collect($entries);
+ $judge = User::factory()->create();
+ $bonusScore->judges()->attach($judge->id);
+ actingAs($judge);
+ // Act & Assert
+ $response = $this->get(route('judging.bonusScore.EntryList', $audition->id));
+ $response->assertOk();
+ $entries->each(fn ($entry) => $response->assertSee($entry->audition->name.' '.$entry->draw_number));
+});
+it('shows existing scores for an entry', function () {
+ $bonusScore = BonusScoreDefinition::factory()->create(['max_score' => 100]);
+ $audition = Audition::factory()->create();
+ $audition->bonusScore()->attach($bonusScore->id);
+ $entry = Entry::factory()->create(['audition_id' => $audition->id, 'draw_number' => 1]);
+ $judge = User::factory()->create();
+ $bonusScore->judges()->attach($judge->id);
+ BonusScore::create([
+ 'entry_id' => $entry->id,
+ 'user_id' => $judge->id,
+ 'originally_scored_entry' => $entry->id,
+ 'score' => 42,
+ ]);
+ actingAs($judge);
+ // Act
+ $response = $this->get(route('judging.bonusScore.EntryList', $audition));
+ $response->assertOk()
+ ->assertSeeInOrder(['', e($audition->name), $entry->draw_number, 42, '
'], false);
+});