diff --git a/.runParalellTestsAll/tests - paralell.run.xml b/.runParalellTestsAll/tests - paralell.run.xml
new file mode 100644
index 0000000..06e48dc
--- /dev/null
+++ b/.runParalellTestsAll/tests - paralell.run.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/Http/Controllers/Admin/AuditionController.php b/app/Http/Controllers/Admin/AuditionController.php
index 9025bf0..9bd8fec 100644
--- a/app/Http/Controllers/Admin/AuditionController.php
+++ b/app/Http/Controllers/Admin/AuditionController.php
@@ -181,37 +181,4 @@ class AuditionController extends Controller
return to_route('admin.auditions.index')->with('success', 'Audition deleted successfully');
}
-
- public function prepareDraw()
- {
- if (! Auth::user()->is_admin) {
- abort(403);
- }
- $allAuditions = Audition::with('entries')->orderBy('score_order')->get();
- $nodraw_auditions = $allAuditions->filter(function ($audition) {
- return $audition->has_no_draw();
- });
- $drawn_auditions = $allAuditions->filter(function ($audition) {
- return $audition->has_complete_draw();
- });
- $partial_draw_auditions = $allAuditions->filter(function ($audition) {
- return $audition->has_partial_draw();
- });
-
- return view('admin.entries.prepare_draw',
- compact('nodraw_auditions', 'drawn_auditions', 'partial_draw_auditions'));
- }
-
- public function runDraw(Request $request)
- {
- if (! Auth::user()->is_admin) {
- abort(403);
- }
- $draw_auditions = Audition::with('entries')->find(array_keys($request->input('auditions')));
- foreach ($draw_auditions as $audition) {
- $audition->runDraw();
- }
-
- return redirect(' / admin / auditions / run_draw');
- }
}
diff --git a/app/Http/Controllers/Admin/StudentController.php b/app/Http/Controllers/Admin/StudentController.php
index 24d29a5..9916f64 100644
--- a/app/Http/Controllers/Admin/StudentController.php
+++ b/app/Http/Controllers/Admin/StudentController.php
@@ -6,10 +6,8 @@ use App\Http\Controllers\Controller;
use App\Models\Audition;
use App\Models\School;
use App\Models\Student;
-use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
-use Illuminate\Support\Facades\Log;
use function abort;
use function to_route;
use function view;
@@ -50,7 +48,7 @@ class StudentController extends Controller
'school_id' => ['required', 'exists:schools,id'],
]);
- $student = Student::create([
+ Student::create([
'first_name' => request('first_name'),
'last_name' => request('last_name'),
'grade' => request('grade'),
@@ -69,11 +67,12 @@ class StudentController extends Controller
$maxGrade = Audition::max('maximum_grade');
$schools = School::orderBy('name')->get();
$student->loadCount('entries');
+
return view('admin.students.edit',
['student' => $student, 'schools' => $schools, 'minGrade' => $minGrade, 'maxGrade' => $maxGrade]);
}
- public function update(Request $request, Student $student)
+ public function update(Student $student)
{
if (! Auth::user()->is_admin) {
abort(403);
@@ -105,8 +104,7 @@ class StudentController extends Controller
public function destroy(Student $student)
{
- Log::debug('Deleting student '.$student->id);
- if($student->entries()->count() > 0) {
+ if ($student->entries()->count() > 0) {
return to_route('admin.students.index')->with('error', 'You cannot delete a student with entries.');
}
$name = $student->full_name();
diff --git a/app/Http/Controllers/Tabulation/EntryFlagController.php b/app/Http/Controllers/Tabulation/EntryFlagController.php
new file mode 100644
index 0000000..32da870
--- /dev/null
+++ b/app/Http/Controllers/Tabulation/EntryFlagController.php
@@ -0,0 +1,103 @@
+validate([
+ 'entry_id' => 'required|exists:entries,id',
+ ]);
+ $entry = Entry::with('flags')->withCount('scoreSheets')->find($validData['entry_id']);
+
+ // If any results are published, get gone
+ if ($entry->audition->hasFlag('seats_published')) {
+ return to_route('entry-flags.noShowSelect')->with('error',
+ 'Cannot enter a no-show for an entry in an audition where seats are published');
+ }
+ if ($entry->audition->hasFlag('advance_published')) {
+ return to_route('entry-flags.noShowSelect')->with('error',
+ 'Cannot enter a no-show for an entry in an audition where advancement is published');
+ }
+
+ if ($entry->hasFlag('no_show')) {
+ $formId = 'no-show-cancellation-form';
+ $buttonName = 'Remove No Show';
+ $submitRouteName = 'entry-flags.undoNoShow';
+ $cardHeading = 'Undo No-Show';
+ $method = 'DELETE';
+ } else {
+ $formId = 'no-show-confirmation-form';
+ $buttonName = 'Confirm No Show';
+ $submitRouteName = 'entry-flags.enterNoShow';
+ $cardHeading = 'Confirm No-Show';
+ $method = 'POST';
+ }
+ $scores = [];
+ if ($entry->score_sheets_count > 0) {
+ $scores = $entry->scoreSheets;
+ $scores->load('judge');
+ }
+
+ return view('tabulation.no_show_confirm',
+ compact('entry',
+ 'formId',
+ 'buttonName',
+ 'submitRouteName',
+ 'cardHeading',
+ 'method',
+ 'scores'));
+ }
+
+ public function enterNoShow(Entry $entry)
+ {
+ if ($entry->audition->hasFlag('seats_published')) {
+ return to_route('entry-flags.noShowSelect')->with('error',
+ 'Cannot enter a no-show for an entry in an audition where seats are published');
+ }
+ if ($entry->audition->hasFlag('advance_published')) {
+ return to_route('entry-flags.noShowSelect')->with('error',
+ 'Cannot enter a no-show for an entry in an audition where advancement is published');
+ }
+ DB::table('score_sheets')->where('entry_id', $entry->id)->delete();
+
+ $entry->addFlag('no_show');
+
+ $msg = 'No Show has been entered for '.$entry->audition->name.' #'.$entry->draw_number.' (ID: '.$entry->id.').';
+
+ return to_route('entry-flags.noShowSelect')->with('success', $msg);
+ }
+
+ public function undoNoShow(Entry $entry)
+ {
+ if ($entry->audition->hasFlag('seats_published')) {
+ return to_route('entry-flags.noShowSelect')->with('error',
+ 'Cannot undo a no-show for an entry in an audition where seats are published');
+ }
+ if ($entry->audition->hasFlag('advance_published')) {
+ return to_route('entry-flags.noShowSelect')->with('error',
+ 'Cannot undo a no-show for an entry in an audition where advancement is published');
+ }
+
+ $entry->removeFlag('no_show');
+
+ return to_route('entry-flags.noShowSelect')->with('success',
+ 'No Show status has been removed for '.$entry->audition->name.' #'.$entry->draw_number.' (ID: '.$entry->id.').');
+ }
+}
diff --git a/app/Http/Controllers/Tabulation/ScoreController.php b/app/Http/Controllers/Tabulation/ScoreController.php
index 5504d77..5f2fe69 100644
--- a/app/Http/Controllers/Tabulation/ScoreController.php
+++ b/app/Http/Controllers/Tabulation/ScoreController.php
@@ -7,36 +7,44 @@ use App\Models\Entry;
use App\Models\ScoreSheet;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Session;
+
class ScoreController extends Controller
{
public function chooseEntry(Request $request)
{
- return view('tabulation.choose_entry');
+ $method = 'GET';
+ $formRoute = 'scores.entryScoreSheet';
+
+ return view('tabulation.choose_entry', compact('method', 'formRoute'));
}
- public function destroyScore(ScoreSheet $score) {
+ public function destroyScore(ScoreSheet $score)
+ {
$score->delete();
- return redirect()->back()->with('success','Score Deleted');
+
+ return redirect()->back()->with('success', 'Score Deleted');
}
public function entryScoreSheet(Request $request)
{
$existing_sheets = [];
- $entry = Entry::with(['student','audition.room.judges'])->find($request->input('entry_id'));
+ $entry = Entry::with(['student', 'audition.room.judges'])->find($request->input('entry_id'));
$judges = $entry->audition->room->judges;
foreach ($judges as $judge) {
- $scoreSheet = ScoreSheet::where('entry_id',$entry->id)->where('user_id',$judge->id)->first();
+ $scoreSheet = ScoreSheet::where('entry_id', $entry->id)->where('user_id', $judge->id)->first();
if ($scoreSheet) {
- Session::flash('caution','Scores exist for this entry. Now editing existing scores');
+ Session::flash('caution', 'Scores exist for this entry. Now editing existing scores');
$existing_sheets[$judge->id] = $scoreSheet;
}
}
$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');
+ if (! $entry) {
+ return redirect()->route('tabulation.chooseEntry')->with('error', 'Entry not found');
}
- return view('tabulation.entry_score_sheet', compact('entry','judges','scoring_guide','subscores','existing_sheets'));
+
+ return view('tabulation.entry_score_sheet',
+ compact('entry', 'judges', 'scoring_guide', 'subscores', 'existing_sheets'));
}
public function saveEntryScoreSheet(Request $request, Entry $entry)
@@ -52,16 +60,17 @@ class ScoreController extends Controller
$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());
+ return redirect(url()->previous())->with('error',
+ $judge->full_name().': '.$scoreValidation)->with('oldScores', $request->all());
}
$scoreSubmission = $request->input('judge'.$judge->id);
$scoresToSave = [];
foreach ($subscores as $subscore) {
$scoresToSave[$subscore->id] = [
- 'subscore_id'=>$subscore->id,
+ 'subscore_id' => $subscore->id,
'subscore_name' => $subscore->name,
- 'score' => intval($scoreSubmission[$subscore->id])
+ 'score' => intval($scoreSubmission[$subscore->id]),
];
}
$preparedScoreSheets[$judge->id]['scores'] = $scoresToSave;
@@ -72,7 +81,7 @@ class ScoreController extends Controller
['subscores' => $sheet['scores']]
);
}
- return redirect()->route('scores.chooseEntry')->with('success',count($preparedScoreSheets) . " Scores saved");
- }
+ return redirect()->route('scores.chooseEntry')->with('success', count($preparedScoreSheets).' Scores saved');
+ }
}
diff --git a/app/Http/Middleware/CheckIfCanTab.php b/app/Http/Middleware/CheckIfCanTab.php
index 7d28c2c..67b0513 100644
--- a/app/Http/Middleware/CheckIfCanTab.php
+++ b/app/Http/Middleware/CheckIfCanTab.php
@@ -25,7 +25,7 @@ class CheckIfCanTab
return $next($request);
}
- return redirect('/')->with('error', 'You do not have access to score tabulation.');
+ return redirect('dashboard')->with('error', 'You are not authorized to perform this action');
}
}
diff --git a/app/Models/Audition.php b/app/Models/Audition.php
index 175c053..d33b721 100644
--- a/app/Models/Audition.php
+++ b/app/Models/Audition.php
@@ -16,14 +16,6 @@ class Audition extends Model
protected $guarded = [];
- protected $rankedEntries = null;
-
- protected static $completeAuditions = null;
-
- protected $fully_scored; // Set by TabulationService
-
- protected $scored_entries_count; //Set by TabulationService
-
public function event(): BelongsTo
{
return $this->belongsTo(Event::class);
@@ -49,84 +41,6 @@ class Audition extends Model
return '$'.number_format($this->entry_fee / 100, 2);
}
- public function has_no_draw(): bool
- {
- // return true if all of my entries have a null draw_number
- //return $this->entries->every(fn($entry) => is_null($entry->draw_number));
- // return $this->entries()->whereNotNull('draw_number')->doesntExist();
- if ($this->entries->count() == 0) {
- return false;
- }
- if ($this->relationLoaded('entries')) {
- return $this->entries->every(function ($entry) {
- return is_null($entry->draw_number);
- });
- } else {
- return $this->entries()->whereNotNull('draw_number')->doesntExist();
- }
-
- }
-
- public function has_complete_draw(): bool
- {
- // return true if all of my entries have a draw_number
- // return $this->entries->every(fn($entry) => !is_null($entry->draw_number));
- // return $this->entries()->whereNull('draw_number')->doesntExist();
- if ($this->entries->count() == 0) {
- return false;
- }
- if ($this->relationLoaded('entries')) {
- return $this->entries->every(function ($entry) {
- return ! is_null($entry->draw_number);
- });
- } else {
- return $this->entries()->whereNull('draw_number')->doesntExist();
- }
- }
-
- public function has_partial_draw(): bool
- {
- if ($this->entries->count() == 0) {
- return false;
- }
- // return true I have at least one entry with a null draw number AND at least one entry with a non-null draw number
- //return $this->entries->contains(fn($entry) => is_null($entry->draw_number)) && $this->entries->contains(fn($entry) => !is_null($entry->draw_number));
-
- //$hasNull = $this->entries()->whereNull('draw_number')->exists();
- //$hasNotNull = $this->entries()->whereNotNull('draw_number')->exists();
- //return $hasNull && $hasNotNull;
-
- if ($this->relationLoaded('entries')) {
- $hasNull = $this->entries->contains(function ($entry) {
- return is_null($entry->draw_number);
- });
-
- $hasNotNull = $this->entries->contains(function ($entry) {
- return ! is_null($entry->draw_number);
- });
-
- return $hasNull && $hasNotNull;
- } else {
- $hasNull = $this->entries()->whereNull('draw_number')->exists();
- $hasNotNull = $this->entries()->whereNotNull('draw_number')->exists();
-
- return $hasNull && $hasNotNull;
- }
- }
-
- public function runDraw(): null
- {
- $entries = $this->entries->shuffle();
-
- foreach ($entries as $index => $entry) {
- $entry->update(['draw_number' => $index + 1]);
- $entry->save();
- }
-
- return null;
- // TODO move all draw functions to a DrawService
- }
-
/**
* @return BelongsToMany|User[]
*/
diff --git a/database/factories/EnsembleFactory.php b/database/factories/EnsembleFactory.php
index a0b950c..4e85c3f 100644
--- a/database/factories/EnsembleFactory.php
+++ b/database/factories/EnsembleFactory.php
@@ -2,10 +2,12 @@
namespace Database\Factories;
+use App\Models\Ensemble;
+use App\Models\Event;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
- * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Ensemble>
+ * @extends Factory
*/
class EnsembleFactory extends Factory
{
@@ -17,8 +19,8 @@ class EnsembleFactory extends Factory
public function definition(): array
{
return [
- 'name' => $this->faker->name,
- 'event_id' => \App\Models\Event::factory(),
+ 'name' => $this->faker->words(4, true),
+ 'event_id' => Event::factory(),
'code' => $this->faker->randomLetter().$this->faker->randomLetter,
'rank' => $this->faker->numberBetween(1, 10),
];
diff --git a/database/seeders/ScoreAllAuditions.php b/database/seeders/ScoreAllAuditions.php
index 230199d..9a9f569 100644
--- a/database/seeders/ScoreAllAuditions.php
+++ b/database/seeders/ScoreAllAuditions.php
@@ -4,7 +4,6 @@ namespace Database\Seeders;
use App\Models\ScoreSheet;
use App\Models\User;
-use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class ScoreAllAuditions extends Seeder
@@ -16,23 +15,23 @@ class ScoreAllAuditions extends Seeder
{
$judges = User::all();
foreach ($judges as $judge) {
- foreach( $judge->rooms as $room) {
- foreach ($room->auditions as $audition){
+ foreach ($judge->rooms as $room) {
+ foreach ($room->auditions as $audition) {
$scoringGuide = $audition->scoringGuide;
$subscores = $scoringGuide->subscores;
- foreach ($audition->entries as $entry){
+ foreach ($audition->entries as $entry) {
$scoreArray = [];
foreach ($subscores as $subscore) {
$scoreArray[$subscore->id] = [
- 'score' => mt_rand(0,100),
+ 'score' => mt_rand(0, 100),
'subscore_id' => $subscore->id,
- 'subscore_name' => $subscore->name
+ 'subscore_name' => $subscore->name,
];
}
ScoreSheet::create([
'user_id' => $judge->id,
'entry_id' => $entry->id,
- 'subscores' => $scoreArray
+ 'subscores' => $scoreArray,
]);
}
}
diff --git a/resources/views/components/form/toggle-checkbox.blade.php b/resources/views/components/form/toggle-checkbox.blade.php
index 3d6086a..1e88ebf 100644
--- a/resources/views/components/form/toggle-checkbox.blade.php
+++ b/resources/views/components/form/toggle-checkbox.blade.php
@@ -2,7 +2,7 @@
@error($name)
diff --git a/resources/views/tabulation/choose_entry.blade.php b/resources/views/tabulation/choose_entry.blade.php
index c7a88e9..2f4c01a 100644
--- a/resources/views/tabulation/choose_entry.blade.php
+++ b/resources/views/tabulation/choose_entry.blade.php
@@ -1,9 +1,16 @@
+@php
+ /**
+* @var string $method Method for the select form
+ * @var string $formRoute Route for the form action. Should be a route name
+ */
+@endphp
+
Choose EntryChoose Entry