diff --git a/xmodule/conditional_block.py b/xmodule/conditional_block.py index 78a5b8c1c1c9..64825273d9c5 100644 --- a/xmodule/conditional_block.py +++ b/xmodule/conditional_block.py @@ -222,9 +222,9 @@ def student_view(self, _context): return fragment def get_html(self): - required_html_ids = [block.location.html_id() for block in self.get_required_blocks] + required_html_ids = [block.usage_key.html_id() for block in self.get_required_blocks] return self.runtime.service(self, 'mako').render_lms_template('conditional_ajax.html', { - 'element_id': self.location.html_id(), + 'element_id': self.usage_key.html_id(), 'ajax_url': self.ajax_url, 'depends': ';'.join(required_html_ids) }) diff --git a/xmodule/tests/test_conditional.py b/xmodule/tests/test_conditional.py index 8eb9e9ac071d..385ec90fc113 100644 --- a/xmodule/tests/test_conditional.py +++ b/xmodule/tests/test_conditional.py @@ -84,6 +84,7 @@ def create(system, source_is_error_block=False, source_visible_to_staff_only=Fal else: source_block = Mock(name='source_block') source_block.location = source_location + source_block.usage_key = source_location source_block.visible_to_staff_only = source_visible_to_staff_only source_block.runtime = system @@ -97,6 +98,7 @@ def create(system, source_is_error_block=False, source_visible_to_staff_only=Fal child_block.runtime = system child_block.render = lambda view, context=None: system.render(child_block, view, context) child_block.location = source_location.replace(category='html', name='child') + child_block.usage_key = child_block.location def visible_to_nonstaff_users(desc): """ @@ -121,7 +123,7 @@ def load_item(usage_id, for_parent=None): # pylint: disable=unused-argument 'conditional_attr': 'attempted', 'conditional_value': 'true', 'xml_attributes': {'attempted': 'true'}, - 'children': [child_block.location], + 'children': [child_block.usage_key], }) cond_block = ConditionalBlock(