Initial commit
This commit is contained in:
17
fix_max_scores.php
Normal file
17
fix_max_scores.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
require __DIR__.'/vendor/autoload.php';
|
||||
$app = require_once __DIR__.'/bootstrap/app.php';
|
||||
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
|
||||
$kernel->bootstrap();
|
||||
|
||||
use App\Models\Attempt;
|
||||
|
||||
$attempts = Attempt::whereNull('max_score')->get();
|
||||
foreach ($attempts as $attempt) {
|
||||
if ($attempt->quiz) {
|
||||
$max = $attempt->quiz->questions->sum('points');
|
||||
$attempt->update(['max_score' => $max]);
|
||||
echo "Updated attempt {$attempt->id} with max_score {$max}\n";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user