Add categories and XModuleDescriptors for all module types that are used at the top level of a course
This commit is contained in:
committed by
Matthew Mongeau
parent
8baf8c81b2
commit
896c7daf36
@@ -97,9 +97,22 @@ class Module(XModule):
|
||||
self.rendered = False
|
||||
|
||||
|
||||
class CourseModuleDescriptor(XModuleDescriptor):
|
||||
pass
|
||||
class WeekDescriptor(XModuleDescriptor):
|
||||
|
||||
def get_goals(self):
|
||||
"""
|
||||
Return a list of Goal XModuleDescriptors that are children
|
||||
of this Week
|
||||
"""
|
||||
return [child for child in self.get_children() if child.type == 'Goal']
|
||||
|
||||
def get_non_goals(self):
|
||||
"""
|
||||
Return a list of non-Goal XModuleDescriptors that are children of
|
||||
this Week
|
||||
"""
|
||||
return [child for child in self.get_children() if child.type != 'Goal']
|
||||
|
||||
|
||||
class ChapterModuleDescriptor(XModuleDescriptor):
|
||||
class SectionDescriptor(XModuleDescriptor):
|
||||
pass
|
||||
|
||||
@@ -7,8 +7,15 @@ setup(
|
||||
install_requires=['distribute'],
|
||||
entry_points={
|
||||
'xmodule.v1': [
|
||||
"Course = seq_module:CourseModuleDescriptor",
|
||||
"Chapter = seq_module:ChapterModuleDescriptor",
|
||||
"Course = seq_module:SectionDescriptor",
|
||||
"Week = seq_module:WeekDescriptor",
|
||||
"Section = seq_module:SectionDescriptor",
|
||||
"LectureSequence = seq_module:SectionDescriptor",
|
||||
"Lab = seq_module:SectionDescriptor",
|
||||
"Homework = seq_module:SectionDescriptor",
|
||||
"TutorialIndex = seq_module:SectionDescriptor",
|
||||
"Exam = seq_module:SectionDescriptor",
|
||||
"VideoSegment = video_module:VideoSegmentDescriptor",
|
||||
]
|
||||
}
|
||||
)
|
||||
|
||||
@@ -57,3 +57,7 @@ class Module(XModule):
|
||||
|
||||
self.annotations=[(e.get("name"),self.render_function(e)) \
|
||||
for e in xmltree]
|
||||
|
||||
|
||||
class VideoSegmentDescriptor(XModuleDescriptor):
|
||||
pass
|
||||
|
||||
@@ -152,13 +152,18 @@ class XModuleDescriptor(Plugin):
|
||||
self.data = data if data is not None else {}
|
||||
self.children = children if children is not None else []
|
||||
self.name = Location(kwargs.get('location')).name
|
||||
self.type = Location(kwargs.get('location')).category
|
||||
self._child_instances = None
|
||||
|
||||
def get_children(self):
|
||||
def get_children(self, categories=None):
|
||||
"""Returns a list of XModuleDescriptor instances for the children of this module"""
|
||||
if self._child_instances is None:
|
||||
self._child_instances = [self.load_item(child) for child in self.children]
|
||||
return self._child_instances
|
||||
|
||||
if categories is None:
|
||||
return self._child_instances
|
||||
else:
|
||||
return [child for child in self._child_instances if child.type in categories]
|
||||
|
||||
|
||||
def get_xml(self):
|
||||
|
||||
Reference in New Issue
Block a user