fix endpoints

This commit is contained in:
root
2026-03-11 23:32:54 -04:00
parent 863e330dd8
commit 0f39dbee62
17 changed files with 2066 additions and 7 deletions
+30
View File
@@ -131,4 +131,34 @@ class ExamScoreService
return $count;
}
public function listBySchoolYear(string $table, ?string $schoolYear): array
{
$schoolYear = $this->term->schoolYear($schoolYear);
$schoolYearVariants = $this->term->schoolYearVariants($schoolYear);
if (empty($schoolYearVariants)) {
$schoolYearVariants = [$schoolYear];
}
$rows = DB::table($table . ' as ex')
->select([
'ex.*',
's.firstname as student_firstname',
's.lastname as student_lastname',
's.school_id as student_school_id',
])
->leftJoin('students as s', 's.id', '=', 'ex.student_id')
->whereIn('ex.school_year', $schoolYearVariants)
->orderBy('ex.class_section_id')
->orderBy('s.lastname')
->orderBy('s.firstname')
->get()
->map(fn ($row) => (array) $row)
->all();
return [
'rows' => $rows,
'schoolYear' => $schoolYear,
];
}
}
@@ -87,6 +87,47 @@ class HomeworkScoreService
];
}
public function listBySchoolYear(?string $schoolYear): array
{
$schoolYear = $this->term->schoolYear($schoolYear);
$schoolYearVariants = $this->term->schoolYearVariants($schoolYear);
if (empty($schoolYearVariants)) {
$schoolYearVariants = [$schoolYear];
}
$rows = Homework::query()
->select([
'homework.id',
'homework.student_id',
'homework.school_id',
'homework.class_section_id',
'homework.updated_by',
'homework.homework_index',
'homework.score',
'homework.comment',
'homework.semester',
'homework.school_year',
'homework.created_at',
'homework.updated_at',
's.firstname as student_firstname',
's.lastname as student_lastname',
])
->leftJoin('students as s', 's.id', '=', 'homework.student_id')
->whereIn('homework.school_year', $schoolYearVariants)
->orderBy('homework.class_section_id')
->orderBy('s.lastname')
->orderBy('s.firstname')
->orderBy('homework.homework_index')
->get()
->map(fn ($row) => $row->toArray())
->all();
return [
'rows' => $rows,
'schoolYear' => $schoolYear,
];
}
private function isLockedForAnySchoolYear(int $classSectionId, string $semester, array $schoolYearVariants): bool
{
foreach ($schoolYearVariants as $year) {
@@ -71,6 +71,45 @@ class ParticipationScoreService
];
}
public function listBySchoolYear(?string $schoolYear): array
{
$schoolYear = $this->term->schoolYear($schoolYear);
$schoolYearVariants = $this->term->schoolYearVariants($schoolYear);
if (empty($schoolYearVariants)) {
$schoolYearVariants = [$schoolYear];
}
$rows = Participation::query()
->select([
'participation.id',
'participation.student_id',
'participation.school_id',
'participation.class_section_id',
'participation.updated_by',
'participation.score',
'participation.comment',
'participation.semester',
'participation.school_year',
'participation.created_at',
'participation.updated_at',
's.firstname as student_firstname',
's.lastname as student_lastname',
])
->leftJoin('students as s', 's.id', '=', 'participation.student_id')
->whereIn('participation.school_year', $schoolYearVariants)
->orderBy('participation.class_section_id')
->orderBy('s.lastname')
->orderBy('s.firstname')
->get()
->map(fn ($row) => $row->toArray())
->all();
return [
'rows' => $rows,
'schoolYear' => $schoolYear,
];
}
public function update(int $classSectionId, string $semester, string $schoolYear, array $scores, array $missingOk, int $updatedBy): int
{
if (GradingLock::isLocked($classSectionId, $semester, $schoolYear)) {
@@ -83,6 +83,47 @@ class ProjectScoreService
];
}
public function listBySchoolYear(?string $schoolYear): array
{
$schoolYear = $this->term->schoolYear($schoolYear);
$schoolYearVariants = $this->term->schoolYearVariants($schoolYear);
if (empty($schoolYearVariants)) {
$schoolYearVariants = [$schoolYear];
}
$rows = Project::query()
->select([
'project.id',
'project.student_id',
'project.school_id',
'project.class_section_id',
'project.updated_by',
'project.project_index',
'project.score',
'project.comment',
'project.semester',
'project.school_year',
'project.created_at',
'project.updated_at',
's.firstname as student_firstname',
's.lastname as student_lastname',
])
->leftJoin('students as s', 's.id', '=', 'project.student_id')
->whereIn('project.school_year', $schoolYearVariants)
->orderBy('project.class_section_id')
->orderBy('s.lastname')
->orderBy('s.firstname')
->orderBy('project.project_index')
->get()
->map(fn ($row) => $row->toArray())
->all();
return [
'rows' => $rows,
'schoolYear' => $schoolYear,
];
}
public function update(int $classSectionId, string $semester, string $schoolYear, array $scores, array $missingOk, int $updatedBy): int
{
if (GradingLock::isLocked($classSectionId, $semester, $schoolYear)) {
+41
View File
@@ -82,6 +82,47 @@ class QuizScoreService
];
}
public function listBySchoolYear(?string $schoolYear): array
{
$schoolYear = $this->term->schoolYear($schoolYear);
$schoolYearVariants = $this->term->schoolYearVariants($schoolYear);
if (empty($schoolYearVariants)) {
$schoolYearVariants = [$schoolYear];
}
$rows = Quiz::query()
->select([
'quiz.id',
'quiz.student_id',
'quiz.school_id',
'quiz.class_section_id',
'quiz.updated_by',
'quiz.quiz_index',
'quiz.score',
'quiz.comment',
'quiz.semester',
'quiz.school_year',
'quiz.created_at',
'quiz.updated_at',
's.firstname as student_firstname',
's.lastname as student_lastname',
])
->leftJoin('students as s', 's.id', '=', 'quiz.student_id')
->whereIn('quiz.school_year', $schoolYearVariants)
->orderBy('quiz.class_section_id')
->orderBy('s.lastname')
->orderBy('s.firstname')
->orderBy('quiz.quiz_index')
->get()
->map(fn ($row) => $row->toArray())
->all();
return [
'rows' => $rows,
'schoolYear' => $schoolYear,
];
}
public function update(int $classSectionId, string $semester, string $schoolYear, array $scores, array $missingOk, int $updatedBy): int
{
if (GradingLock::isLocked($classSectionId, $semester, $schoolYear)) {
@@ -66,7 +66,7 @@ class StudentDirectoryService
'student_id' => $studentId,
'name' => trim(($student['firstname'] ?? '') . ' ' . ($student['lastname'] ?? '')),
'age' => $student['age'] ?? 'N/A',
'email' => $emergencyInfo['emergency_contact_name'] ?? '',
'email' => $emergencyInfo['email'] ?? '',
'phone' => $emergencyInfo['cellphone'] ?? '',
'registration_grade' => $student['registration_grade'] ?? 'N/A',
'class_section_name' => $sectionDisplay !== '' ? $sectionDisplay : 'No class assigned',
@@ -161,4 +161,43 @@ class StudentDirectoryService
'school_year' => $schoolYear,
];
}
public function listStudents(?string $schoolYear = null): array
{
$context = $this->configService->context();
$selectedYear = $schoolYear ?: (string) ($context['school_year'] ?? '');
$students = Student::query()
->select([
'id',
'school_id',
'firstname',
'lastname',
'dob',
'age',
'gender',
'is_active',
'registration_grade',
'is_new',
'photo_consent',
'parent_id',
'registration_date',
'tuition_paid',
'rfid_tag',
'semester',
'year_of_registration',
'school_year',
])
->when($selectedYear !== '', fn ($q) => $q->where('school_year', $selectedYear))
->orderBy('lastname')
->orderBy('firstname')
->get()
->toArray();
return [
'students' => $students,
'schoolYear' => $selectedYear,
'currentYear' => (string) ($context['school_year'] ?? ''),
];
}
}