Monitors are able to flag entries as no-shows or failed-prelims
Closes #45
This commit is contained in:
parent
93d4305131
commit
d5a5dff21d
|
|
@ -5,4 +5,5 @@ namespace App\Enums;
|
||||||
enum UserFlags: string
|
enum UserFlags: string
|
||||||
{
|
{
|
||||||
case HEAD_DIRECTOR = 'head_director';
|
case HEAD_DIRECTOR = 'head_director';
|
||||||
|
case MONITOR = 'monitor';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\User;
|
||||||
|
|
||||||
|
class AssignMonitorsController extends Controller
|
||||||
|
{
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$users = User::orderBy('last_name')->orderBy('first_name')->get();
|
||||||
|
|
||||||
|
return view('admin.assign_monitors', compact('users'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store()
|
||||||
|
{
|
||||||
|
$submittedUsers = request()->input('user');
|
||||||
|
$monitorUsers = array_keys($submittedUsers);
|
||||||
|
$users = User::all();
|
||||||
|
foreach ($users as $user) {
|
||||||
|
if (in_array($user->id, $monitorUsers)) {
|
||||||
|
$user->addFlag('monitor');
|
||||||
|
} else {
|
||||||
|
$user->removeFlag('monitor');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect(route('admin.assign_monitors.index'))->with('success', 'Monitors assigned');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,98 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\Entry;
|
||||||
|
|
||||||
|
class MonitorController extends Controller
|
||||||
|
{
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
if (! auth()->user()->hasFlag('monitor')) {
|
||||||
|
return redirect()->route('dashboard')->with('error', 'You are not assigned as a monitor');
|
||||||
|
}
|
||||||
|
$method = 'GET';
|
||||||
|
$formRoute = 'monitor.enterFlag';
|
||||||
|
$title = 'Flag Entry';
|
||||||
|
|
||||||
|
return view('tabulation.choose_entry', compact('method', 'formRoute', 'title'));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function flagForm()
|
||||||
|
{
|
||||||
|
if (! auth()->user()->hasFlag('monitor')) {
|
||||||
|
return redirect()->route('dashboard')->with('error', 'You are not assigned as a monitor');
|
||||||
|
}
|
||||||
|
$validData = request()->validate([
|
||||||
|
'entry_id' => ['required', 'integer', 'exists:entries,id'],
|
||||||
|
]);
|
||||||
|
$entry = Entry::find($validData['entry_id']);
|
||||||
|
|
||||||
|
// If the entries audition is published, bounce out
|
||||||
|
if ($entry->audition->hasFlag('seats_published') || $entry->audition->hasFlag('advance_published')) {
|
||||||
|
return redirect()->route('monitor.index')->with('error', 'Cannot set flags while results are published');
|
||||||
|
}
|
||||||
|
|
||||||
|
// If entry has scores, bounce on out
|
||||||
|
if ($entry->scoreSheets()->count() > 0) {
|
||||||
|
return redirect()->route('monitor.index')->with('error', 'That entry has existing scores');
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('monitor_entry_flag_form', compact('entry'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function storeFlag(Entry $entry)
|
||||||
|
{
|
||||||
|
if (! auth()->user()->hasFlag('monitor')) {
|
||||||
|
return redirect()->route('dashboard')->with('error', 'You are not assigned as a monitor');
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the entries audition is published, bounce out
|
||||||
|
if ($entry->audition->hasFlag('seats_published') || $entry->audition->hasFlag('advance_published')) {
|
||||||
|
return redirect()->route('monitor.index')->with('error', 'Cannot set flags while results are published');
|
||||||
|
}
|
||||||
|
|
||||||
|
// If entry has scores, bounce on out
|
||||||
|
if ($entry->scoreSheets()->count() > 0) {
|
||||||
|
return redirect()->route('monitor.index')->with('error', 'That entry has existing scores');
|
||||||
|
}
|
||||||
|
|
||||||
|
$action = request()->input('action');
|
||||||
|
$result = match ($action) {
|
||||||
|
'failed-prelim' => $this->setFlag($entry, 'failed_prelim'),
|
||||||
|
'no-show' => $this->setFlag($entry, 'no_show'),
|
||||||
|
'clear' => $this->setFlag($entry, 'clear'),
|
||||||
|
default => redirect()->route('monitor.index')->with('error', 'Invalid action requested'),
|
||||||
|
};
|
||||||
|
if (! $result) {
|
||||||
|
return redirect()->route('monitor.index')->with('error', 'Failed to set flag');
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect()->route('monitor.index')->with('success', 'Flag set for entry #'.$entry->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function setFlag(Entry $entry, string $flag)
|
||||||
|
{
|
||||||
|
if ($flag === 'no_show') {
|
||||||
|
$entry->removeFlag('failed_prelim');
|
||||||
|
$entry->addFlag('no_show');
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if ($flag === 'failed_prelim') {
|
||||||
|
$entry->addFlag('failed_prelim');
|
||||||
|
$entry->addFlag('no_show');
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if ($flag === 'clear') {
|
||||||
|
$entry->removeFlag('failed_prelim');
|
||||||
|
$entry->removeFlag('no_show');
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -182,6 +182,7 @@ class User extends Authenticatable implements MustVerifyEmail
|
||||||
}
|
}
|
||||||
$enum = match ($flag) {
|
$enum = match ($flag) {
|
||||||
'head_director' => UserFlags::HEAD_DIRECTOR,
|
'head_director' => UserFlags::HEAD_DIRECTOR,
|
||||||
|
'monitor' => UserFlags::MONITOR,
|
||||||
};
|
};
|
||||||
$this->flags()->create(['flag_name' => $enum]);
|
$this->flags()->create(['flag_name' => $enum]);
|
||||||
$this->load('flags');
|
$this->load('flags');
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
<x-layout.app>
|
||||||
|
<x-slot:page_title>Assign Room Monitors</x-slot:page_title>
|
||||||
|
<x-card.card>
|
||||||
|
<x-card.heading>Users With Monitor Access</x-card.heading>
|
||||||
|
<x-form.form method="POST" action="{{route('admin.assign_monitors.store')}}">
|
||||||
|
<x-card.list.body>
|
||||||
|
@foreach($users as $user)
|
||||||
|
<x-card.list.row>
|
||||||
|
<x-form.checkbox name="user[{{$user->id}}]" :checked="$user->hasFlag('monitor')">
|
||||||
|
<x-slot:label> {{$user->full_name(true)}}</x-slot:label>
|
||||||
|
</x-form.checkbox>
|
||||||
|
</x-card.list.row>
|
||||||
|
@endforeach
|
||||||
|
</x-card.list.body>
|
||||||
|
<x-form.button class="mb-3">Submit Monitors</x-form.button>
|
||||||
|
</x-form.form>
|
||||||
|
</x-card.card>
|
||||||
|
</x-layout.app>
|
||||||
|
|
@ -29,6 +29,7 @@
|
||||||
<x-layout.navbar.menus.menu-item :href="route('admin.bonus-scores.index')">Bonus Scores</x-layout.navbar.menus.menu-item>
|
<x-layout.navbar.menus.menu-item :href="route('admin.bonus-scores.index')">Bonus Scores</x-layout.navbar.menus.menu-item>
|
||||||
<x-layout.navbar.menus.menu-item :href="route('admin.rooms.index')">Rooms</x-layout.navbar.menus.menu-item>
|
<x-layout.navbar.menus.menu-item :href="route('admin.rooms.index')">Rooms</x-layout.navbar.menus.menu-item>
|
||||||
<x-layout.navbar.menus.menu-item :href="route('admin.rooms.judgingAssignment')">Judges</x-layout.navbar.menus.menu-item>
|
<x-layout.navbar.menus.menu-item :href="route('admin.rooms.judgingAssignment')">Judges</x-layout.navbar.menus.menu-item>
|
||||||
|
<x-layout.navbar.menus.menu-item :href="route('admin.assign_monitors.index')">Room Monitors</x-layout.navbar.menus.menu-item>
|
||||||
<x-layout.navbar.menus.menu-item :href="route('admin.draw.index')">Run Draw</x-layout.navbar.menus.menu-item>
|
<x-layout.navbar.menus.menu-item :href="route('admin.draw.index')">Run Draw</x-layout.navbar.menus.menu-item>
|
||||||
<x-layout.navbar.menus.menu-item :href="route('admin.cards.index')">Print Cards</x-layout.navbar.menus.menu-item>
|
<x-layout.navbar.menus.menu-item :href="route('admin.cards.index')">Print Cards</x-layout.navbar.menus.menu-item>
|
||||||
<x-layout.navbar.menus.menu-item :href="route('admin.signInSheets.index')">Print Sign-In Sheets</x-layout.navbar.menus.menu-item>
|
<x-layout.navbar.menus.menu-item :href="route('admin.signInSheets.index')">Print Sign-In Sheets</x-layout.navbar.menus.menu-item>
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,10 @@
|
||||||
<x-layout.navbar.nav-link href="{{ route('judging.index') }}" :active="request()->is('judging')">Judging
|
<x-layout.navbar.nav-link href="{{ route('judging.index') }}" :active="request()->is('judging')">Judging
|
||||||
</x-layout.navbar.nav-link>
|
</x-layout.navbar.nav-link>
|
||||||
@endif
|
@endif
|
||||||
|
@if(Auth::user()->hasFlag('monitor') && Settings::get('judging_enabled'))
|
||||||
|
<x-layout.navbar.nav-link href="{{ route('monitor.index') }}" :active="request()->is('monitor')">Monitor
|
||||||
|
</x-layout.navbar.nav-link>
|
||||||
|
@endif
|
||||||
@if(Auth::user()->is_admin)
|
@if(Auth::user()->is_admin)
|
||||||
@include('components.layout.navbar.menus.admin')
|
@include('components.layout.navbar.menus.admin')
|
||||||
@include('components.layout.navbar.menus.setup')
|
@include('components.layout.navbar.menus.setup')
|
||||||
|
|
@ -169,6 +173,10 @@
|
||||||
<x-layout.navbar.nav-link-mobile href="{{ route('judging.index') }}" :active="request()->is('judging')">Judging
|
<x-layout.navbar.nav-link-mobile href="{{ route('judging.index') }}" :active="request()->is('judging')">Judging
|
||||||
</x-layout.navbar.nav-link-mobile>
|
</x-layout.navbar.nav-link-mobile>
|
||||||
@endif
|
@endif
|
||||||
|
@if(Auth::user()->hasFlag('monitor') AND Settings::get('judging_enabled'))
|
||||||
|
<x-layout.navbar.nav-link-mobile href="{{ route('monitor.index') }}" :active="request()->is('monitor')">Monitor
|
||||||
|
</x-layout.navbar.nav-link-mobile>
|
||||||
|
@endif
|
||||||
@if(Auth::user()->is_admin)
|
@if(Auth::user()->is_admin)
|
||||||
@include('components.layout.navbar.menus.admin')
|
@include('components.layout.navbar.menus.admin')
|
||||||
@include('components.layout.navbar.menus.setup')
|
@include('components.layout.navbar.menus.setup')
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
<x-layout.app>
|
||||||
|
<x-slot:page_title>Entry Status</x-slot:page_title>
|
||||||
|
<x-card.card class="max-w-xl mx-auto">
|
||||||
|
<x-card.heading>Entry #{{$entry->id}}</x-card.heading>
|
||||||
|
<x-card.list.body>
|
||||||
|
<x-card.list.row><span class="font-semibold">Audition</span>{{$entry->audition->name}}
|
||||||
|
#{{$entry->draw_number}}</x-card.list.row>
|
||||||
|
<x-card.list.row><span class="font-semibold">Name</span>{{$entry->student->full_name() }}</x-card.list.row>
|
||||||
|
<x-card.list.row><span class="font-semibold">School</span>{{$entry->student->school->name }}
|
||||||
|
</x-card.list.row>
|
||||||
|
<x-card.list.row><span class="font-semibold">Current Status</span>
|
||||||
|
@if($entry->hasFlag('failed_prelim'))
|
||||||
|
Failed Prelim
|
||||||
|
@elseif($entry->hasFlag('no_show'))
|
||||||
|
No-Show
|
||||||
|
@else
|
||||||
|
No Flags
|
||||||
|
@endif
|
||||||
|
</x-card.list.row>
|
||||||
|
</x-card.list.body>
|
||||||
|
<x-form.form method="POST" action="{{route('monitor.storeFlag',['entry'=>$entry])}}">
|
||||||
|
<div class="grid grid-cols-2 gap-3 p-3">
|
||||||
|
|
||||||
|
@if(! $entry->hasFlag('failed_prelim'))
|
||||||
|
<x-form.button name="action" value="failed-prelim">Failed Prelim</x-form.button>
|
||||||
|
@endif
|
||||||
|
@if(! $entry->hasFlag('no_show') || $entry->hasFlag('failed_prelim'))
|
||||||
|
<x-form.button name="action" value="no-show">No-Show</x-form.button>
|
||||||
|
@endif
|
||||||
|
@if($entry->hasFlag('no_show') || $entry->hasFlag('failed_prelim'))
|
||||||
|
<x-form.button name="action" value="clear">Clear Status</x-form.button>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</x-form.form>
|
||||||
|
</x-card.card>
|
||||||
|
</x-layout.app>
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
// Admin Routes
|
// Admin Routes
|
||||||
|
use App\Http\Controllers\Admin\AssignMonitorsController;
|
||||||
use App\Http\Controllers\Admin\AuditionController;
|
use App\Http\Controllers\Admin\AuditionController;
|
||||||
use App\Http\Controllers\Admin\AuditionSettings;
|
use App\Http\Controllers\Admin\AuditionSettings;
|
||||||
use App\Http\Controllers\Admin\BonusScoreDefinitionController;
|
use App\Http\Controllers\Admin\BonusScoreDefinitionController;
|
||||||
|
|
@ -34,6 +35,12 @@ Route::middleware(['auth', 'verified', CheckIfAdmin::class])->prefix('admin/')->
|
||||||
Route::post('/settings',
|
Route::post('/settings',
|
||||||
[AuditionSettings::class, 'save'])->name('audition-settings-save');
|
[AuditionSettings::class, 'save'])->name('audition-settings-save');
|
||||||
|
|
||||||
|
// Admin Assign Monitors Routes
|
||||||
|
Route::prefix('assign_monitors')->controller(AssignMonitorsController::class)->group(function () {
|
||||||
|
Route::get('/', 'index')->name('admin.assign_monitors.index');
|
||||||
|
Route::post('/', 'store')->name('admin.assign_monitors.store');
|
||||||
|
});
|
||||||
|
|
||||||
// Admin Bonus Scores Routes
|
// Admin Bonus Scores Routes
|
||||||
Route::prefix('bonus-scores')->controller(BonusScoreDefinitionController::class)->group(function () {
|
Route::prefix('bonus-scores')->controller(BonusScoreDefinitionController::class)->group(function () {
|
||||||
Route::get('/', 'index')->name('admin.bonus-scores.index');
|
Route::get('/', 'index')->name('admin.bonus-scores.index');
|
||||||
|
|
@ -180,5 +187,6 @@ Route::middleware(['auth', 'verified', CheckIfAdmin::class])->prefix('admin/')->
|
||||||
});
|
});
|
||||||
|
|
||||||
// Print Room and Judge Assignment Report
|
// Print Room and Judge Assignment Report
|
||||||
Route::get('room_assignment_report', PrintRoomAssignmentsController::class)->name('admin.print_room_assignment_report');
|
Route::get('room_assignment_report',
|
||||||
|
PrintRoomAssignmentsController::class)->name('admin.print_room_assignment_report');
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use App\Http\Controllers\FilterController;
|
use App\Http\Controllers\FilterController;
|
||||||
|
use App\Http\Controllers\MonitorController;
|
||||||
use App\Http\Controllers\TestController;
|
use App\Http\Controllers\TestController;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
|
|
@ -23,6 +24,13 @@ Route::prefix('filters')->middleware(['auth', 'verified'])->controller(FilterCon
|
||||||
Route::get('/admin_student_filter/clear', 'clearAdminStudentFilter')->name('admin.students.filter.clear');
|
Route::get('/admin_student_filter/clear', 'clearAdminStudentFilter')->name('admin.students.filter.clear');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Monitor Related Routes
|
||||||
|
Route::prefix('monitor')->middleware(['auth', 'verified'])->controller(MonitorController::class)->group(function () {
|
||||||
|
Route::get('/', 'index')->name('monitor.index');
|
||||||
|
Route::get('/enter_flag', 'flagForm')->name('monitor.enterFlag');
|
||||||
|
Route::post('enter_flag/{entry}', 'storeFlag')->name('monitor.storeFlag');
|
||||||
|
});
|
||||||
|
|
||||||
//Route::get('/my_school', [SchoolController::class, 'my_school'])->middleware('auth','verified');
|
//Route::get('/my_school', [SchoolController::class, 'my_school'])->middleware('auth','verified');
|
||||||
//Route::get('/schools/create', [SchoolController::class, 'create'])->middleware('auth','verified');
|
//Route::get('/schools/create', [SchoolController::class, 'create'])->middleware('auth','verified');
|
||||||
//Route::post('/schools', [SchoolController::class, 'store'])->middleware('auth','verified');
|
//Route::post('/schools', [SchoolController::class, 'store'])->middleware('auth','verified');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue