fix registration enrollment of students
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user