fix teacher page

This commit is contained in:
root
2026-06-04 19:26:24 -04:00
parent 6408906f07
commit 6fa656bb6c
9 changed files with 1370 additions and 4 deletions
@@ -114,6 +114,7 @@ class ScoreDashboardService
'homework' => $this->normalizeScore($scoreRow->homework_avg),
'quiz' => $this->normalizeScore($scoreRow->quiz_avg),
'project' => $this->normalizeScore($scoreRow->project_avg),
'participation' => $this->normalizeScore($scoreRow->participation_score),
'midterm_exam' => $this->normalizeScore($scoreRow->midterm_exam_score),
'final_exam' => $this->normalizeScore($scoreRow->final_exam_score),
'attendance' => $this->normalizeScore($scoreRow->attendance_score),
@@ -125,6 +126,24 @@ class ScoreDashboardService
unset($student);
$classSection = ClassSection::query()->where('class_section_id', $classSectionId)->first();
$missingOkMap = [
'ptap_comment' => MissingScoreOverride::getOverridesMap($classSectionId, $semesterLabel, $schoolYear, 'ptap_comment'),
];
if (strtolower($semesterLabel) === 'fall') {
$missingOkMap['midterm_comment'] = MissingScoreOverride::getOverridesMap(
$classSectionId,
$semesterLabel,
$schoolYear,
'midterm_comment'
);
} elseif (strtolower($semesterLabel) === 'spring') {
$missingOkMap['final_comment'] = MissingScoreOverride::getOverridesMap(
$classSectionId,
$semesterLabel,
$schoolYear,
'final_comment'
);
}
return [
'students' => $students,
@@ -133,6 +152,7 @@ class ScoreDashboardService
'semester' => $semesterLabel,
'school_year' => $schoolYear,
'scoresLocked' => GradingLock::isLocked($classSectionId, $semesterLabel, $schoolYear),
'missing_ok_map' => $missingOkMap,
];
}
@@ -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();