Compare commits

...

12 Commits

20 changed files with 640 additions and 422 deletions

View File

@ -65,14 +65,14 @@ class YearEndCleanup
if (is_array($options)) {
if (in_array('deleteRooms', $options)) {
DB::table('auditions')->update(['room_id' => null]);
DB::table('auditions')->update(['room_id' => 0]);
DB::table('auditions')->update(['order_in_room' => '0']);
DB::table('room_user')->truncate();
DB::table('rooms')->delete();
DB::table('rooms')->where('id', '>', 0)->delete();
}
if (in_array('removeAuditionsFromRoom', $options)) {
DB::table('auditions')->update(['room_id' => null]);
DB::table('auditions')->update(['room_id' => 0]);
DB::table('auditions')->update(['order_in_room' => '0']);
}

View File

@ -0,0 +1,41 @@
<?php
namespace App\Console\Commands;
use App\Actions\Tabulation\EnterScore;
use App\Models\ScoreSheet;
use Illuminate\Console\Command;
class RecalculateJudgeTotalsCommand extends Command
{
protected $signature = 'audition:recalculate-judge-totals';
protected $description = 'Recalculates total scores for all score sheets for unpubished auditions';
public function handle(): void
{
$this->info('Starting score recalculation...');
$scoreSheets = ScoreSheet::all();
foreach ($scoreSheets as $scoreSheet) {
if ($scoreSheet->entry->audition->hasFlag('seats_published')) {
continue;
}
$this->recalculate($scoreSheet);
}
$this->info('Score recalculation completed successfully.');
}
private function recalculate(ScoreSheet|int $scoreSheet): void
{
if (is_int($scoreSheet)) {
$scoreSheet = ScoreSheet::findOrFail($scoreSheet);
}
$scribe = app()->make(EnterScore::class);
$scoreSubmission = [];
foreach ($scoreSheet->subscores as $subscore) {
$scoreSubmission[$subscore['subscore_id']] = $subscore['score'];
}
$scribe($scoreSheet->judge, $scoreSheet->entry, $scoreSubmission, $scoreSheet);
}
}

View File

@ -8,14 +8,14 @@ use Illuminate\Console\Command;
/**
* @codeCoverageIgnore
*/
class RecalculateScores extends Command
class RecalculateTotalScores extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'audition:recalculate-scores';
protected $signature = 'audition:recalculate-total-scores';
/**
* The console command description.

View File

@ -28,10 +28,14 @@ class PrintCards extends Controller
public function print(\App\Actions\Print\PrintCards $printer)
{
// dump(request()->all());
if (request()->audition == null) {
return redirect()->back()->with('error', 'You must specify at least one audition');
}
// if (request()->audition == null) {
// return redirect()->back()->with('error', 'You must specify at least one audition');
// }
if (request()->audition) {
$selectedAuditionIds = array_keys(request()->audition);
} else {
$selectedAuditionIds = [];
}
$cardQuery = Entry::whereIn('audition_id', $selectedAuditionIds);
// Process Filters

View File

@ -110,6 +110,10 @@ class ScoringGuideController extends Controller
'Cannot update a subscore for a different scoring guide');
}
$validateData = $validateData = $request->validated();
if (! auditionSetting('advanceTo')) {
$validateData['for_advance'] = 0;
$validateData['for_seating'] = 1;
}
$subscore->update([
'name' => $validateData['name'],

View File

@ -3,6 +3,7 @@
namespace App\Http\Controllers\Judging;
use App\Actions\Tabulation\EnterScore;
use App\Exceptions\AuditionAdminException;
use App\Http\Controllers\Controller;
use App\Models\Audition;
use App\Models\Entry;
@ -100,7 +101,11 @@ class JudgingController extends Controller
// Enter the score
/** @noinspection PhpUnhandledExceptionInspection */
try {
$enterScore(Auth::user(), $entry, $validatedData['score']);
} catch (AuditionAdminException $e) {
return redirect()->back()->with('error', $e->getMessage());
}
// Deal with an advancement vote if needed
$this->advancementVote($request, $entry);

View File

@ -45,7 +45,15 @@ class PrelimJudgingController extends Controller
$oldSheet = PrelimScoreSheet::where('user_id', Auth::id())->where('entry_id',
$entry->id)->value('subscores') ?? null;
return view('judging.prelim_entry_form', compact('entry', 'oldSheet'));
if ($oldSheet) {
$formRoute = 'update.savePrelimScoreSheet';
$formMethod = 'PATCH';
} else {
$formRoute = 'judging.savePrelimScoreSheet';
$formMethod = 'POST';
}
return view('judging.prelim_entry_form', compact('entry', 'oldSheet', 'formRoute', 'formMethod'));
}
/**

View File

@ -81,7 +81,7 @@ class AdvancementController extends Controller
return $entry->hasFlag('no_show');
});
$scoringComplete = $audition->entries->where('for_advancement, true')->every(function ($entry) {
$scoringComplete = $audition->entries->where('for_advancement', true)->every(function ($entry) {
return $entry->totalScore || $entry->hasFlag('no_show');
});

View File

@ -78,7 +78,7 @@ return [
'url' => env('LOG_SLACK_WEBHOOK_URL'),
'username' => env('LOG_SLACK_USERNAME', 'Laravel Log'),
'emoji' => env('LOG_SLACK_EMOJI', ':boom:'),
'level' => env('LOG_LEVEL', 'critical'),
'level' => env('LOG_LEVEL', 'debug'),
'replace_placeholders' => true,
],

737
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -18,6 +18,7 @@
</include>
</source>
<php>
<ini name="memory_limit" value="512M"/>
<env name="APP_ENV" value="testing"/>
<env name="APP_MAINTENANCE_DRIVER" value="file"/>
<env name="BCRYPT_ROUNDS" value="4"/>

View File

@ -13,8 +13,7 @@
<tr>
<x-table.th>Name</x-table.th>
<x-table.th>School</x-table.th>
<x-table.th>Email</x-table.th>
<x-table.th>Cell Phone</x-table.th>
<x-table.th>Cell Phone<br />Email</x-table.th>
<x-table.th>Judging Preference</x-table.th>
<x-table.th>Privileges</x-table.th>
</tr>
@ -22,10 +21,16 @@
<x-table.body>
@foreach($users as $user)
<tr class="hover:bg-gray-50">
<x-table.td><a href="{{ route('admin.users.edit',$user) }}">{{ $user->full_name(true) }}</a>{{ $user->hasFlag('head_director') ? ' *':'' }}</x-table.td>
<x-table.td>
<a href="{{ route('admin.users.edit',$user) }}">{{ $user->full_name(true) }}</a>
{{ $user->hasFlag('head_director') ? ' *':'' }}
@if(! $user->email_verified_at)
<p class="text-xs font-light">Unverified Account</p>
@endif
</x-table.td>
<x-table.td>{{ $user->has_school() ? $user->school->name : ' ' }}</x-table.td>
<x-table.td>{{ $user->email }}</x-table.td>
<x-table.td>{{ $user->cell_phone }}</x-table.td>
<x-table.td>{{ $user->cell_phone }}<br/>{{ $user->email }}</x-table.td>
<x-table.td>{{ $user->judging_preference }}</x-table.td>
<x-table.td>
@if($user->is_admin)

View File

@ -2,7 +2,7 @@
<x-layout.page-header>Year End Reset</x-layout.page-header>
<x-card.card class="mt-5 max-w-xl m-auto">
<x-card.heading>Reset Options</x-card.heading>
<x-form.form action="{{ route('admin.year_end_procedures') }}">
<x-form.form action="{{ route('admin.execute_year_end_procedures') }}">
<x-form.checkbox name="options[]" label="Delete Rooms" value="deleteRooms" />
<x-form.checkbox name="options[]" label="Remove Auditions From Rooms" value="removeAuditionsFromRoom" />
<x-form.checkbox name="options[]" label="Unassign Judges" value="unassignJudges" />

View File

@ -29,14 +29,14 @@
<option value="user">Director</option>
<option value="admin" selected>Admin</option>
</x-form.select>
<x-layout.nav-link href="/admin" :active="request()->is('admin')">Dashboard</x-layout.nav-link>
<x-layout.nav-link href="/admin/users" :active="request()->is('admin/users')">Users</x-layout.nav-link>
<x-layout.nav-link href="/admin/schools" :active="request()->is('admin/schools')">Schools</x-layout.nav-link>
<x-layout.nav-link href="/admin/students" :active="request()->is('admin/students')">Students</x-layout.nav-link>
<x-layout.nav-link href="/admin/entries" :active="request()->is('admin/entries')">Entries</x-layout.nav-link>
<x-layout.nav-link href="/admin/auditions" :active="request()->is('admin/auditions')">Auditions</x-layout.nav-link>
<x-layout.nav-link href="/admin/scoring" :active="request()->is('admin/scoring')">Scoring</x-layout.nav-link>
<x-layout.nav-link href="/admin/rooms" :active="request()->is('admin/rooms')">Rooms</x-layout.nav-link>
<x-layout.navbar.nav-link href="/admin" :active="request()->is('admin')">Dashboard</x-layout.navbar.nav-link>
<x-layout.navbar.nav-link href="/admin/users" :active="request()->is('admin/users')">Users</x-layout.navbar.nav-link>
<x-layout.navbar.nav-link href="/admin/schools" :active="request()->is('admin/schools')">Schools</x-layout.navbar.nav-link>
<x-layout.navbar.nav-link href="/admin/students" :active="request()->is('admin/students')">Students</x-layout.navbar.nav-link>
<x-layout.navbar.nav-link href="/admin/entries" :active="request()->is('admin/entries')">Entries</x-layout.navbar.nav-link>
<x-layout.navbar.nav-link href="/admin/auditions" :active="request()->is('admin/auditions')">Auditions</x-layout.navbar.nav-link>
<x-layout.navbar.nav-link href="/admin/scoring" :active="request()->is('admin/scoring')">Scoring</x-layout.navbar.nav-link>
<x-layout.navbar.nav-link href="/admin/rooms" :active="request()->is('admin/rooms')">Rooms</x-layout.navbar.nav-link>
{{-- <a href="/dashboard" class="bg-indigo-700 text-white rounded-md px-3 py-2 text-sm font-medium" aria-current="page">Dashboard</a>--}}
{{-- <a href="/students" class="text-white hover:bg-indigo-500 hover:bg-opacity-75 rounded-md px-3 py-2 text-sm font-medium">Students</a>--}}

View File

@ -15,11 +15,9 @@
</ul>
</x-slot:subheading>
</x-card.heading>
<x-form.form method="POST" action="{{ route('judging.savePrelimScoreSheet', $entry) }}">
@if($oldSheet)
{{-- if there are existing scores, make this a patch request --}}
@method('PATCH')
@endif
<x-form.form method="POST" action="{{ route($formRoute, $entry) }}">
@method($formMethod)
<x-card.list.body class="mt-1">
@foreach($entry->audition->prelimDefinition->scoringGuide->subscores()->orderBy('display_order')->get() as $subscore)
@php

View File

@ -38,7 +38,7 @@ Route::middleware(['auth', 'verified', CheckIfAdmin::class])->prefix('admin/')->
// Year-end procedures
Route::get('/year_end_procedures', [YearEndResetController::class, 'index'])->name('admin.year_end_procedures');
Route::post('/year_end_procedures', [YearEndResetController::class, 'execute'])->name('admin.year_end_procedures');
Route::post('/year_end_procedures', [YearEndResetController::class, 'execute'])->name('admin.execute_year_end_procedures');
Route::post('/auditions/roomUpdate', [
AuditionController::class, 'roomUpdate',

View File

@ -22,7 +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');
route::patch('/enterScore/{entry}', 'updatePrelimScoreSheet')->name('judging.updatePrelimScoreSheet');
});
// Bonus score judging routes

View File

@ -25,7 +25,7 @@ it('calls the YearEndCleanup action', function () {
$mock->shouldReceive('__invoke')->once();
app()->instance(YearEndCleanup::class, $mock);
actAsAdmin();
$response = $this->post(route('admin.year_end_procedures'));
$response = $this->post(route('admin.execute_year_end_procedures'));
$response->assertRedirect(route('dashboard'))
->with('success', 'Year end cleanup completed. ');
});

View File

@ -1,6 +1,5 @@
<?php
use App\Models\Entry;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
@ -15,183 +14,8 @@ describe('index method', function () {
$response = $this->get(route('monitor.index'));
$response->assertForbidden();
});
it('presents a form to choose an entry', function () {
$user = User::factory()->create();
$user->addFlag('monitor');
actingAs($user);
$response = $this->get(route('monitor.index'));
$response->assertOk()
->assertViewIs('tabulation.choose_entry');
});
});
describe('method flagForm is a form to decide what type of flag to put on an entry', function () {
it('only allows those assigned to monitor to access this page', function () {
$user = User::factory()->create();
actingAs($user);
$response = $this->post(route('monitor.enterFlag'));
$response->assertStatus(403);
});
it('wont add flags to an entry in an audition with published seats', function () {
$user = User::factory()->create();
$user->addFlag('monitor');
$user->refresh();
actingAs($user);
$entry = Entry::factory()->create();
$entry->audition->addFlag('seats_published');
$response = $this->post(route('monitor.enterFlag'), ['entry_id' => $entry->id]);
$response->assertRedirect(route('monitor.index'))
->assertSessionHas('error');
expect($response->getSession()->get('error'))->toBe('Cannot set flags while results are published');
});
it('wont add flags to an entry in an audition with published advancement', function () {
$user = User::factory()->create();
$user->addFlag('monitor');
$user->refresh();
actingAs($user);
$entry = Entry::factory()->create();
$entry->audition->addFlag('advancement_published');
$response = $this->post(route('monitor.enterFlag'), ['entry_id' => $entry->id]);
$response->assertRedirect(route('monitor.index'))
->assertSessionHas('error');
expect($response->getSession()->get('error'))->toBe('Cannot set flags while results are published');
});
it('wont add flags to an entry in an audition with scores', function () {
$user = User::factory()->create();
$user->addFlag('monitor');
$user->refresh();
actingAs($user);
$entry = Entry::factory()->create();
DB::table('score_sheets')->insert([
'user_id' => $user->id,
'entry_id' => $entry->id,
'subscores' => json_encode([12, 3, 5]),
'seating_total' => 1,
'advancement_total' => 1,
]);
$response = $this->post(route('monitor.enterFlag'), ['entry_id' => $entry->id]);
$response->assertRedirect(route('monitor.index'))
->assertSessionHas('error');
expect($response->getSession()->get('error'))->toBe('That entry has existing scores');
});
it('displays a form to choose a flag for the entry', function () {
$user = User::factory()->create();
$user->addFlag('monitor');
$user->refresh();
actingAs($user);
$entry = Entry::factory()->create();
$response = $this->post(route('monitor.enterFlag'), ['entry_id' => $entry->id]);
$response->assertOk()
->assertViewIs('monitor_entry_flag_form');
});
});
describe('method storeFlag stores the flag and returns to the select entry form', function () {
it('only allows those assigned to monitor to access this page', function () {
$user = User::factory()->create();
$entry = Entry::factory()->create();
actingAs($user);
$response = $this->post(route('monitor.storeFlag', $entry), ['flag' => 'no_show']);
$response->assertForbidden();
});
it('wont add flags to an entry in an audition with published seats', function () {
$user = User::factory()->create();
$user->addFlag('monitor');
$user->refresh();
actingAs($user);
$entry = Entry::factory()->create();
$entry->audition->addFlag('seats_published');
$response = $this->post(route('monitor.storeFlag', $entry), ['flag' => 'no_show']);
$response->assertRedirect(route('monitor.index'))
->assertSessionHas('error');
expect($response->getSession()->get('error'))->toBe('Cannot set flags while results are published');
});
it('wont add flags to an entry in an audition with published advancement', function () {
$user = User::factory()->create();
$user->addFlag('monitor');
$user->refresh();
actingAs($user);
$entry = Entry::factory()->create();
$entry->audition->addFlag('advancement_published');
$response = $this->post(route('monitor.storeFlag', $entry), ['flag' => 'no_show']);
$response->assertRedirect(route('monitor.index'))
->assertSessionHas('error');
expect($response->getSession()->get('error'))->toBe('Cannot set flags while results are published');
});
it('wont add flags to an entry in an audition with scores', function () {
$user = User::factory()->create();
$user->addFlag('monitor');
$user->refresh();
actingAs($user);
$entry = Entry::factory()->create();
DB::table('score_sheets')->insert([
'user_id' => $user->id,
'entry_id' => $entry->id,
'subscores' => json_encode([12, 3, 5]),
'seating_total' => 1,
'advancement_total' => 1,
]);
$response = $this->post(route('monitor.storeFlag', $entry), ['flag' => 'no_show']);
$response->assertRedirect(route('monitor.index'))
->assertSessionHas('error');
expect($response->getSession()->get('error'))->toBe('That entry has existing scores');
});
it('wont add a bogus flag', function () {
$user = User::factory()->create();
$user->addFlag('monitor');
$user->refresh();
actingAs($user);
$entry = Entry::factory()->create();
$response = $this->post(route('monitor.storeFlag', $entry), ['action' => 'nonsense']);
$response->assertRedirect(route('monitor.index'))
->assertSessionHas('error');
expect($response->getSession()->get('error'))->toBe('Invalid action requested');
});
it('can add a failed-prelim tag to an entry', function () {
$user = User::factory()->create();
$user->addFlag('monitor');
$user->refresh();
actingAs($user);
$entry = Entry::factory()->create();
$response = $this->post(route('monitor.storeFlag', $entry), ['action' => 'failed-prelim']);
$response->assertRedirect(route('monitor.index'));
$entry->refresh();
expect($entry->hasFlag('failed_prelim'))->toBeTrue();
});
it('can add a no-show tag to an entry', function () {
$user = User::factory()->create();
$user->addFlag('monitor');
$user->refresh();
actingAs($user);
$entry = Entry::factory()->create();
$response = $this->post(route('monitor.storeFlag', $entry), ['action' => 'no-show']);
$response->assertRedirect(route('monitor.index'));
$entry->refresh();
expect($entry->hasFlag('no_show'))->toBeTrue();
});
it('can clear flags', function () {
$user = User::factory()->create();
$user->addFlag('monitor');
$user->refresh();
actingAs($user);
$entry = Entry::factory()->create();
$entry->addFlag('no_show');
$entry->refresh();
expect($entry->hasFlag('no_show'))->toBeTrue();
$response = $this->post(route('monitor.storeFlag', $entry), ['action' => 'clear']);
$response->assertRedirect(route('monitor.index'));
$entry->refresh();
expect($entry->hasFlag('no_show'))->toBeFalse();
});
it('needs additional tests written', function () {
// TODO: Write tests for new monitor pabe
});
});

View File

@ -2,6 +2,11 @@ import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
export default defineConfig({
server: {
cors: {
origin: /^https?:\/\/(?:(?:[^:]+\.)?localhost|auditionadmin\.test|127\.0\.0\.1|\[::1\])(?::\d+)?$/,
}
},
plugins: [
laravel({
input: ['resources/css/app.css', 'resources/js/app.js'],