Allow editing of scores by prelims judges.

This commit is contained in:
Matt Young 2025-10-18 15:04:12 -05:00
parent b978966c98
commit 40363a5964
3 changed files with 40 additions and 5 deletions

View File

@ -24,7 +24,8 @@ class PrelimJudgingController extends Controller
$prelimScoresheets = PrelimScoreSheet::where('user_id', Auth::id())->get()->keyBy('entry_id');
return view('judging.prelim_entry_list', compact('prelimDefinition', 'entries', 'subscores', 'published', 'prelimScoresheets'));
return view('judging.prelim_entry_list',
compact('prelimDefinition', 'entries', 'subscores', 'published', 'prelimScoresheets'));
}
public function prelimScoreEntryForm(Entry $entry)
@ -70,4 +71,33 @@ class PrelimJudgingController extends Controller
return redirect()->route('judging.prelimEntryList', $entry->audition->prelimDefinition)->with('success',
'Entered prelim scores for '.$entry->audition->name.' '.$entry->draw_number);
}
public function updatePrelimScoreSheet(Entry $entry, Request $request, EnterPrelimScore $scribe)
{
if (auth()->user()->cannot('judge', $entry->audition->prelimDefinition)) {
return redirect()->route('dashboard')->with('error', 'You are not assigned to judge that prelim audition.');
}
// Validate form data
$subscores = $entry->audition->prelimDefinition->scoringGuide->subscores;
$validationChecks = [];
foreach ($subscores as $subscore) {
$validationChecks['score'.'.'.$subscore->id] = 'required|integer|max:'.$subscore->max_score;
}
$validatedData = $request->validate($validationChecks);
// Get the existing score
$scoreSheet = PrelimScoreSheet::where('user_id', auth()->user()->id)->where('entry_id', $entry->id)->first();
if (! $scoreSheet) {
return redirect()->back()->with('error', 'No score sheet exists.');
}
// Update the score
$scribe(auth()->user(), $entry, $validatedData['score'], $scoreSheet);
return redirect()->route('judging.prelimEntryList', $entry->audition->prelimDefinition)->with('success',
'Updated prelim scores for '.$entry->audition->name.' '.$entry->draw_number);
}
}

View File

@ -5,7 +5,8 @@
<x-card.heading>
{{ $prelimDefinition->audition->name }} Prelims
@if($published)
<x-slot:subheading class="text-red-500">Results are published. Scores cannot be changed.</x-slot:subheading>
<x-slot:subheading class="text-red-500">Results are published. Scores cannot be changed.
</x-slot:subheading>
@endif
</x-card.heading>
<x-table.table>
@ -13,7 +14,7 @@
<tr>
<x-table.th :sortable="false"><a href="{{ url()->current() }}">Entry</a></x-table.th>
@foreach($subscores as $subscore)
<x-table.th :sortable="false" class="hidden md:table-cell">{{ $subscore->name }}</x-table.th>
<x-table.th :sortable="false" class="hidden md:table-cell">{{ $subscore->name }}</x-table.th>
@endforeach
<x-table.th :sortable="true">Timestamp</x-table.th>
</tr>
@ -23,14 +24,17 @@
{{-- @continue($entry->hasFlag('no_show'))--}}
<tr>
<x-table.td>
@if(! $published && ! $entry->hasFlag('no_show'))
@if(! $published && ! $entry->hasFlag('no_show') && $entry->scoreSheets()->count() < 1)
<a href="{{ route('judging.prelimScoreEntryForm', $entry) }}">
@endif
{{ $prelimDefinition->audition->name }} {{ $entry->draw_number }}
@if($entry->hasFlag('no_show'))
<p class="text-red-600">No Show</p>
@endif
@if(! $published && ! $entry->hasFlag('no_show'))
@if($entry->scoreSheets()->count() > 0)
<p class="text-green-600">Has Finals Scores</p>
@endif
@if(! $published && ! $entry->hasFlag('no_show') && $entry->scoreSheets()->count() < 1)
</a>
@endif
</x-table.td>

View File

@ -22,6 +22,7 @@ Route::middleware(['auth', 'verified', CheckIfCanJudge::class])->prefix('judging
Route::get('/{prelimDefinition}', 'prelimEntryList')->name('judging.prelimEntryList');
route::get('/enterScore/{entry}', 'prelimScoreEntryForm')->name('judging.prelimScoreEntryForm');
route::post('/enterScore/{entry}', 'savePrelimScoreSheet')->name('judging.savePrelimScoreSheet');
route::patch('/enterScore/{entry}', 'updatePrelimScoreSheet')->name('judging.savePrelimScoreSheet');
});
// Bonus score judging routes