Rewrite scoring all auditions.
This commit is contained in:
parent
4f317f1458
commit
b8ce2bc6db
|
|
@ -2,9 +2,9 @@
|
||||||
|
|
||||||
namespace Database\Seeders;
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use App\Actions\Tabulation\EnterScore;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Database\Seeder;
|
use Illuminate\Database\Seeder;
|
||||||
use App\Models\ScoreSheet;
|
|
||||||
|
|
||||||
class ScoreAllAuditions extends Seeder
|
class ScoreAllAuditions extends Seeder
|
||||||
{
|
{
|
||||||
|
|
@ -13,26 +13,19 @@ class ScoreAllAuditions extends Seeder
|
||||||
*/
|
*/
|
||||||
public function run(): void
|
public function run(): void
|
||||||
{
|
{
|
||||||
|
$recorder = app(EnterScore::class);
|
||||||
$judges = User::all();
|
$judges = User::all();
|
||||||
foreach ($judges as $judge) {
|
foreach ($judges as $judge) { // Iterate over all users
|
||||||
foreach ($judge->rooms as $room) {
|
foreach ($judge->rooms as $room) { // Iterate over each user's assigned rooms
|
||||||
foreach ($room->auditions as $audition) {
|
foreach ($room->auditions as $audition) { // Iterate over each audition in that room
|
||||||
$scoringGuide = $audition->scoringGuide;
|
$scoringGuide = $audition->scoringGuide; // Load the scoring guide for that audition
|
||||||
$subscores = $scoringGuide->subscores;
|
$subscores = $scoringGuide->subscores; // Get the subscores for that audition
|
||||||
foreach ($audition->entries as $entry) {
|
foreach ($audition->entries as $entry) { // Iterate over each entry in that audition
|
||||||
$scoreArray = [];
|
$scoreArray = [];
|
||||||
foreach ($subscores as $subscore) {
|
foreach ($subscores as $subscore) {
|
||||||
$scoreArray[$subscore->id] = [
|
$scoreArray[$subscore->id] = mt_rand(0, $subscore->max_score);
|
||||||
'score' => mt_rand(0, 100),
|
|
||||||
'subscore_id' => $subscore->id,
|
|
||||||
'subscore_name' => $subscore->name,
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
ScoreSheet::create([
|
$recorder($judge, $entry, $scoreArray);
|
||||||
'user_id' => $judge->id,
|
|
||||||
'entry_id' => $entry->id,
|
|
||||||
'subscores' => $scoreArray,
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue