fix: Bug showing hidden sections for learners of a public course fixed (#27925)
The bug is explained in https://openedx.atlassian.net/browse/CRI-233. Only is missing add the `VisibilityTransformer` in `get_blocks()` when the user is not enrolled to the course. On the test, `html_block` is visible only for staff and `vertical_block` is a normal block. The new behaviour hides the `html_block` and show the `vertical_block` to anonymous users
This commit is contained in:
@@ -90,6 +90,8 @@ def get_blocks(
|
||||
),
|
||||
HiddenContentTransformer()
|
||||
]
|
||||
else:
|
||||
transformers += [course_blocks_api.visibility.VisibilityTransformer()]
|
||||
|
||||
# Note: A change to the BlockCompletionTransformer (https://github.com/edx/edx-platform/pull/27622/)
|
||||
# will be introducing a bug if hide_access_denials is True. I'm accepting this risk because in
|
||||
|
||||
@@ -53,7 +53,9 @@ class TestGetBlocks(SharedModuleStoreTestCase):
|
||||
|
||||
def test_no_user(self):
|
||||
blocks = get_blocks(self.request, self.course.location)
|
||||
assert str(self.html_block.location) in blocks['blocks']
|
||||
assert str(self.html_block.location) not in blocks['blocks']
|
||||
vertical_block = self.store.get_item(self.course.id.make_usage_key('vertical', 'vertical_x1a'))
|
||||
assert str(vertical_block.location) in blocks['blocks']
|
||||
|
||||
def test_access_before_api_transformer_order(self):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user