add class progress and fix endpoints

This commit is contained in:
root
2026-03-12 17:27:49 -04:00
parent 0f39dbee62
commit 33be0c9a0d
40 changed files with 2086 additions and 438 deletions
@@ -0,0 +1,48 @@
<?php
namespace App\Services\ClassProgress;
use App\Models\SubjectCurriculum;
class ClassProgressMetaService
{
public function subjectSections(): array
{
return (array) config('progress.subject_sections', []);
}
public function statusOptions(): array
{
return (array) config('progress.status_options', []);
}
public function sundayOptions(int $count = 12): array
{
$start = now();
if ((int) $start->format('w') !== 0) {
$start = $start->next('Sunday');
}
$options = [];
for ($i = 0; $i < $count; $i++) {
$options[] = $start->format('Y-m-d');
$start = $start->addDays(7);
}
return $options;
}
public function curriculumOptions(?int $classId): array
{
if (!$classId) {
return [];
}
$options = [];
foreach ($this->subjectSections() as $slug => $section) {
$options[$slug] = SubjectCurriculum::getOptionsForClass((int) $classId, (string) $slug);
}
return $options;
}
}