mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-14 12:30:49 +08:00
new exam progress update logic
This commit is contained in:
@@ -25,7 +25,7 @@ class ExamResource extends JsonResource
|
||||
'end' => $this->end,
|
||||
'duration' => $this->duration ?: '',
|
||||
'duration_text' => $this->duration_text,
|
||||
'filters' => $this->filters,
|
||||
'filters' => $this->normalizeFilters($this->resource),
|
||||
'filters_formatted' => $this->formatFilters($this->resource),
|
||||
'indexes' => $this->indexes,
|
||||
'indexes_formatted' => $this->formatIndexes($this->resource),
|
||||
@@ -36,6 +36,17 @@ class ExamResource extends JsonResource
|
||||
];
|
||||
}
|
||||
|
||||
private function normalizeFilters(Exam $exam)
|
||||
{
|
||||
$filters = $exam->filters;
|
||||
foreach (Exam::$filters as $key => $value) {
|
||||
if (!isset($filters->$key)) {
|
||||
$filters->$key = [];
|
||||
}
|
||||
}
|
||||
return $filters;
|
||||
}
|
||||
|
||||
private function formatFilters(Exam $exam)
|
||||
{
|
||||
$currentFilters = $exam->filters;
|
||||
|
||||
Reference in New Issue
Block a user