diff --git a/app/Actions/Tabulation/GetAuditionSeats.php b/app/Actions/Tabulation/GetAuditionSeats.php
new file mode 100644
index 0000000..0dc1101
--- /dev/null
+++ b/app/Actions/Tabulation/GetAuditionSeats.php
@@ -0,0 +1,40 @@
+getSeats($audition);
+ }
+
+ protected function getSeats(Audition $audition)
+ {
+ $ensembles = Ensemble::where('event_id', $audition->event_id)->orderBy('rank')->get();
+ $seats = Seat::with('student.school')->where('audition_id', $audition->id)->orderBy('seat')->get();
+ $return = [];
+ foreach ($ensembles as $ensemble) {
+ $ensembleSeats = $seats->filter(fn ($seat) => $seat->ensemble_id === $ensemble->id);
+ foreach ($ensembleSeats as $seat) {
+ $return[] = [
+ 'ensemble' => $ensemble->name,
+ 'seat' => $seat->seat,
+ 'student_name' => $seat->student->full_name(),
+ 'school_name' => $seat->student->school->name,
+ ];
+ }
+ }
+
+ return $return;
+ }
+}
diff --git a/app/Actions/Tabulation/PublishSeats.php b/app/Actions/Tabulation/PublishSeats.php
new file mode 100644
index 0000000..7c37b23
--- /dev/null
+++ b/app/Actions/Tabulation/PublishSeats.php
@@ -0,0 +1,31 @@
+id
+ Seat::where('audition_id', $audition->id)->delete();
+ foreach ($seats as $seat) {
+ Seat::create([
+ 'ensemble_id' => $seat['ensemble_id'],
+ 'audition_id' => $seat['audition_id'],
+ 'seat' => $seat['seat'],
+ 'entry_id' => $seat['entry_id'],
+ ]);
+ }
+ $audition->addFlag('seats_published');
+ Cache::forget('resultsSeatList');
+ }
+}
diff --git a/app/Actions/Tabulation/UnpublishSeats.php b/app/Actions/Tabulation/UnpublishSeats.php
new file mode 100644
index 0000000..e00cbbc
--- /dev/null
+++ b/app/Actions/Tabulation/UnpublishSeats.php
@@ -0,0 +1,21 @@
+removeFlag('seats_published');
+ Cache::forget('resultsSeatList');
+ Seat::where('audition_id', $audition->id)->delete();
+ }
+}
diff --git a/app/Http/Controllers/Tabulation/SeatAuditionController.php b/app/Http/Controllers/Tabulation/SeatAuditionFormController.php
similarity index 87%
rename from app/Http/Controllers/Tabulation/SeatAuditionController.php
rename to app/Http/Controllers/Tabulation/SeatAuditionFormController.php
index e75ee9f..f06c392 100644
--- a/app/Http/Controllers/Tabulation/SeatAuditionController.php
+++ b/app/Http/Controllers/Tabulation/SeatAuditionFormController.php
@@ -3,6 +3,7 @@
namespace App\Http\Controllers\Tabulation;
use App\Actions\Tabulation\CalculateEntryScore;
+use App\Actions\Tabulation\GetAuditionSeats;
use App\Actions\Tabulation\RankAuditionEntries;
use App\Http\Controllers\Controller;
use App\Models\Audition;
@@ -11,7 +12,7 @@ use App\Services\DoublerService;
use App\Services\EntryService;
use Illuminate\Http\Request;
-class SeatAuditionController extends Controller
+class SeatAuditionFormController extends Controller
{
protected CalculateEntryScore $calc;
@@ -39,6 +40,13 @@ class SeatAuditionController extends Controller
public function __invoke(Request $request, Audition $audition)
{
+ // If a seating proposal was posted, deal wth it
+ if ($request->method() == 'POST') {
+ $requestedEnsembleAccepts = $request->input('ensembleAccept');
+ } else {
+ $requestedEnsembleAccepts = false;
+ }
+
$entryData = [];
$entries = $this->ranker->rank('seating', $audition);
$entries->load('student.school');
@@ -89,15 +97,15 @@ class SeatAuditionController extends Controller
});
}
- return view('tabulation.auditionSeating', compact('entryData', 'audition', 'rightPanel', 'seatableEntries'));
+ return view('tabulation.auditionSeating', compact('entryData', 'audition', 'rightPanel', 'seatableEntries', 'requestedEnsembleAccepts'));
}
protected function pickRightPanel(Audition $audition, array $seatable)
{
if ($audition->hasFlag('seats_published')) {
+ $resultsWindow = new GetAuditionSeats;
$rightPanel['view'] = 'tabulation.auditionSeating-show-published-seats';
- $rightPanel['data'] = '';
-
+ $rightPanel['data'] = $resultsWindow($audition);
return $rightPanel;
}
if ($seatable['allScored'] == false || $seatable['doublersResolved'] == false) {
diff --git a/app/Http/Controllers/Tabulation/SeatingPublicationController.php b/app/Http/Controllers/Tabulation/SeatingPublicationController.php
new file mode 100644
index 0000000..2adfda6
--- /dev/null
+++ b/app/Http/Controllers/Tabulation/SeatingPublicationController.php
@@ -0,0 +1,33 @@
+id.'seatingProposal';
+ $seats = $request->session()->get($sessionKey);
+
+ $publisher($audition, $seats);
+
+ $request->session()->forget($sessionKey);
+
+ return redirect()->route('seating.audition', ['audition' => $audition->id]);
+ }
+
+ public function unpublishSeats(Request $request, Audition $audition)
+ {
+ $publisher = new UnpublishSeats;
+ $publisher($audition);
+
+ return redirect()->route('seating.audition', ['audition' => $audition->id]);
+ }
+}
diff --git a/app/Http/Controllers/Tabulation/TabulationController.php b/app/Http/Controllers/Tabulation/TabulationController.php
index e49c324..f162968 100644
--- a/app/Http/Controllers/Tabulation/TabulationController.php
+++ b/app/Http/Controllers/Tabulation/TabulationController.php
@@ -35,57 +35,6 @@ class TabulationController extends Controller
$this->auditionService = $auditionService;
}
- public function status()
- {
- // Needs to provide a collection of auditions
- $auditions = $this->tabulationService->getAuditionsWithStatus('seating');
-
- return view('tabulation.status', compact('auditions'));
- }
-
- public function auditionSeating(Request $request, Audition $audition)
- {
- if ($request->method() == 'POST') {
- $requestedEnsembleAccepts = $request->input('ensembleAccept');
- } else {
- $requestedEnsembleAccepts = false;
- }
-
- $entries = $this->tabulationService->auditionEntries($audition->id);
- $entries = $entries->filter(function ($entry) {
- return $entry->for_seating;
- });
-
- $doublerComplete = true;
- foreach ($entries as $entry) {
-
- if ($this->doublerService->studentIsDoubler($entry->student_id)) { // If this entry is a doubler
- if ($this->doublerService->getDoublerInfo($entry->student_id)[$entry->id]['status'] === 'undecided') { // If there is no decision for this entry
- $doublerComplete = false;
- }
- }
- }
-
- $scoringComplete = $entries->every(function ($entry) {
- return $entry->scoring_complete;
- });
- $ensembleLimits = $this->seatingService->getLimitForAudition($audition->id);
- $auditionComplete = $scoringComplete && $doublerComplete;
-
- $seatableEntries = $this->seatingService->getSeatableEntries($audition->id);
- $seatableEntries = $seatableEntries->filter(function ($entry) {
- return $entry->for_seating;
- });
-
- return view('tabulation.auditionSeating', compact('audition',
- 'entries',
- 'scoringComplete',
- 'doublerComplete',
- 'auditionComplete',
- 'ensembleLimits',
- 'seatableEntries',
- 'requestedEnsembleAccepts'));
- }
public function publishSeats(Request $request, Audition $audition)
{
diff --git a/resources/views/tabulation/auditionSeating-fill-seats-form.blade.php b/resources/views/tabulation/auditionSeating-fill-seats-form.blade.php
index b2a4b71..dd5794c 100644
--- a/resources/views/tabulation/auditionSeating-fill-seats-form.blade.php
+++ b/resources/views/tabulation/auditionSeating-fill-seats-form.blade.php
@@ -3,12 +3,12 @@
@endphp