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:
Chris Chávez
2022-08-02 11:40:23 -05:00
committed by GitHub
parent 38e63681bb
commit ebd96cba8a
2 changed files with 5 additions and 1 deletions

View File

@@ -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

View File

@@ -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):
"""