Commit 07892189 by Dennis Jen

Video structure returns modules of any graded status.

parent 0cdcf18c
...@@ -90,6 +90,11 @@ class CourseAPIPresenterMixin(object): ...@@ -90,6 +90,11 @@ class CourseAPIPresenterMixin(object):
""" Module type to retrieve structure for. E.g. video, problem. """ """ Module type to retrieve structure for. E.g. video, problem. """
pass pass
@property
def module_graded_type(self):
""" Graded module type to review structure for. E.g. True, False, None. """
return None
def get_cache_key(self, name): def get_cache_key(self, name):
""" Returns sanitized key for caching. """ """ Returns sanitized key for caching. """
return sanitize_cache_key(u'{}_{}'.format(self.course_id, name)) return sanitize_cache_key(u'{}_{}'.format(self.course_id, name))
...@@ -114,7 +119,7 @@ class CourseAPIPresenterMixin(object): ...@@ -114,7 +119,7 @@ class CourseAPIPresenterMixin(object):
if not found_structure: if not found_structure:
structure = self._get_structure() structure = self._get_structure()
found_structure = CourseStructure.course_structure_to_sections(structure, self.module_type, found_structure = CourseStructure.course_structure_to_sections(structure, self.module_type,
graded=False) graded=self.module_graded_type)
cache.set(all_sections_key, found_structure) cache.set(all_sections_key, found_structure)
for section in found_structure: for section in found_structure:
......
...@@ -368,3 +368,14 @@ class CoursePerformancePresenter(CourseAPIPresenterMixin, BasePresenter): ...@@ -368,3 +368,14 @@ class CoursePerformancePresenter(CourseAPIPresenterMixin, BasePresenter):
@property @property
def module_type(self): def module_type(self):
return 'problem' return 'problem'
@property
def module_graded_type(self):
"""
Get ungraded blocks.
This is a bit confusing as this presenter is used to show both graded and
ungraded content. The ungraded content uses CourseAPIPresenterMixin::course_structure
which then gets the module grade type for filtering.
"""
return False
...@@ -17,8 +17,6 @@ class CourseStructure(object): ...@@ -17,8 +17,6 @@ class CourseStructure(object):
if block_type: if block_type:
kwargs[u'type'] = block_type kwargs[u'type'] = block_type
kwargs.setdefault(u'graded', False)
matched = True matched = True
for name, value in kwargs.iteritems(): for name, value in kwargs.iteritems():
matched &= (block.get(name, None) == value) matched &= (block.get(name, None) == value)
...@@ -99,10 +97,14 @@ class CourseStructure(object): ...@@ -99,10 +97,14 @@ class CourseStructure(object):
if len(block_types) > 0: if len(block_types) > 0:
block_types = list(block_types) block_types = list(block_types)
block_type = block_types.pop(0) block_type = block_types.pop(0)
filter_kwargs = {
'block_type': block_type,
}
if graded is not None:
filter_kwargs['graded'] = graded
structure_sections = CourseStructure._filter_children(blocks, section_id, structure_sections = CourseStructure._filter_children(blocks, section_id,
graded=graded, require_format=False,
block_type=block_type, **filter_kwargs)
require_format=False)
for section in structure_sections: for section in structure_sections:
children = CourseStructure._build_sections(blocks, section[u'id'], graded, block_types) children = CourseStructure._build_sections(blocks, section[u'id'], graded, block_types)
......
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