Commit 4b54e849 by Victor Shnayder

Merge pull request #1448 from MITx/feature/ichuang/conditional-xmodule-icon-and-errortracker

Conditional XModule: add errortracker msg for bad require & inherit icon from child
parents 66889b87 b5ba88f0
...@@ -45,6 +45,10 @@ class ConditionalModule(XModule): ...@@ -45,6 +45,10 @@ class ConditionalModule(XModule):
XModule.__init__(self, system, location, definition, descriptor, instance_state, shared_state, **kwargs) XModule.__init__(self, system, location, definition, descriptor, instance_state, shared_state, **kwargs)
self.contents = None self.contents = None
self.condition = self.metadata.get('condition', '') self.condition = self.metadata.get('condition', '')
self._get_required_modules()
children = self.get_display_items()
if children:
self.icon_class = children[0].get_icon_class()
#log.debug('conditional module required=%s' % self.required_modules_list) #log.debug('conditional module required=%s' % self.required_modules_list)
def _get_required_modules(self): def _get_required_modules(self):
...@@ -129,7 +133,14 @@ class ConditionalDescriptor(SequenceDescriptor): ...@@ -129,7 +133,14 @@ class ConditionalDescriptor(SequenceDescriptor):
required_module_list = [tuple(x.split('/', 1)) for x in self.metadata.get('required', '').split('&')] required_module_list = [tuple(x.split('/', 1)) for x in self.metadata.get('required', '').split('&')]
self.required_module_locations = [] self.required_module_locations = []
for (tag, name) in required_module_list: for rm in required_module_list:
try:
(tag, name) = rm
except Exception as err:
msg = "Specification of required module in conditional is broken: %s" % self.metadata.get('required')
log.warning(msg)
self.system.error_tracker(msg)
continue
loc = self.location.dict() loc = self.location.dict()
loc['category'] = tag loc['category'] = tag
loc['name'] = name loc['name'] = name
......
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