Commit ef9cf87b by Tim Babych Committed by cahrens

Compute graders just once per Course.

parent bba03a51
...@@ -589,7 +589,7 @@ def _get_module_info(xblock, rewrite_static_links=True): ...@@ -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, 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. Creates the information needed for client-side XBlockInfo.
...@@ -626,13 +626,17 @@ def create_xblock_info(xblock, data=None, metadata=None, include_ancestor_info=F ...@@ -626,13 +626,17 @@ def create_xblock_info(xblock, data=None, metadata=None, include_ancestor_info=F
is_xblock_unit = is_unit(xblock, parent_xblock) is_xblock_unit = is_unit(xblock, parent_xblock)
is_unit_with_changes = is_xblock_unit and modulestore().has_changes(xblock.location) 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 # 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) 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: if should_visit_children and xblock.has_children:
child_info = _create_xblock_child_info( child_info = _create_xblock_child_info(
xblock, xblock,
course_outline, course_outline,
include_children_predicate=include_children_predicate graders,
include_children_predicate=include_children_predicate,
) )
else: else:
child_info = None child_info = None
...@@ -641,7 +645,6 @@ def create_xblock_info(xblock, data=None, metadata=None, include_ancestor_info=F ...@@ -641,7 +645,6 @@ def create_xblock_info(xblock, data=None, metadata=None, include_ancestor_info=F
release_date = get_default_time_display(xblock.start) if xblock.start != DEFAULT_START_DATE else None 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) published = modulestore().has_item(xblock.location, revision=ModuleStoreEnum.RevisionOption.published_only)
graders = CourseGradingModel.fetch(xblock.location.course_key).graders
xblock_info = { xblock_info = {
"id": unicode(xblock.location), "id": unicode(xblock.location),
"display_name": xblock.display_name_with_default, "display_name": xblock.display_name_with_default,
...@@ -777,7 +780,7 @@ def _create_xblock_ancestor_info(xblock, course_outline): ...@@ -777,7 +780,7 @@ def _create_xblock_ancestor_info(xblock, course_outline):
} }
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 Returns information about the children of an xblock, as well as about the primary category
of xblock expected as children. of xblock expected as children.
...@@ -794,7 +797,8 @@ def _create_xblock_child_info(xblock, course_outline, include_children_predicate ...@@ -794,7 +797,8 @@ def _create_xblock_child_info(xblock, course_outline, include_children_predicate
create_xblock_info( create_xblock_info(
child, include_child_info=True, course_outline=course_outline, child, include_child_info=True, course_outline=course_outline,
include_children_predicate=include_children_predicate, include_children_predicate=include_children_predicate,
parent_xblock=xblock parent_xblock=xblock,
graders=graders
) for child in xblock.get_children() ) for child in xblock.get_children()
] ]
return child_info return child_info
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment