diff --git a/common/lib/xmodule/xmodule/combined_open_ended_module.py b/common/lib/xmodule/xmodule/combined_open_ended_module.py index 957b978407..4788c43382 100644 --- a/common/lib/xmodule/xmodule/combined_open_ended_module.py +++ b/common/lib/xmodule/xmodule/combined_open_ended_module.py @@ -98,6 +98,8 @@ class CombinedOpenEndedModule(XModule): self.static_data = { 'max_score' : self._max_score, 'max_attempts' : self.max_attempts, + 'prompt' : definition['prompt'], + 'rubric' : definition['rubric'] } self.task_xml=definition['task_xml'] @@ -371,16 +373,20 @@ class CombinedOpenEndedDescriptor(XmlDescriptor, EditingDescriptor): 'hintprompt': 'some-html' } """ - expected_children = ['task'] + expected_children = ['task', 'rubric', 'prompt'] for child in expected_children: if len(xml_object.xpath(child)) == 0 : raise ValueError("Combined Open Ended definition must include at least one '{0}' tag".format(child)) - def parse(k): + def parse_task(k): """Assumes that xml_object has child k""" return [stringify_children(xml_object.xpath(k)[i]) for i in xrange(0,len(xml_object.xpath(k)))] - return {'task_xml': parse('task')} + def parse(k): + """Assumes that xml_object has child k""" + return xml_object.xpath(k)[0] + + return {'task_xml': parse_task('task'), 'prompt' : parse('prompt'), 'rubric' : parse('rubric')} def definition_to_xml(self, resource_fs): diff --git a/common/lib/xmodule/xmodule/open_ended_module.py b/common/lib/xmodule/xmodule/open_ended_module.py index 9cdbdd54e2..b795db8228 100644 --- a/common/lib/xmodule/xmodule/open_ended_module.py +++ b/common/lib/xmodule/xmodule/open_ended_module.py @@ -40,8 +40,6 @@ class OpenEndedModule(openendedchild.OpenEndedChild): def setup_response(self, system, location, definition, descriptor): oeparam = definition['oeparam'] - prompt = definition['prompt'] - rubric = definition['rubric'] self.url = definition.get('url', None) self.queue_name = definition.get('queuename', self.DEFAULT_QUEUE) @@ -53,12 +51,12 @@ class OpenEndedModule(openendedchild.OpenEndedChild): if oeparam is None: raise ValueError("No oeparam found in problem xml.") - if prompt is None: + if self.prompt is None: raise ValueError("No prompt found in problem xml.") - if rubric is None: + if self.rubric is None: raise ValueError("No rubric found in problem xml.") - self._parse(oeparam, prompt, rubric, system) + self._parse(oeparam, self.prompt, self.rubric, system) if self.created=="True" and self.state == self.ASSESSING: self.created="False" @@ -530,7 +528,7 @@ class OpenEndedDescriptor(XmlDescriptor, EditingDescriptor): } """ - for child in ['openendedrubric', 'prompt', 'openendedparam']: + for child in ['openendedparam']: if len(xml_object.xpath(child)) != 1: raise ValueError("Open Ended definition must include exactly one '{0}' tag".format(child)) @@ -538,10 +536,7 @@ class OpenEndedDescriptor(XmlDescriptor, EditingDescriptor): """Assumes that xml_object has child k""" return xml_object.xpath(k)[0] - return {'rubric': parse('openendedrubric'), - 'prompt': parse('prompt'), - 'oeparam': parse('openendedparam'), - } + return {'oeparam': parse('openendedparam'),} def definition_to_xml(self, resource_fs): @@ -553,7 +548,7 @@ class OpenEndedDescriptor(XmlDescriptor, EditingDescriptor): child_node = etree.fromstring(child_str) elt.append(child_node) - for child in ['openendedrubric', 'prompt', 'openendedparam']: + for child in ['openendedparam']: add_child(child) return elt diff --git a/common/lib/xmodule/xmodule/openendedchild.py b/common/lib/xmodule/xmodule/openendedchild.py index 5d69323e4a..4a81703919 100644 --- a/common/lib/xmodule/xmodule/openendedchild.py +++ b/common/lib/xmodule/xmodule/openendedchild.py @@ -127,6 +127,9 @@ class OpenEndedChild(): self.attempts = instance_state.get('attempts', 0) self.max_attempts = static_data['max_attempts'] + self.prompt = static_data['prompt'] + self.rubric = static_data['rubric'] + # Used for progress / grading. Currently get credit just for # completion (doesn't matter if you self-assessed correct/incorrect). self._max_score = static_data['max_score'] diff --git a/common/lib/xmodule/xmodule/self_assessment_module.py b/common/lib/xmodule/xmodule/self_assessment_module.py index 88c47f92ef..7050ff991b 100644 --- a/common/lib/xmodule/xmodule/self_assessment_module.py +++ b/common/lib/xmodule/xmodule/self_assessment_module.py @@ -33,8 +33,6 @@ log = logging.getLogger("mitx.courseware") class SelfAssessmentModule(openendedchild.OpenEndedChild): def setup_response(self, system, location, definition, descriptor): - self.rubric = definition['rubric'] - self.prompt = definition['prompt'] self.submit_message = definition['submitmessage'] self.hint_prompt = definition['hintprompt']