Modify judging to use only defined scores if an audition has split scoring.
This commit is contained in:
parent
c60f1714c1
commit
b6206976a1
|
|
@ -12,6 +12,7 @@ use App\Models\AuditLogEntry;
|
||||||
use App\Models\Entry;
|
use App\Models\Entry;
|
||||||
use App\Models\EntryTotalScore;
|
use App\Models\EntryTotalScore;
|
||||||
use App\Models\ScoreSheet;
|
use App\Models\ScoreSheet;
|
||||||
|
use App\Models\SubscoreDefinition;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
|
@ -70,7 +71,12 @@ class EnterScore
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check the validity of submitted subscores, format array for storage, and sum score
|
// Check the validity of submitted subscores, format array for storage, and sum score
|
||||||
|
if ($entry->audition->splitScoreDefinition) {
|
||||||
|
$subscoreIDs = $entry->audition->splitScoreDefinition->subscoresForJudge($user);
|
||||||
|
$subscoresRequired = SubscoreDefinition::findMany($subscoreIDs);
|
||||||
|
} else {
|
||||||
$subscoresRequired = $entry->audition->scoringGuide->subscores;
|
$subscoresRequired = $entry->audition->scoringGuide->subscores;
|
||||||
|
}
|
||||||
$subscoresStorageArray = [];
|
$subscoresStorageArray = [];
|
||||||
$seatingTotal = 0;
|
$seatingTotal = 0;
|
||||||
$seatingMaxPossible = 0;
|
$seatingMaxPossible = 0;
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ use App\Models\Audition;
|
||||||
use App\Models\Entry;
|
use App\Models\Entry;
|
||||||
use App\Models\JudgeAdvancementVote;
|
use App\Models\JudgeAdvancementVote;
|
||||||
use App\Models\ScoreSheet;
|
use App\Models\ScoreSheet;
|
||||||
|
use App\Models\SubscoreDefinition;
|
||||||
use App\Services\AuditionService;
|
use App\Services\AuditionService;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
@ -46,7 +47,12 @@ class JudgingController extends Controller
|
||||||
if ($audition->prelimDefinition) {
|
if ($audition->prelimDefinition) {
|
||||||
$entries = $entries->reject(fn ($entry) => ! $entry->hasFlag('passed_prelim'));
|
$entries = $entries->reject(fn ($entry) => ! $entry->hasFlag('passed_prelim'));
|
||||||
}
|
}
|
||||||
|
if ($audition->splitScoreDefinition) {
|
||||||
|
$subscoreIds = $audition->splitScoreDefinition->subscoresForJudge($request->user());
|
||||||
|
$subscores = SubscoreDefinition::findMany($subscoreIds)->sortBy('display_order');
|
||||||
|
} else {
|
||||||
$subscores = $audition->scoringGuide->subscores()->orderBy('display_order')->get();
|
$subscores = $audition->scoringGuide->subscores()->orderBy('display_order')->get();
|
||||||
|
}
|
||||||
|
|
||||||
$votes = JudgeAdvancementVote::where('user_id', Auth::id())->get();
|
$votes = JudgeAdvancementVote::where('user_id', Auth::id())->get();
|
||||||
$published = $audition->hasFlag('advancement_published') || $audition->hasFlag('seats_published');
|
$published = $audition->hasFlag('advancement_published') || $audition->hasFlag('seats_published');
|
||||||
|
|
@ -76,12 +82,17 @@ class JudgingController extends Controller
|
||||||
return redirect()->route('judging.auditionEntryList', $entry->audition)->with('error',
|
return redirect()->route('judging.auditionEntryList', $entry->audition)->with('error',
|
||||||
'The requested entry is marked as having failed a prelim. Scores cannot be entered.');
|
'The requested entry is marked as having failed a prelim. Scores cannot be entered.');
|
||||||
}
|
}
|
||||||
|
if ($entry->audition->splitScoreDefinition) {
|
||||||
|
$limitedSubscores = $entry->audition->splitScoreDefinition->subscoresForJudge($request->user());
|
||||||
|
} else {
|
||||||
|
$limitedSubscores = false;
|
||||||
|
}
|
||||||
|
|
||||||
$oldSheet = ScoreSheet::where('user_id', Auth::id())->where('entry_id', $entry->id)->value('subscores') ?? null;
|
$oldSheet = ScoreSheet::where('user_id', Auth::id())->where('entry_id', $entry->id)->value('subscores') ?? null;
|
||||||
$oldVote = JudgeAdvancementVote::where('user_id', Auth::id())->where('entry_id', $entry->id)->first();
|
$oldVote = JudgeAdvancementVote::where('user_id', Auth::id())->where('entry_id', $entry->id)->first();
|
||||||
$oldVote = $oldVote ? $oldVote->vote : 'noVote';
|
$oldVote = $oldVote ? $oldVote->vote : 'noVote';
|
||||||
|
|
||||||
return view('judging.entry_score_sheet', compact('entry', 'oldSheet', 'oldVote'));
|
return view('judging.entry_score_sheet', compact('entry', 'oldSheet', 'oldVote', 'limitedSubscores'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function saveScoreSheet(Request $request, Entry $entry, EnterScore $enterScore)
|
public function saveScoreSheet(Request $request, Entry $entry, EnterScore $enterScore)
|
||||||
|
|
@ -91,7 +102,13 @@ class JudgingController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate form data
|
// Validate form data
|
||||||
|
if ($entry->audition->splitScoreDefinition) {
|
||||||
|
$subscoreIDs = $entry->audition->splitScoreDefinition->subscoresForJudge($request->user());
|
||||||
|
$subscores = SubscoreDefinition::findMany($subscoreIDs);
|
||||||
|
|
||||||
|
} else {
|
||||||
$subscores = $entry->audition->subscoreDefinitions;
|
$subscores = $entry->audition->subscoreDefinitions;
|
||||||
|
}
|
||||||
$validationChecks = [];
|
$validationChecks = [];
|
||||||
foreach ($subscores as $subscore) {
|
foreach ($subscores as $subscore) {
|
||||||
$validationChecks['score'.'.'.$subscore->id] = 'required|integer|max:'.$subscore->max_score;
|
$validationChecks['score'.'.'.$subscore->id] = 'required|integer|max:'.$subscore->max_score;
|
||||||
|
|
|
||||||
|
|
@ -19,4 +19,18 @@ class SplitScoreDefinition extends Model
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Audition::class);
|
return $this->belongsTo(Audition::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function subscoresForJudge(User $judge): array
|
||||||
|
{
|
||||||
|
$validSubscores = [];
|
||||||
|
foreach ($this->splits as $split) {
|
||||||
|
if (in_array($judge->id, $split['judges'])) {
|
||||||
|
foreach ($split['subscores'] as $subscore) {
|
||||||
|
$validSubscores[] = $subscore;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $validSubscores;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@
|
||||||
@endif
|
@endif
|
||||||
<x-card.list.body class="mt-1">
|
<x-card.list.body class="mt-1">
|
||||||
@foreach($entry->audition->scoringGuide->subscores()->orderBy('display_order')->get() as $subscore)
|
@foreach($entry->audition->scoringGuide->subscores()->orderBy('display_order')->get() as $subscore)
|
||||||
|
@continue($limitedSubscores && ! in_array($subscore->id, $limitedSubscores))
|
||||||
@php
|
@php
|
||||||
if($oldScores) {
|
if($oldScores) {
|
||||||
$value = $oldScores['score'][$subscore->id];
|
$value = $oldScores['score'][$subscore->id];
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue