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
+22 -6
View File
@@ -40,15 +40,15 @@ class StudentYearStatusService
return (int) ($row['is_new'] ?? 1) === 1;
}
public function upsert(int $studentId, string $schoolYear, bool $isNew): void
public function upsert(int $studentId, string $schoolYear, bool $isNew): bool
{
if ($studentId <= 0) {
return;
return false;
}
$schoolYear = trim($schoolYear);
if (! preg_match('/^\d{4}-\d{4}$/', $schoolYear) || ! $this->db->tableExists('student_year_status')) {
return;
return false;
}
$flag = $isNew ? 1 : 0;
@@ -59,19 +59,35 @@ class StudentYearStatusService
->first();
if (is_array($existing) && isset($existing['id'])) {
$this->yearStatusModel->update((int) $existing['id'], [
return (bool) $this->yearStatusModel->update((int) $existing['id'], [
'is_new' => $flag,
]);
return;
}
$this->yearStatusModel->insert([
return (bool) $this->yearStatusModel->insert([
'student_id' => $studentId,
'school_year' => $schoolYear,
'is_new' => $flag,
]);
}
public function hasStatus(int $studentId, string $schoolYear): bool
{
if ($studentId <= 0) {
return false;
}
$schoolYear = trim($schoolYear);
if (! preg_match('/^\d{4}-\d{4}$/', $schoolYear) || ! $this->db->tableExists('student_year_status')) {
return false;
}
return $this->yearStatusModel
->where('student_id', $studentId)
->where('school_year', $schoolYear)
->countAllResults() > 0;
}
/**
* Mark students who existed in a source school year as returning in the target year.
*