Skip to content

Commit

Permalink
fix: resolve discussions
Browse files Browse the repository at this point in the history
  • Loading branch information
ruzniaievdm committed Feb 15, 2024
1 parent e343bbd commit 24695b5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
get_container_handler_context,
get_user_partition_info,
get_visibility_partition_info,
get_validation_messages,
get_render_error,
get_xblock_validation_messages,
get_xblock_render_error,
)
from cms.djangoapps.contentstore.views.component import _get_item_in_course
from cms.djangoapps.contentstore.xblock_storage_handlers.view_handlers import get_xblock
Expand Down Expand Up @@ -240,8 +240,8 @@ def get(self, request: Request, usage_key_string: str):
child_info = modulestore().get_item(child)
user_partition_info = get_visibility_partition_info(child_info, course=course)
user_partitions = get_user_partition_info(child_info, course=course)
validation_messages = get_validation_messages(child_info)
render_error = get_render_error(request, child_info)
validation_messages = get_xblock_validation_messages(child_info)
render_error = get_xblock_render_error(request, child_info)

children.append({
"name": child_info.display_name_with_default,
Expand Down
13 changes: 6 additions & 7 deletions cms/djangoapps/contentstore/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2141,7 +2141,7 @@ def track_course_update_event(course_key, user, event_data=None):
tracker.emit(event_name, event_data)


def get_validation_messages(xblock):
def get_xblock_validation_messages(xblock):
"""
Retrieves validation messages for a given xblock.
Expand All @@ -2155,7 +2155,7 @@ def get_validation_messages(xblock):
return validation_json['messages']


def get_render_error(request, xblock):
def get_xblock_render_error(request, xblock):
"""
Checks if there are any rendering errors for a given block and return these.
Expand All @@ -2170,7 +2170,7 @@ def get_render_error(request, xblock):
from xmodule.studio_editable import has_author_view
from xmodule.x_module import AUTHOR_VIEW, STUDENT_VIEW

def get_render_context(request, block):
def get_xblock_render_context(request, block):
"""
Return a dict of the data needs for render of each block.
"""
Expand All @@ -2187,13 +2187,12 @@ def get_render_context(request, block):
"tags_count_map": {},
}

render_error = ""
try:
block = _load_preview_block(request, xblock)
preview_view = AUTHOR_VIEW if has_author_view(block) else STUDENT_VIEW
render_context = get_render_context(request, block)
render_context = get_xblock_render_context(request, block)
block.render(preview_view, render_context)
except Exception as exc: # pylint: disable=broad-except
render_error = str(exc)
return str(exc)

return render_error
return ""

0 comments on commit 24695b5

Please sign in to comment.