diff options
| author | Rasmus Fuhse <fuhse@data-quest.de> | 2023-09-01 14:33:05 +0200 |
|---|---|---|
| committer | Rasmus Fuhse <fuhse@data-quest.de> | 2023-09-01 14:33:05 +0200 |
| commit | 8c3a64f5f1c5096986ad7685c03ae4eea28eda7a (patch) | |
| tree | f47198d4dc228f37c4d675480f5fd0acc72b7748 /lib/classes/JsonApi/Routes/Courseware | |
| parent | 185ab4a1919f137e99c72addf98790e0e5f833d2 (diff) | |
re #3128issue-3128
Diffstat (limited to 'lib/classes/JsonApi/Routes/Courseware')
| -rw-r--r-- | lib/classes/JsonApi/Routes/Courseware/UserProgressesOfUnitsShow.php | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/classes/JsonApi/Routes/Courseware/UserProgressesOfUnitsShow.php b/lib/classes/JsonApi/Routes/Courseware/UserProgressesOfUnitsShow.php index 7b900e7..26bd261 100644 --- a/lib/classes/JsonApi/Routes/Courseware/UserProgressesOfUnitsShow.php +++ b/lib/classes/JsonApi/Routes/Courseware/UserProgressesOfUnitsShow.php @@ -36,6 +36,11 @@ class UserProgressesOfUnitsShow extends NonJsonApiController if (!$GLOBALS['perm']->have_studip_perm('autor', $root->range_id) || !$unit->canRead($user)) { throw new AuthorizationFailedException(); } + $response = $response->withHeader('Content-Type', 'application/json'); + if (!$root) { + $response->getBody()->write((string) json_encode([])); + return $response; + } $instance = new Instance($root); $isTeacher = $GLOBALS['perm']->have_studip_perm('tutor', $root->range_id); @@ -46,9 +51,7 @@ class UserProgressesOfUnitsShow extends NonJsonApiController $progresses = $this->prepareProgressData($elements, $progress); - $response = $response->withHeader('Content-Type', 'application/json'); $response->getBody()->write((string) json_encode($progresses)); - return $response; } |
