diff --git a/app/Actions/Tabulation/EnterScore.php b/app/Actions/Tabulation/EnterScore.php
index 54023c4..bb5646e 100644
--- a/app/Actions/Tabulation/EnterScore.php
+++ b/app/Actions/Tabulation/EnterScore.php
@@ -85,6 +85,7 @@ class EnterScore
if (! $scores->keys()->contains($subscore->id)) {
throw new AuditionAdminException('Invalid Score Submission');
}
+
if ($scores[$subscore->id] > $subscore->max_score) {
throw new AuditionAdminException('Supplied subscore exceeds maximum allowed');
}
diff --git a/app/Http/Controllers/Tabulation/EntryFlagController.php b/app/Http/Controllers/Tabulation/EntryFlagController.php
index 5a1a8c0..9ceca76 100644
--- a/app/Http/Controllers/Tabulation/EntryFlagController.php
+++ b/app/Http/Controllers/Tabulation/EntryFlagController.php
@@ -9,6 +9,9 @@ use Illuminate\Http\Request;
use function to_route;
+/**
+ * Used for tabulation enter noshow menu option
+ */
class EntryFlagController extends Controller
{
public function noShowSelect()
@@ -30,11 +33,11 @@ class EntryFlagController extends Controller
// If any results are published, get gone
if ($entry->audition->hasFlag('seats_published')) {
return to_route('entry-flags.noShowSelect')->with('error',
- 'Cannot enter a no-show for an entry in an audition where seats are published');
+ 'Cannot enter a no-show or failed-prelim for an entry in an audition where seats are published');
}
if ($entry->audition->hasFlag('advancement_published')) {
return to_route('entry-flags.noShowSelect')->with('error',
- 'Cannot enter a no-show for an entry in an audition where advancement is published');
+ 'Cannot enter a no-show or failed-prelim for an entry in an audition where advancement is published');
}
if ($entry->hasFlag('no_show')) {
@@ -43,6 +46,12 @@ class EntryFlagController extends Controller
$submitRouteName = 'entry-flags.undoNoShow';
$cardHeading = 'Undo No-Show';
$method = 'DELETE';
+ } elseif ($entry->hasFlag('failed_prelim')) {
+ $formId = 'no-show-cancellation-form';
+ $buttonName = 'Remove Failed Prelim';
+ $submitRouteName = 'entry-flags.undoNoShow';
+ $cardHeading = 'Undo Failed-Prelim';
+ $method = 'DELETE';
} else {
$formId = 'no-show-confirmation-form';
$buttonName = 'Confirm No Show';
@@ -85,21 +94,32 @@ class EntryFlagController extends Controller
{
if ($entry->audition->hasFlag('seats_published')) {
return to_route('entry-flags.noShowSelect')->with('error',
- 'Cannot undo a no-show for an entry in an audition where seats are published');
+ 'Cannot undo a no-show or failed-prelim for an entry in an audition where seats are published');
}
if ($entry->audition->hasFlag('advancement_published')) {
return to_route('entry-flags.noShowSelect')->with('error',
- 'Cannot undo a no-show for an entry in an audition where advancement is published');
+ 'Cannot undo a no-show or failed-prelim for an entry in an audition where advancement is published');
}
$entry->removeFlag('no_show');
+ $entry->removeFlag('failed_prelim');
return to_route('entry-flags.noShowSelect')->with('success',
- 'No Show status has been removed for '.$entry->audition->name.' #'.$entry->draw_number.' (ID: '.$entry->id.').');
+ $entry->audition->name.' #'.$entry->draw_number.' (ID: '.$entry->id.') may now be scored.');
}
public function undoDecline(Entry $entry)
{
+ if ($entry->audition->hasFlag('seats_published')) {
+ return redirect()->back()
+ ->with('error', 'Cannot undo a decline for an entry in an audition where seats are published');
+ }
+
+ if ($entry->audition->hasFlag('advancement_published')) {
+ return redirect()->back()
+ ->with('error', 'Cannot undo a no-show or failed-prelim for an entry in an audition where advancement is published');
+ }
+
$entry->removeFlag('declined');
return redirect()->back()->with('success', 'Decline cleared');
diff --git a/app/Http/Controllers/Tabulation/ScoreController.php b/app/Http/Controllers/Tabulation/ScoreController.php
index b4863a8..d506b47 100644
--- a/app/Http/Controllers/Tabulation/ScoreController.php
+++ b/app/Http/Controllers/Tabulation/ScoreController.php
@@ -3,7 +3,7 @@
namespace App\Http\Controllers\Tabulation;
use App\Actions\Tabulation\EnterScore;
-use App\Exceptions\ScoreEntryException;
+use App\Exceptions\AuditionAdminException;
use App\Http\Controllers\Controller;
use App\Models\Entry;
use App\Models\EntryTotalScore;
@@ -12,6 +12,9 @@ use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Session;
+/**
+ * Provides functionality for entering judge scores from the admin side.
+ */
class ScoreController extends Controller
{
public function chooseEntry()
@@ -25,7 +28,6 @@ class ScoreController extends Controller
public function destroyScore(ScoreSheet $score)
{
- EntryTotalScore::where('entry_id', $score->entry_id)->delete();
if ($score->entry->audition->hasFlag('seats_published')) {
return redirect()->back()->with('error', 'Cannot delete scores for an entry where seats are published');
}
@@ -33,6 +35,7 @@ class ScoreController extends Controller
return redirect()->back()->with('error',
'Cannot delete scores for an entry where advancement is published');
}
+ EntryTotalScore::where('entry_id', $score->entry_id)->delete();
$score->delete();
return redirect()->back()->with('success', 'Score Deleted');
@@ -41,7 +44,7 @@ class ScoreController extends Controller
public function entryScoreSheet(Request $request)
{
$existing_sheets = [];
- $entry = Entry::with(['student', 'audition.room.judges'])->find($request->input('entry_id'));
+ $entry = Entry::with(['student', 'audition.room.judges'])->findOrFail($request->input('entry_id'));
$publishedCheck = $this->checkIfPublished($entry);
if ($publishedCheck) {
@@ -58,9 +61,7 @@ class ScoreController extends Controller
}
$scoring_guide = $entry->audition->scoringGuide;
$subscores = $entry->audition->scoringGuide->subscores->sortBy('display_order');
- if (! $entry) {
- return redirect()->route('tabulation.chooseEntry')->with('error', 'Entry not found');
- }
+
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');
@@ -76,20 +77,32 @@ class ScoreController extends Controller
if ($publishedCheck) {
return $publishedCheck;
}
+
+ /**
+ * Here we process the submission from the scoring form.
+ * We're expecting submitted data to include an array for each judge.
+ * Each array should be called judge+ the judges ID number
+ * The array should have a key for each subscore and the value of the score submitted
+ */
foreach ($request->all() as $key => $value) {
+ // We're not interested in submission values that don't ahve judge in the name
if (! str_contains($key, 'judge')) {
continue;
}
+ // Extract the judge ID from the field name and load the user
$judge_id = str_replace('judge', '', $key);
$judge = User::find($judge_id);
+
+ // Check for existing scores, if so, tell EnterScores action that we're updating it, otherwise a new score
$existingScore = ScoreSheet::where('entry_id', $entry->id)
->where('user_id', $judge->id)->first();
if ($existingScore === null) {
$existingScore = false;
}
+
try {
$scoreRecorder($judge, $entry, $value, $existingScore);
- } catch (ScoreEntryException $e) {
+ } catch (AuditionAdminException $e) {
return redirect()->route('scores.entryScoreSheet', ['entry_id' => $entry->id])
->with('error', $e->getMessage());
}
diff --git a/resources/views/components/form/option.blade.php b/resources/views/components/form/option.blade.php
index f7745c0..46711ed 100644
--- a/resources/views/components/form/option.blade.php
+++ b/resources/views/components/form/option.blade.php
@@ -8,7 +8,7 @@