diff --git a/common/lib/xmodule/xmodule/course_module.py b/common/lib/xmodule/xmodule/course_module.py index 286f7bd1dc..085aca92dc 100644 --- a/common/lib/xmodule/xmodule/course_module.py +++ b/common/lib/xmodule/xmodule/course_module.py @@ -1211,23 +1211,23 @@ class CourseDescriptor(CourseFields, SequenceDescriptor): for module_descriptor in yield_descriptor_descendents(child): yield module_descriptor - for c in self.get_children(): - for s in c.get_children(): - if s.graded: - xmoduledescriptors = list(yield_descriptor_descendents(s)) - xmoduledescriptors.append(s) + for chapter in self.get_children(): + for section in chapter.get_children(): + if section.graded: + xmoduledescriptors = list(yield_descriptor_descendents(section)) + xmoduledescriptors.append(section) # The xmoduledescriptors included here are only the ones that have scores. section_description = { - 'section_descriptor': s, - 'xmoduledescriptors': filter(lambda child: child.has_score, xmoduledescriptors) + 'section_descriptor': section, + 'xmoduledescriptors': [child for child in xmoduledescriptors if child.has_score] } - section_format = s.format if s.format is not None else '' + section_format = section.format if section.format is not None else '' graded_sections[section_format] = graded_sections.get(section_format, []) + [section_description] all_descriptors.extend(xmoduledescriptors) - all_descriptors.append(s) + all_descriptors.append(section) return {'graded_sections': graded_sections, 'all_descriptors': all_descriptors, }