Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions cms/djangoapps/contentstore/views/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why we need it here? it is never passed.

"""
Creates the information needed for client-side XBlockInfo.

Expand Down Expand Up @@ -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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better "if not graders"

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
Expand All @@ -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,
Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand Down