Skip to content

Commit

Permalink
Do not show hidden course modules to students in exercises API
Browse files Browse the repository at this point in the history
After the pull request #1090 CachedContent includes hidden modules too.
Students must not see hidden modules in the course exercise list API,
so they are now filtered out.

Fixes #1224
  • Loading branch information
ihalaij1 authored and markkuriekkinen committed Aug 15, 2023
1 parent 969800d commit 4dd2e41
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion course/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,8 @@ def __module_to_dict(self, module, **kwargs):
def list(self, request, *args, **kwargs):
modules = []
for module in self.content.data['modules']:
modules.append(self.__module_to_dict(module, **kwargs))
if module['status'] != CourseModule.STATUS.HIDDEN:
modules.append(self.__module_to_dict(module, **kwargs))
return Response({"count": len(modules), "next": None, "previous": None, 'results': modules})

def retrieve(self, request, *args, **kwargs):
Expand Down

0 comments on commit 4dd2e41

Please sign in to comment.