I’m trying to get a problem block from
/api/courses/v1/blocks/<block_id/
but for every block other than root I get the following error:
Traceback (most recent call last):
File “/openedx/edx-platform/./openedx/core/djangoapps/content/block_structure/block_structure.py”, line 302, in getattr
return self.fields[field_name]
KeyError: ‘end’
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “/openedx/venv/lib/python3.8/site-packages/django/core/handlers/exception.py”, line 47, in inner
response = get_response(request)
File “/openedx/venv/lib/python3.8/site-packages/django/core/handlers/base.py”, line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File “/openedx/venv/lib/python3.8/site-packages/django/views/decorators/csrf.py”, line 54, in wrapped_view
return view_func(*args, **kwargs)
File “/openedx/venv/lib/python3.8/site-packages/django/views/generic/base.py”, line 70, in view
return self.dispatch(request, *args, **kwargs)
File “/openedx/venv/lib/python3.8/site-packages/django/utils/decorators.py”, line 43, in _wrapper
return bound_method(*args, **kwargs)
File “/openedx/venv/lib/python3.8/site-packages/rest_framework/views.py”, line 509, in dispatch
response = self.handle_exception(exc)
File “/openedx/venv/lib/python3.8/site-packages/rest_framework/views.py”, line 506, in dispatch
response = handler(request, *args, **kwargs)
File “/openedx/venv/lib/python3.8/site-packages/rest_framework/generics.py”, line 199, in get
return self.list(request, *args, **kwargs)
File “/openedx/edx-platform/./lms/djangoapps/course_api/blocks/views.py”, line 225, in list
get_blocks(
File “/openedx/edx-platform/./lms/djangoapps/course_api/blocks/api.py”, line 112, in get_blocks
blocks = course_blocks_api.get_course_blocks(
File “/openedx/edx-platform/./lms/djangoapps/course_blocks/api.py”, line 107, in get_course_blocks
return get_block_structure_manager(starting_block_usage_key.course_key).get_transformed(
File “/openedx/edx-platform/./openedx/core/djangoapps/content/block_structure/manager.py”, line 78, in get_transformed
transformers.transform(block_structure)
File “/openedx/edx-platform/./openedx/core/djangoapps/content/block_structure/transformers.py”, line 114, in transform
self._transform_without_filters(block_structure)
File “/openedx/edx-platform/./openedx/core/djangoapps/content/block_structure/transformers.py”, line 140, in _transform_without_filters
transformer.transform(self.usage_info, block_structure)
File “/openedx/edx-platform/./lms/djangoapps/course_blocks/transformers/hidden_content.py”, line 77, in transform
block_structure.remove_block_traversal(lambda block_key: self._is_block_hidden(block_structure, block_key))
File “/openedx/edx-platform/./openedx/core/djangoapps/content/block_structure/block_structure.py”, line 702, in remove_block_traversal
self.filter_topological_traversal(
File “/openedx/edx-platform/./openedx/core/djangoapps/content/block_structure/block_structure.py”, line 727, in filter_topological_traversal
for _ in self.topological_traversal(filter_func=filter_func, **kwargs):
File “/openedx/edx-platform/./openedx/core/lib/graph_traversals.py”, line 329, in _traverse_generic
should_yield_node = filter_func(current_node)
File “/openedx/edx-platform/./openedx/core/djangoapps/content/block_structure/block_structure.py”, line 683, in retain_or_remove
if removal_condition(block_key):
File “/openedx/edx-platform/./lms/djangoapps/course_blocks/transformers/hidden_content.py”, line 77, in
block_structure.remove_block_traversal(lambda block_key: self._is_block_hidden(block_structure, block_key))
File “/openedx/edx-platform/./lms/djangoapps/course_blocks/transformers/hidden_content.py”, line 87, in _is_block_hidden
hidden_date = block_structure[block_structure.root_block_usage_key].end
File “/openedx/edx-platform/./openedx/core/djangoapps/content/block_structure/block_structure.py”, line 304, in getattr
raise AttributeError(f"Field {field_name} does not exist") # lint-amnesty, pylint: disable=raise-missing-from
AttributeError: Field end does not exist
I have set course end date and problems dues date, but even then the ‘end’ attribute for block structure is not set. Any idea why this could be happening? Thanks.