fix teacher attendance
API CI/CD / Validate (composer + pint) (push) Successful in 3m10s
API CI/CD / Test (PHPUnit) (push) Failing after 5m2s
API CI/CD / Build frontend assets (push) Successful in 1m2s
API CI/CD / Security audit (push) Failing after 49s
API CI/CD / Deploy to shared hosting (PHP) (push) Has been skipped

This commit is contained in:
root
2026-07-07 21:51:51 -04:00
parent e0dfc3ec82
commit c891a82012
7 changed files with 102 additions and 29 deletions
@@ -123,8 +123,12 @@ class AttendanceQueryService
];
}
public function teacherAttendanceFormData(?int $userId, int $requestedSectionId = 0): array
{
public function teacherAttendanceFormData(
?int $userId,
int $requestedSectionId = 0,
?string $requestedSchoolYear = null,
?string $requestedSemester = null
): array {
if (! $userId) {
throw new RuntimeException('User not logged in.');
}
@@ -134,8 +138,12 @@ class AttendanceQueryService
? trim(($teacher->firstname ?? '').' '.($teacher->lastname ?? ''))
: 'Unknown Teacher';
$semester = $this->attendanceService->currentSemester();
$schoolYear = $this->attendanceService->currentSchoolYear();
$semester = trim((string) $requestedSemester) !== ''
? trim((string) $requestedSemester)
: $this->attendanceService->currentSemester();
$schoolYear = trim((string) $requestedSchoolYear) !== ''
? trim((string) $requestedSchoolYear)
: $this->attendanceService->currentSchoolYear();
$assignments = $this->teacherClass->getClassAssignmentsByUserId($userId, $schoolYear, $semester);
@@ -187,7 +195,9 @@ class AttendanceQueryService
implode(',', array_fill(0, count($sundayDates), '?')).')';
foreach ($students as $student) {
$student = is_array($student) ? $student : (array) $student;
$student = is_array($student)
? $student
: (method_exists($student, 'toArray') ? $student->toArray() : (array) $student);
unset($student['created_by'], $student['updated_by'], $student['deleted_at']);
$studentId = (int) $student['id'];