fix teacher page
This commit is contained in:
@@ -16,6 +16,7 @@ class TeacherAssignmentService
|
||||
{
|
||||
$context = $this->configService->context();
|
||||
$schoolYear = $schoolYear ?: (string) ($context['school_year'] ?? '');
|
||||
$semester = trim((string) ($context['semester'] ?? ''));
|
||||
|
||||
$teachers = User::getTeachersAndTAs();
|
||||
$classSections = ClassSection::query()
|
||||
@@ -39,6 +40,7 @@ class TeacherAssignmentService
|
||||
|
||||
$assignments = TeacherClass::query()
|
||||
->when($schoolYear !== '', fn ($q) => $q->where('school_year', $schoolYear))
|
||||
->when($semester !== '', fn ($q) => $q->where('semester', $semester))
|
||||
->get()
|
||||
->toArray();
|
||||
|
||||
@@ -113,12 +115,13 @@ class TeacherAssignmentService
|
||||
{
|
||||
$context = $this->configService->context();
|
||||
$schoolYear = (string) ($input['school_year'] ?? $context['school_year'] ?? '');
|
||||
$semester = trim((string) ($input['semester'] ?? $context['semester'] ?? ''));
|
||||
$teacherId = (int) ($input['teacher_id'] ?? 0);
|
||||
$classSectionId = (int) ($input['class_section_id'] ?? 0);
|
||||
$teacherRole = (string) ($input['teacher_role'] ?? '');
|
||||
$loggedInUserId = (int) ($input['updated_by'] ?? 0);
|
||||
|
||||
if ($teacherId <= 0 || $classSectionId <= 0 || $schoolYear === '') {
|
||||
if ($teacherId <= 0 || $classSectionId <= 0 || $schoolYear === '' || $semester === '') {
|
||||
return ['ok' => false, 'message' => 'Missing required parameters for assignment.'];
|
||||
}
|
||||
|
||||
@@ -132,6 +135,7 @@ class TeacherAssignmentService
|
||||
->where('teacher_id', $teacherId)
|
||||
->where('class_section_id', $classSectionId)
|
||||
->where('position', $position)
|
||||
->where('semester', $semester)
|
||||
->where('school_year', $schoolYear)
|
||||
->first();
|
||||
|
||||
@@ -143,6 +147,7 @@ class TeacherAssignmentService
|
||||
'teacher_id' => $teacherId,
|
||||
'class_section_id' => $classSectionId,
|
||||
'position' => $position,
|
||||
'semester' => $semester,
|
||||
'school_year' => $schoolYear,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
@@ -162,15 +167,17 @@ class TeacherAssignmentService
|
||||
$teacherId = (int) ($input['teacher_id'] ?? 0);
|
||||
$classSectionId = (int) ($input['class_section_id'] ?? 0);
|
||||
$position = strtolower((string) ($input['position'] ?? ''));
|
||||
$semester = trim((string) ($input['semester'] ?? $context['semester'] ?? ''));
|
||||
$schoolYear = trim((string) ($input['school_year'] ?? $context['school_year'] ?? ''));
|
||||
|
||||
if ($teacherId <= 0 || $classSectionId <= 0 || !in_array($position, ['main', 'ta'], true) || $schoolYear === '') {
|
||||
if ($teacherId <= 0 || $classSectionId <= 0 || !in_array($position, ['main', 'ta'], true) || $schoolYear === '' || $semester === '') {
|
||||
return ['ok' => false, 'message' => 'Missing or invalid data for deletion.'];
|
||||
}
|
||||
|
||||
$assignment = TeacherClass::query()
|
||||
->where('teacher_id', $teacherId)
|
||||
->where('class_section_id', $classSectionId)
|
||||
->where('semester', $semester)
|
||||
->where('school_year', $schoolYear)
|
||||
->where('position', $position)
|
||||
->first();
|
||||
|
||||
Reference in New Issue
Block a user