fix: the get_completion JS handler should not ignore FBE blocks
Because xblock handlers normally get a block tree that already has inaccessible blocks stripped, they don't see FBE gated blocks at all. So the get_completion handler would return True for FBE units incorrectly. Leading to a visual bug as an audit user went through their units in the courseware. In order to let the handler know about the full tree, I've added a new attribute you can set on your xblock handlers: my_handler.will_recheck_access = True This will tell the top-level handler code get the full tree for you. As part of this, I've also changed the sequence xblock handler's into proper xblock handlers (not old-style xmodule handlers). This changes their URLs slightly. I've kept the old URLs for now as well, but they'll be removed after Maple. AA-409
This commit is contained in:
@@ -897,6 +897,31 @@ class TestHandleXBlockCallback(SharedModuleStoreTestCase, LoginEnrollmentTestCas
|
||||
)
|
||||
assert not mock_score_signal.called
|
||||
|
||||
@ddt.data(
|
||||
# See seq_module.py for the definition of these handlers
|
||||
('get_completion', True), # has the 'will_recheck_access' attribute set to True
|
||||
('goto_position', False), # does not set it
|
||||
)
|
||||
@ddt.unpack
|
||||
@patch('lms.djangoapps.courseware.module_render.get_module_for_descriptor', wraps=get_module_for_descriptor)
|
||||
def test_will_recheck_access_handler_attribute(self, handler, will_recheck_access, mock_get_module):
|
||||
"""Confirm that we pay attention to any 'will_recheck_access' attributes on handler methods"""
|
||||
course = CourseFactory.create()
|
||||
descriptor_kwargs = {
|
||||
'category': 'sequential',
|
||||
'parent': course,
|
||||
}
|
||||
descriptor = ItemFactory.create(**descriptor_kwargs)
|
||||
usage_id = str(descriptor.location)
|
||||
|
||||
# Send no special parameters, which will be invalid, but we don't care
|
||||
request = self.request_factory.post('/', data='{}', content_type='application/json')
|
||||
request.user = self.mock_user
|
||||
|
||||
render.handle_xblock_callback(request, str(course.id), usage_id, handler)
|
||||
assert mock_get_module.call_count == 1
|
||||
assert mock_get_module.call_args[1]['will_recheck_access'] == will_recheck_access
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
@patch.dict('django.conf.settings.FEATURES', {'ENABLE_XBLOCK_VIEW_ENDPOINT': True})
|
||||
|
||||
Reference in New Issue
Block a user