diff --git a/app/Exceptions/TabulationException.php b/app/Exceptions/TabulationException.php index 425943d..408654d 100644 --- a/app/Exceptions/TabulationException.php +++ b/app/Exceptions/TabulationException.php @@ -16,9 +16,7 @@ class TabulationException extends Exception public function render($request) { -// if ($e instanceof TabulationException) { + dd('in the render'); return redirect('/tabulation/status')->with('error', $this->getMessage()); -// } -// return parent::render($request, $e); } } diff --git a/app/Services/TabulationService.php b/app/Services/TabulationService.php index cbd9ba6..320dc29 100644 --- a/app/Services/TabulationService.php +++ b/app/Services/TabulationService.php @@ -10,6 +10,7 @@ use App\Models\User; use Illuminate\Support\Facades\Cache; use App\Services\AuditionCacheService; use Illuminate\Support\Facades\DB; +use Illuminate\Support\Facades\Session; class TabulationService @@ -63,7 +64,7 @@ class TabulationService */ public function entryFinalScores(Entry $entry) { $audition = $this->auditionCacheService->getAudition($entry->audition_id); - $this->validateEntryScoreSheets($entry); + if (! $this->entryScoreSheetsAreValid($entry)) return null; $subscores = $audition->scoringGuide->subscores->sortBy('tiebreak_order'); $finalScoresArray = []; @@ -90,15 +91,14 @@ class TabulationService return $finalScoresArray; } - /** - * @throws TabulationException - */ - public function validateEntryScoreSheets(Entry $entry): bool { - $audition = $this->auditionCacheService->getAudition($entry->audition_id); + public function entryScoreSheetsAreValid(Entry $entry): bool { + //TODO consider making this move the invalid score to another database for further investication + $validJudges = $this->auditionCacheService->getAudition($entry->audition_id)->judges; foreach ($entry->scoreSheets as $sheet) { - if (! $audition->judges->contains($sheet->user_id)) { + if (! $validJudges->contains($sheet->user_id)) { $invalidJudge = User::find($sheet->user_id); - throw new TabulationException('Invalid scores for entry ' . $entry->id . ' exist from ' . $invalidJudge->full_name()); + Session::flash('error','Invalid scores for entry ' . $entry->id . ' exist from ' . $invalidJudge->full_name()); + return false; } } return true; diff --git a/bootstrap/app.php b/bootstrap/app.php index a84bc15..397c57a 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -1,5 +1,6 @@ Test Page -@php(dd($auditions)) + @php(dd($tabservice->entryScoreSheetsAreValid(Entry::find(1102)))) @foreach($auditions as $audition) - {{ $audition->name }} has {{ $audition->entries_count }} entries. {{ $audition->scored_entries_count }} are fully scored.
+ {{ $audition->name }} has {{ $audition->entries_count }} entries. {{ $audition->scored_entries_count }} are + fully scored.
@endforeach -