fix registration enrollment of students
Deploy to Shared Hosting / Shared hosting deploy (push) Failing after 48s
Tests / PHPUnit (push) Successful in 1m19s

This commit is contained in:
root
2026-08-26 21:36:03 -04:00
parent a354d78fa9
commit 9676261d65
7 changed files with 208 additions and 53 deletions
+29 -13
View File
@@ -707,7 +707,35 @@ final class EnrollmentTransitionService
}
}
return trim((string) ($student['school_year'] ?? '')) === $targetSchoolYear;
if ($this->db->fieldExists('school_year', 'students')) {
return trim((string) ($student['school_year'] ?? '')) === $targetSchoolYear;
}
return ! $this->studentHasPriorSchoolHistory($studentId, $targetSchoolYear);
}
private function studentHasPriorSchoolHistory(int $studentId, string $targetSchoolYear): bool
{
if ($studentId <= 0) {
return false;
}
foreach (['student_class', 'enrollments', 'student_decisions'] as $table) {
if (! $this->db->tableExists($table) || ! $this->db->fieldExists('school_year', $table)) {
continue;
}
$count = $this->db->table($table)
->where('student_id', $studentId)
->where('school_year !=', $targetSchoolYear)
->countAllResults();
if ($count > 0) {
return true;
}
}
return false;
}
private function schoolYearByName(string $schoolYear): ?array
@@ -2009,19 +2037,7 @@ final class EnrollmentTransitionService
private function applyHouseholdLastNameRule(array &$evaluation, int $parentId, ?string $sourceSchoolYear = null): void
{
if (! empty($evaluation['first_enrollment'])) {
$evaluation['family_name_check_ok'] = true;
return;
}
$students = $this->linkedStudentsForParent($parentId);
$sourceSchoolYear = trim((string) $sourceSchoolYear);
if ($sourceSchoolYear !== '') {
$students = array_values(array_filter(
$students,
fn (array $student): bool => $this->sourceAssignment((int) ($student['id'] ?? 0), $sourceSchoolYear) !== null
));
}
if (count($students) <= 1) {
$evaluation['family_name_check_ok'] = true;