diff --git a/app/Http/Controllers/JudgingController.php b/app/Http/Controllers/JudgingController.php new file mode 100644 index 0000000..9fb260f --- /dev/null +++ b/app/Http/Controllers/JudgingController.php @@ -0,0 +1,49 @@ +judgingAssignments; + return view('judging.index', compact('rooms')); + } + + public function auditionEntryList(Audition $audition) + { + // TODO verify user is assigned to judge this audition + $entries = Entry::where('audition_id','=',$audition->id)->orderBy('draw_number')->get(); + + return view('judging.audition_entry_list', compact('audition','entries')); + } + + public function entryScoreSheet(Entry $entry) + { + // TODO verify user is assigned to judge this audition + return view('judging.entry_score_sheet',compact('entry')); + } + + public function saveScoreSheet(Request $request, Entry $entry) + { + // TODO verify user is assigned to judge this audition + $scoringGuide = $entry->audition->scoringGuide; + $scoreValidation = $scoringGuide->validateScores($request->input('score')); + if ($scoreValidation != 'success') { + return redirect(url()->previous())->with('error', $scoreValidation)->with('oldScores',$request->all()); + } + dd($scoreValidation); + } + + +} diff --git a/app/Http/Middleware/CheckIfCanJudge.php b/app/Http/Middleware/CheckIfCanJudge.php new file mode 100644 index 0000000..75770de --- /dev/null +++ b/app/Http/Middleware/CheckIfCanJudge.php @@ -0,0 +1,31 @@ +with('error', 'Judging is not currently enabled.'); + } + + if(! Auth::user()->isJudge()) { + return redirect('/dashboard')->with('error', 'You are not assigned to judge.'); + } + + return $next($request); + } +} diff --git a/app/Models/ScoringGuide.php b/app/Models/ScoringGuide.php index 67206f9..bd0963f 100644 --- a/app/Models/ScoringGuide.php +++ b/app/Models/ScoringGuide.php @@ -27,6 +27,11 @@ class ScoringGuide extends Model return $this->hasMany(SubscoreDefinition::class); } + /** + * Validate a set of subscores. Expects an array in the form of subscore_id => score + * @param array $prospective_score + * @return string + */ public function validateScores(Array $prospective_score) { foreach ($this->subscores as $subscore) { diff --git a/app/Models/User.php b/app/Models/User.php index 474218a..0072943 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -10,6 +10,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Database\Eloquent\Relations\HasManyThrough; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; +use phpDocumentor\Reflection\Types\Boolean; class User extends Authenticatable implements MustVerifyEmail { @@ -106,6 +107,11 @@ class User extends Authenticatable implements MustVerifyEmail return $this->rooms(); } + public function isJudge(): Bool + { + return $this->judgingAssignments->count() > 0; + } + /** * Return an array of schools using the users email domain * @return SchoolEmailDomain[] diff --git a/resources/views/components/layout/navbar/navbar.blade.php b/resources/views/components/layout/navbar/navbar.blade.php index 8a9201f..3b10192 100644 --- a/resources/views/components/layout/navbar/navbar.blade.php +++ b/resources/views/components/layout/navbar/navbar.blade.php @@ -1,4 +1,4 @@ -@php use Illuminate\Support\Facades\Auth; @endphp +@php use App\Settings;use Illuminate\Support\Facades\Auth; @endphp {{--TODO Clean up mobile menu area--}}