add tests batch 20
This commit is contained in:
+16
-23
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\BaseModel;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class Homework extends BaseModel
|
||||
@@ -34,20 +35,20 @@ class Homework extends BaseModel
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'student_id' => 'integer',
|
||||
'school_id' => 'integer',
|
||||
'student_id' => 'integer',
|
||||
'school_id' => 'integer',
|
||||
'class_section_id' => 'integer',
|
||||
'updated_by' => 'integer',
|
||||
'homework_index' => 'integer',
|
||||
'updated_by' => 'integer',
|
||||
'homework_index' => 'integer',
|
||||
|
||||
// keep numeric; change to 'integer' if your scores are whole numbers
|
||||
'score' => 'decimal:2',
|
||||
'max_points' => 'decimal:2',
|
||||
'locked_by' => 'integer',
|
||||
'locked_at' => 'datetime',
|
||||
'score' => 'decimal:2',
|
||||
'max_points' => 'decimal:2',
|
||||
'locked_by' => 'integer',
|
||||
'locked_at' => 'datetime',
|
||||
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
];
|
||||
|
||||
/* Optional relationships */
|
||||
@@ -92,18 +93,10 @@ class Homework extends BaseModel
|
||||
foreach ($rows as $r) {
|
||||
$score = $r->score ?? null;
|
||||
|
||||
if ($score === null) {
|
||||
continue;
|
||||
}
|
||||
if (is_string($score) && trim($score) === '') {
|
||||
continue;
|
||||
}
|
||||
if ($score === '') {
|
||||
continue;
|
||||
}
|
||||
if (! is_numeric($score)) {
|
||||
continue;
|
||||
}
|
||||
if ($score === null) continue;
|
||||
if (is_string($score) && trim($score) === '') continue;
|
||||
if ($score === '') continue;
|
||||
if (!is_numeric($score)) continue;
|
||||
|
||||
$total += (float) $score;
|
||||
$count++;
|
||||
@@ -115,4 +108,4 @@ class Homework extends BaseModel
|
||||
|
||||
return round($total / $count, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user