diff --git a/cms/djangoapps/contentstore/views/item.py b/cms/djangoapps/contentstore/views/item.py index 16eb7ede7dbb..c3f60084bd98 100644 --- a/cms/djangoapps/contentstore/views/item.py +++ b/cms/djangoapps/contentstore/views/item.py @@ -589,7 +589,7 @@ def _get_module_info(xblock, rewrite_static_links=True): def create_xblock_info(xblock, data=None, metadata=None, include_ancestor_info=False, include_child_info=False, - course_outline=False, include_children_predicate=NEVER, parent_xblock=None): + course_outline=False, include_children_predicate=NEVER, parent_xblock=None, graders=None): """ Creates the information needed for client-side XBlockInfo. @@ -629,13 +629,17 @@ def safe_get_username(user_id): is_xblock_unit = is_unit(xblock) is_unit_with_changes = is_xblock_unit and modulestore().has_changes(xblock.location) + if graders is None: + graders = CourseGradingModel.fetch(xblock.location.course_key).graders + # Compute the child info first so it can be included in aggregate information for the parent should_visit_children = include_child_info and (course_outline and not is_xblock_unit or not course_outline) if should_visit_children and xblock.has_children: child_info = _create_xblock_child_info( xblock, course_outline, - include_children_predicate=include_children_predicate + graders, + include_children_predicate=include_children_predicate, ) else: child_info = None @@ -644,7 +648,6 @@ def safe_get_username(user_id): release_date = get_default_time_display(xblock.start) if xblock.start != DEFAULT_START_DATE else None published = modulestore().has_item(xblock.location, revision=ModuleStoreEnum.RevisionOption.published_only) - graders = CourseGradingModel.fetch(xblock.location.course_key).graders xblock_info = { "id": unicode(xblock.location), "display_name": xblock.display_name_with_default, @@ -780,7 +783,7 @@ def collect_ancestor_info(ancestor, include_child_info=False): } -def _create_xblock_child_info(xblock, course_outline, include_children_predicate=NEVER): +def _create_xblock_child_info(xblock, course_outline, graders, include_children_predicate=NEVER): """ Returns information about the children of an xblock, as well as about the primary category of xblock expected as children. @@ -797,7 +800,8 @@ def _create_xblock_child_info(xblock, course_outline, include_children_predicate create_xblock_info( child, include_child_info=True, course_outline=course_outline, include_children_predicate=include_children_predicate, - parent_xblock=xblock + parent_xblock=xblock, + graders=graders ) for child in xblock.get_children() ] return child_info