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