fix class progress admin side

This commit is contained in:
root
2026-04-25 21:56:33 -04:00
parent 5c544f93b9
commit 5e8fa682b9
9 changed files with 475 additions and 172 deletions
@@ -24,7 +24,7 @@ class ClassProgressIndexRequest extends ClassProgressFormRequest
'status' => $statuses ? ['nullable', 'in:' . implode(',', $statuses)] : ['nullable', 'string'],
'group_by_week' => ['nullable', 'boolean'],
'page' => ['nullable', 'integer', 'min:1'],
'per_page' => ['nullable', 'integer', 'min:1', 'max:100'],
'per_page' => ['nullable', 'integer', 'min:1', 'max:200'],
'sort_by' => ['nullable', 'in:week_start,week_end,subject,status,created_at'],
'sort_dir' => ['nullable', 'in:asc,desc'],
];
@@ -18,6 +18,7 @@ class ClassSectionIndexRequest extends ApiFormRequest
'class_id' => ['nullable', 'integer', 'min:1'],
'school_year' => ['nullable', 'string', 'max:9'],
'semester' => ['nullable', 'string', 'max:255'],
'with_students' => ['nullable', 'boolean'],
'sort_by' => ['nullable', 'string', 'in:class_section_name,class_section_id,class_id,school_year,semester,class_name'],
'sort_dir' => ['nullable', 'string', 'in:asc,desc'],
'page' => ['nullable', 'integer', 'min:1'],
@@ -17,16 +17,19 @@ class ClassProgressGroupCollection extends ResourceCollection
{
$groups = [];
foreach ($paginator->items() as $report) {
$key = $report->week_start?->format('Y-m-d') ?? '';
if ($key === '') {
$weekStart = $report->week_start?->format('Y-m-d') ?? '';
$sectionId = (int) ($report->class_section_id ?? 0);
if ($weekStart === '' || $sectionId <= 0) {
continue;
}
$key = $sectionId . '|' . $weekStart;
if (!isset($groups[$key])) {
$groups[$key] = [
'week_start' => $key,
'week_start' => $weekStart,
'week_end' => $report->week_end?->format('Y-m-d'),
'class_section_id' => $report->class_section_id,
'class_section_id' => $sectionId,
'class_section_name' => $report->classSection?->class_section_name ?? '',
'reports' => [],
];