fix teacher page
This commit is contained in:
@@ -44,6 +44,7 @@ class ScoreController extends BaseApiController
|
||||
'semester' => $data['semester'] ?? null,
|
||||
'school_year' => $data['school_year'] ?? null,
|
||||
'scores_locked' => $data['scoresLocked'] ?? false,
|
||||
'missing_ok_map' => $data['missing_ok_map'] ?? [],
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ class TeacherClass extends BaseModel
|
||||
protected $fillable = [
|
||||
'teacher_id',
|
||||
'class_section_id',
|
||||
'semester',
|
||||
'school_year',
|
||||
'position',
|
||||
'updated_by',
|
||||
@@ -404,6 +405,7 @@ class TeacherClass extends BaseModel
|
||||
return [
|
||||
'teacher_id' => [$req, 'integer', 'min:1', 'exists:users,id'],
|
||||
'class_section_id' => [$req, 'integer', 'min:1'],
|
||||
'semester' => [$req, 'string', 'max:25'],
|
||||
'school_year' => [$req, 'string', 'max:9'],
|
||||
'position' => [$req, 'string', 'in:' . implode(',', self::allowedPositions())],
|
||||
'updated_by' => ['nullable', 'integer'],
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user