fix gitlab tests
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\BaseModel;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class MissingScoreOverride extends BaseModel
|
||||
@@ -25,11 +26,11 @@ class MissingScoreOverride extends BaseModel
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'student_id' => 'integer',
|
||||
'student_id' => 'integer',
|
||||
'class_section_id' => 'integer',
|
||||
'item_index' => 'integer',
|
||||
'is_allowed' => 'boolean',
|
||||
'updated_by' => 'integer',
|
||||
'item_index' => 'integer',
|
||||
'is_allowed' => 'boolean',
|
||||
'updated_by' => 'integer',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -100,12 +101,12 @@ class MissingScoreOverride extends BaseModel
|
||||
->where('school_year', $schoolYear)
|
||||
->where('item_type', $itemType);
|
||||
|
||||
if (! empty($studentIds)) {
|
||||
if (!empty($studentIds)) {
|
||||
$q->whereIn('student_id', array_map('intval', $studentIds));
|
||||
}
|
||||
|
||||
if ($itemIndexes !== null) {
|
||||
if (! empty($itemIndexes)) {
|
||||
if (!empty($itemIndexes)) {
|
||||
$q->whereIn('item_index', array_map('intval', $itemIndexes));
|
||||
} else {
|
||||
// legacy behavior: if itemIndexes is provided but empty, do nothing.
|
||||
@@ -127,27 +128,25 @@ class MissingScoreOverride extends BaseModel
|
||||
|
||||
foreach ($checkedItems as $item) {
|
||||
$sid = (int) ($item['student_id'] ?? 0);
|
||||
if ($sid <= 0) {
|
||||
continue;
|
||||
}
|
||||
if ($sid <= 0) continue;
|
||||
|
||||
$rows[] = [
|
||||
'student_id' => $sid,
|
||||
'student_id' => $sid,
|
||||
'class_section_id' => $classSectionId,
|
||||
'semester' => $semester,
|
||||
'school_year' => $schoolYear,
|
||||
'item_type' => $itemType,
|
||||
'item_index' => array_key_exists('item_index', $item) ? $item['item_index'] : null,
|
||||
'is_allowed' => 1,
|
||||
'updated_by' => $updatedBy,
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
'semester' => $semester,
|
||||
'school_year' => $schoolYear,
|
||||
'item_type' => $itemType,
|
||||
'item_index' => array_key_exists('item_index', $item) ? $item['item_index'] : null,
|
||||
'is_allowed' => 1,
|
||||
'updated_by' => $updatedBy,
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
];
|
||||
}
|
||||
|
||||
if (! empty($rows)) {
|
||||
if (!empty($rows)) {
|
||||
DB::table((new static)->getTable())->insert($rows);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user