fix parent pages and teachers and admin
API CI/CD / Validate (composer + pint) (push) Successful in 3m8s
API CI/CD / Build frontend assets (push) Successful in 1m2s
API CI/CD / Test (PHPUnit) (push) Failing after 6m5s
API CI/CD / Security audit (push) Failing after 52s
API CI/CD / Deploy to shared hosting (PHP) (push) Has been skipped
API CI/CD / Validate (composer + pint) (push) Successful in 3m8s
API CI/CD / Build frontend assets (push) Successful in 1m2s
API CI/CD / Test (PHPUnit) (push) Failing after 6m5s
API CI/CD / Security audit (push) Failing after 52s
API CI/CD / Deploy to shared hosting (PHP) (push) Has been skipped
This commit is contained in:
@@ -5,6 +5,7 @@ namespace App\Services\ClassProgress;
|
||||
use App\Models\Configuration;
|
||||
use App\Models\SubjectCurriculum;
|
||||
use App\Services\SemesterRangeService;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class ClassProgressMetaService
|
||||
{
|
||||
@@ -146,7 +147,17 @@ class ClassProgressMetaService
|
||||
|
||||
$options = [];
|
||||
foreach ($this->subjectSections() as $slug => $section) {
|
||||
$options[$slug] = SubjectCurriculum::getOptionsForClass((int) $classId, (string) $slug, $schoolYear);
|
||||
$subjects = $this->subjectLookupValues((string) $slug, is_array($section) ? $section : []);
|
||||
|
||||
$options[$slug] = SubjectCurriculum::query()
|
||||
->forClass((int) $classId)
|
||||
->where(function (Builder $query) use ($subjects) {
|
||||
$query->whereIn('subject', $subjects);
|
||||
})
|
||||
->forSchoolYear($schoolYear)
|
||||
->ordered()
|
||||
->get()
|
||||
->all();
|
||||
}
|
||||
|
||||
return $options;
|
||||
@@ -198,4 +209,26 @@ class ClassProgressMetaService
|
||||
|
||||
return $unitTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Curriculum rows have existed with both short slugs (`quran`) and display
|
||||
* subjects (`Quran/Arabic`). Query all configured aliases but keep the API
|
||||
* response keyed by slug for the frontend.
|
||||
*
|
||||
* @param array<string, mixed> $section
|
||||
* @return list<string>
|
||||
*/
|
||||
private function subjectLookupValues(string $slug, array $section): array
|
||||
{
|
||||
$values = [$slug];
|
||||
|
||||
foreach (['db_subject', 'label'] as $key) {
|
||||
$value = trim((string) ($section[$key] ?? ''));
|
||||
if ($value !== '') {
|
||||
$values[] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return array_values(array_unique($values));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user