fix is_active student flag and apply it in all pages
Deploy to Shared Hosting / Shared hosting deploy (push) Failing after 48s
Tests / PHPUnit (push) Successful in 1m17s

This commit is contained in:
root
2026-08-20 12:59:59 -04:00
parent 0a31aa1393
commit bfa343b69f
57 changed files with 820 additions and 240 deletions
+23 -7
View File
@@ -267,9 +267,9 @@ public function showUpdateAttendanceForm()
$currentSunday = $sundayDates[2];
// Students roster for this section/year/semester (try section code, then PK fallback)
$students = $this->studentModel->getByClassAndYear($class_section_id, $schoolYear, $semester);
$students = $this->studentModel->getActiveByClassAndYear($class_section_id, $schoolYear, $semester);
if (empty($students) && $classSectionPk > 0 && $classSectionPk !== $class_section_id) {
$students = $this->studentModel->getByClassAndYear($classSectionPk, $schoolYear, $semester);
$students = $this->studentModel->getActiveByClassAndYear($classSectionPk, $schoolYear, $semester);
}
// Build student attendance rows
@@ -598,11 +598,12 @@ public function showUpdateAttendanceForm()
$seenStudentIds[$studentId] = true;
$student = $this->studentModel
->select('id, firstname, lastname, school_id')
->select('id, firstname, lastname, school_id, is_active')
->where('id', $studentId)
->where('is_active', 1)
->first();
if (!$student) continue;
$student['enrollment_status'] = $sc['enrollment_status'] ?? '';
$student['is_withdrawn'] = (int)($sc['is_withdrawn'] ?? 0);
$studentsBySection[$secCode][] = $student;
$hasRoster = true;
@@ -1027,9 +1028,11 @@ public function showUpdateAttendanceForm()
continue;
}
$student = $this->studentModel
->select('id, firstname, lastname, school_id')
->select('id, firstname, lastname, school_id, is_active')
->find($studentId);
if (!$student) continue;
$student['enrollment_status'] = $sc['enrollment_status'] ?? '';
$student['is_withdrawn'] = (int)($sc['is_withdrawn'] ?? 0);
$studentsBySection[$secCode][] = $student;
$hasRoster = true;
@@ -1603,7 +1606,7 @@ public function showUpdateAttendanceForm()
// optional score updates (never bubble)
try {
$studentUserInfo = $this->studentModel->getStudentInfoByClassSectionId(
$studentUserInfo = $this->studentModel->getActiveStudentInfoByClassSectionId(
$classSectionId,
$semester,
$schoolYear
@@ -1722,6 +1725,19 @@ public function showUpdateAttendanceForm()
$semester = (string)($this->semester ?? '');
$schoolYear = (string)($this->schoolYear ?? '');
$activeStudents = $this->studentModel->getActiveByClassAndYear($classSectionId, $schoolYear, $semester);
$activeStudentIds = array_fill_keys(array_map(static fn(array $row): int => (int)($row['id'] ?? 0), $activeStudents), true);
$attendanceData = array_values(array_filter($attendanceData, static function ($row) use ($activeStudentIds): bool {
$sid = (int)($row['student_id'] ?? 0);
return $sid > 0 && isset($activeStudentIds[$sid]);
}));
if (empty($attendanceData)) {
return redirect()->to('/teacher/showupdate_attendance?class_section_id=' . $classSectionId)
->with('status', 'error')
->with('message', 'No active student attendance data provided.');
}
// Existing attendance rows for today (used to lock parent/admin submissions)
$existingRows = $this->attendanceDataModel
->where('class_section_id', $classSectionId)
@@ -2027,7 +2043,7 @@ public function showUpdateAttendanceForm()
}
try {
$studentUserInfo = $this->studentModel->getStudentInfoByClassSectionId($classSectionId, $this->semester, $this->schoolYear);
$studentUserInfo = $this->studentModel->getActiveStudentInfoByClassSectionId($classSectionId, $this->semester, $this->schoolYear);
$this->semesterScoreService->updateScoresForStudents($studentUserInfo);
} catch (\Throwable $e) {
// ignore