46 lines
1.6 KiB
PHP
46 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Tabulation;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\Audition;
|
|
use App\Models\Entry;
|
|
use App\Rules\ValidScoreArray;
|
|
use Illuminate\Http\Request;
|
|
use function dump;
|
|
use function redirect;
|
|
|
|
class TabulationController extends Controller
|
|
{
|
|
public function chooseEntry(Request $request)
|
|
{
|
|
return view('tabulation.choose_entry');
|
|
}
|
|
|
|
public function entryScoreSheet(Request $request)
|
|
{
|
|
$entry = Entry::with(['student','audition.room.judges'])->find($request->input('entry_id'));
|
|
$judges = $entry->audition->room->judges;
|
|
$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');
|
|
}
|
|
return view('tabulation.entry_score_sheet', compact('entry','judges','scoring_guide','subscores'));
|
|
}
|
|
|
|
public function saveEntryScoreSheet(Request $request, Entry $entry)
|
|
{
|
|
$judges = $entry->audition->room->judges;
|
|
$subscores = $entry->audition->scoringGuide->subscores->sortBy('tiebreak_order');
|
|
$scoringGuide = $entry->audition->scoringGuide;
|
|
foreach ($judges as $judge) {
|
|
$scoreValidation = $scoringGuide->validateScores($request->input('judge'.$judge->id));
|
|
if ($scoreValidation != 'success') {
|
|
return redirect(url()->previous())->with('error', $judge->full_name() . ': ' . $scoreValidation)->with('oldScores',$request->all());
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|