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
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:
@@ -93,8 +93,11 @@ class TeacherAttendanceSubmissionService
|
||||
'semester' => $semester,
|
||||
'school_year' => $schoolYear,
|
||||
];
|
||||
$isTeacher = $this->attendancePolicyService->isTeacher($currentUser['roles']);
|
||||
$dayStatus = strtolower((string) ($dayPolicyRow['status'] ?? 'draft'));
|
||||
|
||||
if (! $this->attendancePolicyService->canEditDay($dayPolicyRow, $currentUser)) {
|
||||
if (! $this->attendancePolicyService->canEditDay($dayPolicyRow, $currentUser)
|
||||
&& ! ($isTeacher && $dayStatus === 'submitted')) {
|
||||
throw new RuntimeException('Attendance is locked for your role.');
|
||||
}
|
||||
|
||||
@@ -137,8 +140,6 @@ class TeacherAttendanceSubmissionService
|
||||
}
|
||||
}
|
||||
|
||||
$isTeacher = $this->attendancePolicyService->isTeacher($currentUser['roles']);
|
||||
|
||||
DB::transaction(function () use (
|
||||
$user,
|
||||
$assignedTeachers,
|
||||
@@ -172,6 +173,15 @@ class TeacherAttendanceSubmissionService
|
||||
$position = strtolower((string) ($teacher['position'] ?? 'main'));
|
||||
$position = $position === 'ta' ? 'ta' : 'main';
|
||||
|
||||
if ($isTeacher && DB::table('staff_attendance')
|
||||
->where('user_id', $teacherId)
|
||||
->whereDate('date', $attendDate)
|
||||
->where('semester', $semester)
|
||||
->where('school_year', $schoolYear)
|
||||
->exists()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$staffPayload = [
|
||||
'role_name' => 'Teacher',
|
||||
'status' => strtolower((string) ($teachersData[$teacherId]['status'] ?? 'present')),
|
||||
@@ -204,10 +214,7 @@ class TeacherAttendanceSubmissionService
|
||||
$existing = $existingByStudent[$studentId] ?? null;
|
||||
|
||||
if ($isTeacher && $existing) {
|
||||
$lockInfo = $detectExternalSubmission($existing);
|
||||
if (($lockInfo['locked'] ?? false) === true) {
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->studentAttendanceWriterService->saveOrUpdateStudentAttendance([
|
||||
|
||||
Reference in New Issue
Block a user