diff options
| author | Rami Jasim <minecraftmrgold@gmail.com> | 2025-12-17 09:28:53 +0000 |
|---|---|---|
| committer | Rami Jasim <minecraftmrgold@gmail.com> | 2025-12-17 09:28:53 +0000 |
| commit | 166eb5d657e9bccfbcd0f891d78a000b7b0fcb3f (patch) | |
| tree | 2b6584a54f4add018cbe2c6b2288733c2354808c /lib | |
| parent | 9ab2f4aa874b1015ecc3ac5c24672956176fd789 (diff) | |
add filtering for module.stat to the json-api route ModulesIndex and include...
Closes #6119
Merge request studip/studip!4651
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/classes/JsonApi/Routes/Mvv/ModulesIndex.php | 11 | ||||
| -rw-r--r-- | lib/classes/JsonApi/Schemas/Module.php | 1 |
2 files changed, 11 insertions, 1 deletions
diff --git a/lib/classes/JsonApi/Routes/Mvv/ModulesIndex.php b/lib/classes/JsonApi/Routes/Mvv/ModulesIndex.php index 3018fd4..bdf78c8 100644 --- a/lib/classes/JsonApi/Routes/Mvv/ModulesIndex.php +++ b/lib/classes/JsonApi/Routes/Mvv/ModulesIndex.php @@ -11,7 +11,7 @@ use JsonApi\JsonApiController; class ModulesIndex extends JsonApiController { - protected $allowedFilteringParameters = ['q', 'institute', 'semester', 'section']; + protected $allowedFilteringParameters = ['q', 'institute', 'semester', 'section', 'stat']; protected $allowedPagingParameters = ['offset', 'limit']; @@ -70,6 +70,12 @@ class ModulesIndex extends JsonApiController if (isset($filtering['semester']) && !\Semester::exists($filtering['semester'])) { return 'Filter `semester` must be a valid id.'; } + + // stat + $allowed_module_stats = array_keys($GLOBALS['MVV_MODUL']['STATUS']['values']); + if (isset($filtering['stat']) && !in_array($filtering['stat'], $allowed_module_stats)) { + return 'Filter `stat` has no valid value. Must be one of these: ' . implode(', ', $allowed_module_stats); + } } private function getModules($filtering, $offset, $limit): array @@ -101,6 +107,9 @@ class ModulesIndex extends JsonApiController if (isset($filtering['q'])) { $where .= " AND (`mvv_modul_deskriptor`.`bezeichnung` LIKE CONCAT('%', :q, '%') OR `mvv_modul`.`code` LIKE CONCAT('%', :q, '%')) "; } + if (isset($filtering['stat'])) { + $where .= " AND `stat` = :stat "; + } $where .= ' ORDER BY `mvv_modul`.`code` ASC, `mvv_modul_deskriptor`.`bezeichnung` ASC LIMIT :limit OFFSET :offset'; return \Modul::findBySQL( diff --git a/lib/classes/JsonApi/Schemas/Module.php b/lib/classes/JsonApi/Schemas/Module.php index 55fe085..f480069 100644 --- a/lib/classes/JsonApi/Schemas/Module.php +++ b/lib/classes/JsonApi/Schemas/Module.php @@ -52,6 +52,7 @@ class Module extends SchemaProvider 'comment-capacity' => (string) $resource->deskriptoren->kommentar_kapazitaet, 'comment_sws' => (string) $resource->deskriptoren->kommentar_sws, 'type' => get_class($resource), + 'stat' => $resource->stat, 'status' => \Config::get()->MVV_MODUL['STATUS']['values'][$resource->stat], ]; } |
