From af837264e9ecc0b076ed1f7bdac64559040bda88 Mon Sep 17 00:00:00 2001 From: Matt Young Date: Mon, 8 Jul 2024 17:16:36 -0500 Subject: [PATCH] Score Entry working for tabulator --- app/Http/Controllers/Tabulation/ScoreController.php | 7 +++++-- app/Models/ScoreSheet.php | 5 +++++ .../Tabulation}/enterScoreEntryFormTest.php | 12 +++++++++++- 3 files changed, 21 insertions(+), 3 deletions(-) rename tests/Feature/{ => Pages/Tabulation}/enterScoreEntryFormTest.php (92%) diff --git a/app/Http/Controllers/Tabulation/ScoreController.php b/app/Http/Controllers/Tabulation/ScoreController.php index 1524f03..35b1fda 100644 --- a/app/Http/Controllers/Tabulation/ScoreController.php +++ b/app/Http/Controllers/Tabulation/ScoreController.php @@ -4,9 +4,9 @@ namespace App\Http\Controllers\Tabulation; use App\Http\Controllers\Controller; use App\Models\Entry; +use App\Models\ScoreSheet; use Illuminate\Http\Request; use Illuminate\Support\Facades\Session; -use App\Models\ScoreSheet; class ScoreController extends Controller { @@ -48,7 +48,10 @@ class ScoreController extends Controller if (! $entry) { return redirect()->route('tabulation.chooseEntry')->with('error', 'Entry not found'); } - session()->flash('error', 'This entry is marked as a no-show. Entering a score will remove the no-show flag'); + if ($entry->hasFlag('no_show')) { + session()->flash('error', + 'This entry is marked as a no-show. Entering a score will remove the no-show flag'); + } return view('tabulation.entry_score_sheet', compact('entry', 'judges', 'scoring_guide', 'subscores', 'existing_sheets')); diff --git a/app/Models/ScoreSheet.php b/app/Models/ScoreSheet.php index 7b7c337..cf93064 100644 --- a/app/Models/ScoreSheet.php +++ b/app/Models/ScoreSheet.php @@ -38,6 +38,11 @@ class ScoreSheet extends Model ); } + public function getSubscore($id) + { + return $this->subscores[$id]['score'] ?? false; + } + public function isValid() { // TODO move to either TabulationService or a specific service for scoreValidation diff --git a/tests/Feature/enterScoreEntryFormTest.php b/tests/Feature/Pages/Tabulation/enterScoreEntryFormTest.php similarity index 92% rename from tests/Feature/enterScoreEntryFormTest.php rename to tests/Feature/Pages/Tabulation/enterScoreEntryFormTest.php index 532e5a2..da72947 100644 --- a/tests/Feature/enterScoreEntryFormTest.php +++ b/tests/Feature/Pages/Tabulation/enterScoreEntryFormTest.php @@ -103,9 +103,19 @@ it('will not accept scores for an entry in an audition with published advancemen }); it('warns if the entry is flagged as a no-show', function () { // Arrange - $response = validRequest(); + $data = testData(); + $data['entry']->addFlag('no_show'); + $response = validRequest($data); // Act & Assert $response ->assertOk() ->assertSee('marked as a no-show'); }); +it('does not show the no-show flag if an entry is not a no show', function () { + // Arrange + $response = validRequest(); + // Act & Assert + $response + ->assertOk() + ->assertDontSee('marked as a no-show'); +});