add test batches
This commit is contained in:
@@ -11,7 +11,9 @@ use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class StudentAssignmentService
|
||||
{
|
||||
public function __construct(private StudentConfigService $configService) {}
|
||||
public function __construct(private StudentConfigService $configService)
|
||||
{
|
||||
}
|
||||
|
||||
public function assignClasses(int $studentId, array $classSectionIds, bool $isEventOnly, ?int $userId = null): array
|
||||
{
|
||||
@@ -25,7 +27,7 @@ class StudentAssignmentService
|
||||
}
|
||||
|
||||
$student = Student::query()->find($studentId);
|
||||
if (! $student) {
|
||||
if (!$student) {
|
||||
return ['ok' => false, 'message' => 'Student not found.'];
|
||||
}
|
||||
|
||||
@@ -45,7 +47,7 @@ class StudentAssignmentService
|
||||
}
|
||||
|
||||
$missing = array_diff($classSectionIds, array_keys($sectionMap));
|
||||
if (! empty($missing)) {
|
||||
if (!empty($missing)) {
|
||||
return ['ok' => false, 'message' => 'One or more selected classes do not exist.'];
|
||||
}
|
||||
|
||||
@@ -103,7 +105,7 @@ class StudentAssignmentService
|
||||
}
|
||||
}
|
||||
|
||||
if (! $isEventOnly) {
|
||||
if (!$isEventOnly) {
|
||||
$enrollment = Enrollment::query()
|
||||
->where('student_id', $studentId)
|
||||
->where('school_year', $schoolYear)
|
||||
@@ -141,12 +143,12 @@ class StudentAssignmentService
|
||||
$displayNames = [];
|
||||
foreach ($classSectionIds as $classSectionId) {
|
||||
$section = $sectionMap[$classSectionId] ?? null;
|
||||
if (! $section) {
|
||||
if (!$section) {
|
||||
continue;
|
||||
}
|
||||
$name = (string) ($section['class_section_name'] ?? '');
|
||||
if ($name === '') {
|
||||
$name = 'Section #'.$classSectionId;
|
||||
$name = 'Section #' . $classSectionId;
|
||||
}
|
||||
$displayNames[] = $name;
|
||||
}
|
||||
@@ -178,7 +180,7 @@ class StudentAssignmentService
|
||||
->where('school_year', $schoolYear)
|
||||
->first();
|
||||
|
||||
if (! $row) {
|
||||
if (!$row) {
|
||||
return ['ok' => false, 'message' => 'Assignment not found for this student/class.'];
|
||||
}
|
||||
|
||||
@@ -210,7 +212,7 @@ class StudentAssignmentService
|
||||
->first();
|
||||
|
||||
if ($enrollment) {
|
||||
$newClassId = ! empty($remainingIds) ? $remainingIds[0] : null;
|
||||
$newClassId = !empty($remainingIds) ? $remainingIds[0] : null;
|
||||
if ((int) $enrollment->class_section_id === $classSectionId || $newClassId !== null) {
|
||||
$enrollment->update([
|
||||
'class_section_id' => $newClassId,
|
||||
@@ -296,7 +298,7 @@ class StudentAssignmentService
|
||||
$payload['updated_by'] = $modifiedBy;
|
||||
}
|
||||
|
||||
$results[$table.'_updated'] = DB::table($table)
|
||||
$results[$table . '_updated'] = DB::table($table)
|
||||
->where('student_id', $studentId)
|
||||
->where('semester', $semester)
|
||||
->where('school_year', $schoolYear)
|
||||
@@ -310,7 +312,6 @@ class StudentAssignmentService
|
||||
{
|
||||
$values = array_map('intval', $ids);
|
||||
$values = array_values(array_unique(array_filter($values, static fn ($v) => $v > 0)));
|
||||
|
||||
return $values;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user