Conflicts: cms/djangoapps/contentstore/course_info_model.py cms/djangoapps/contentstore/module_info_model.py cms/djangoapps/contentstore/tests/factories.py cms/djangoapps/contentstore/tests/test_course_settings.py cms/djangoapps/contentstore/views.py cms/djangoapps/models/settings/course_details.py cms/djangoapps/models/settings/course_grading.py cms/templates/edit_subsection.html common/djangoapps/mitxmako/shortcuts.py common/djangoapps/static_replace.py common/djangoapps/util/converters.py common/djangoapps/xmodule_modifiers.py common/lib/xmodule/setup.py common/lib/xmodule/xmodule/abtest_module.py common/lib/xmodule/xmodule/capa_module.py common/lib/xmodule/xmodule/course_module.py common/lib/xmodule/xmodule/discussion_module.py common/lib/xmodule/xmodule/error_module.py common/lib/xmodule/xmodule/html_module.py common/lib/xmodule/xmodule/js/src/video/display.coffee common/lib/xmodule/xmodule/mako_module.py common/lib/xmodule/xmodule/modulestore/mongo.py common/lib/xmodule/xmodule/modulestore/store_utilities.py common/lib/xmodule/xmodule/modulestore/xml.py common/lib/xmodule/xmodule/modulestore/xml_importer.py common/lib/xmodule/xmodule/raw_module.py common/lib/xmodule/xmodule/self_assessment_module.py common/lib/xmodule/xmodule/seq_module.py common/lib/xmodule/xmodule/template_module.py common/lib/xmodule/xmodule/tests/__init__.py common/lib/xmodule/xmodule/tests/test_export.py common/lib/xmodule/xmodule/tests/test_import.py common/lib/xmodule/xmodule/video_module.py common/lib/xmodule/xmodule/x_module.py common/lib/xmodule/xmodule/xml_module.py lms/djangoapps/courseware/access.py lms/djangoapps/courseware/courses.py lms/djangoapps/courseware/grades.py lms/djangoapps/courseware/models.py lms/djangoapps/courseware/module_render.py lms/djangoapps/courseware/tests/tests.py lms/djangoapps/courseware/views.py lms/djangoapps/django_comment_client/utils.py lms/templates/staff_problem_info.html lms/templates/video.html rakefile
57 lines
1.7 KiB
Python
57 lines
1.7 KiB
Python
from xmodule.x_module import XModule
|
|
from xmodule.seq_module import SequenceDescriptor
|
|
from xmodule.progress import Progress
|
|
from pkg_resources import resource_string
|
|
|
|
# HACK: This shouldn't be hard-coded to two types
|
|
# OBSOLETE: This obsoletes 'type'
|
|
class_priority = ['video', 'problem']
|
|
|
|
|
|
class VerticalModule(XModule):
|
|
''' Layout module for laying out submodules vertically.'''
|
|
|
|
has_children = True
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
XModule.__init__(self, *args, **kwargs)
|
|
self.contents = None
|
|
|
|
def get_html(self):
|
|
if self.contents is None:
|
|
self.contents = [{
|
|
'id': child.id,
|
|
'content': child.get_html()
|
|
} for child in self.get_display_items()]
|
|
|
|
return self.system.render_template('vert_module.html', {
|
|
'items': self.contents
|
|
})
|
|
|
|
def get_progress(self):
|
|
# TODO: Cache progress or children array?
|
|
children = self.get_children()
|
|
progresses = [child.get_progress() for child in children]
|
|
progress = reduce(Progress.add_counts, progresses, None)
|
|
return progress
|
|
|
|
def get_icon_class(self):
|
|
child_classes = set(child.get_icon_class() for child in self.get_children())
|
|
new_class = 'other'
|
|
for c in class_priority:
|
|
if c in child_classes:
|
|
new_class = c
|
|
return new_class
|
|
|
|
|
|
class VerticalDescriptor(SequenceDescriptor):
|
|
module_class = VerticalModule
|
|
|
|
has_children = True
|
|
|
|
js = {'coffee': [resource_string(__name__, 'js/src/vertical/edit.coffee')]}
|
|
js_module_name = "VerticalDescriptor"
|
|
|
|
# TODO (victor): Does this need its own definition_to_xml method? Otherwise it looks
|
|
# like verticals will get exported as sequentials...
|