diff --git a/common/lib/xmodule/xmodule/combined_open_ended_module.py b/common/lib/xmodule/xmodule/combined_open_ended_module.py index 02d6cab373..c47919095f 100644 --- a/common/lib/xmodule/xmodule/combined_open_ended_module.py +++ b/common/lib/xmodule/xmodule/combined_open_ended_module.py @@ -90,6 +90,11 @@ class CombinedOpenEndedModule(XModule): # completion (doesn't matter if you self-assessed correct/incorrect). self._max_score = int(self.metadata.get('max_score', MAX_SCORE)) + self.static_data = { + 'max_score' : self._max_score, + 'max_attempts' : self.max_attempts, + } + self.task_xml=definition['task_xml'] self.setup_next_task() @@ -137,7 +142,7 @@ class CombinedOpenEndedModule(XModule): self.current_task_descriptor=children['descriptors'][current_task_type](self.system) self.current_task_parsed_xml=self.current_task_descriptor.definition_from_xml(etree.fromstring(self.current_task_xml),self.system) if current_task_state is None and self.current_task_number==0: - self.current_task=children['modules'][current_task_type](self.system, self.location, self.current_task_parsed_xml, self.current_task_descriptor) + self.current_task=children['modules'][current_task_type](self.system, self.location, self.current_task_parsed_xml, self.current_task_descriptor, self.static_data) self.task_states.append(self.current_task.get_instance_state()) self.state=self.ASSESSING elif current_task_state is None and self.current_task_number>0: @@ -145,13 +150,13 @@ class CombinedOpenEndedModule(XModule): last_response = last_response_data['response'] current_task_state = ('{"state": "assessing", "version": 1, "max_score": ' + str(self._max_score) + ', ' + '"attempts": 0, "created": "True", "history": [{"answer": "' + str(last_response) + '"}]}') - self.current_task=children['modules'][current_task_type](self.system, self.location, self.current_task_parsed_xml, self.current_task_descriptor, instance_state=current_task_state) + self.current_task=children['modules'][current_task_type](self.system, self.location, self.current_task_parsed_xml, self.current_task_descriptor, self.static_data, instance_state=current_task_state) self.task_states.append(self.current_task.get_instance_state()) self.state=self.ASSESSING else: if self.current_task_number>0 and not reset: current_task_state=self.overwrite_state(current_task_state) - self.current_task=children['modules'][current_task_type](self.system, self.location, self.current_task_parsed_xml, self.current_task_descriptor, instance_state=current_task_state) + self.current_task=children['modules'][current_task_type](self.system, self.location, self.current_task_parsed_xml, self.current_task_descriptor, self.static_data, instance_state=current_task_state) log.debug(self.current_task.get_instance_state()) log.debug(self.get_instance_state()) @@ -191,12 +196,15 @@ class CombinedOpenEndedModule(XModule): task_descriptor=children['descriptors'][task_type](self.system) task_parsed_xml=task_descriptor.definition_from_xml(etree.fromstring(task_xml),self.system) - task=children['modules'][task_type](self.system, self.location, task_parsed_xml, task_descriptor, instance_state=task_state) + task=children['modules'][task_type](self.system, self.location, task_parsed_xml, task_descriptor, self.static_data, instance_state=task_state) last_response=task.latest_answer() last_score = task.latest_score() last_post_assessment = task.latest_post_assessment() max_score = task.max_score() - last_response_dict={'response' : last_response, 'score' : last_score, 'post_assessment' : last_post_assessment, 'type' : task_type, 'max_score' : max_score} + state = task.state + last_response_dict={'response' : last_response, 'score' : last_score, + 'post_assessment' : last_post_assessment, + 'type' : task_type, 'max_score' : max_score, 'state' : state} return last_response_dict @@ -291,7 +299,7 @@ class CombinedOpenEndedModule(XModule): def get_status(self): status=[] - for i in xrange(0,self.current_task_number): + for i in xrange(0,self.current_task_number+1): task_data = self.get_last_response(i) task_data.update({'task_number' : i+1}) status.append(task_data) diff --git a/common/lib/xmodule/xmodule/open_ended_module.py b/common/lib/xmodule/xmodule/open_ended_module.py index de24d30502..c607e3eccf 100644 --- a/common/lib/xmodule/xmodule/open_ended_module.py +++ b/common/lib/xmodule/xmodule/open_ended_module.py @@ -34,15 +34,6 @@ from datetime import datetime log = logging.getLogger("mitx.courseware") -# Set the default number of max attempts. Should be 1 for production -# Set higher for debugging/testing -# attempts specified in xml definition overrides this. -MAX_ATTEMPTS = 1 - -# Set maximum available number of points. -# Overriden by max_score specified in xml. -MAX_SCORE = 1 - class OpenEndedModule(openendedchild.OpenEndedChild): def setup_response(self, system, location, definition, descriptor): @@ -113,11 +104,6 @@ class OpenEndedModule(openendedchild.OpenEndedChild): self.payload = {'grader_payload': updated_grader_payload} - try: - self.max_score = int(find_with_default(oeparam, 'max_score', 1)) - except ValueError: - self.max_score = 1 - def message_post(self,get, system): """ Handles a student message post (a reaction to the grade they received from an open ended grader type) diff --git a/common/lib/xmodule/xmodule/openendedchild.py b/common/lib/xmodule/xmodule/openendedchild.py index 63ab5b806a..2e3a5b8e02 100644 --- a/common/lib/xmodule/xmodule/openendedchild.py +++ b/common/lib/xmodule/xmodule/openendedchild.py @@ -69,7 +69,7 @@ class OpenEndedChild(): POST_ASSESSMENT = 'post_assessment' DONE = 'done' - def __init__(self, system, location, definition, descriptor, + def __init__(self, system, location, definition, descriptor, static_data, instance_state=None, shared_state=None, **kwargs): """ Definition file should have 4 blocks -- prompt, rubric, submitmessage, hintprompt, @@ -118,11 +118,11 @@ class OpenEndedChild(): self.created = instance_state.get('created', "False") self.attempts = instance_state.get('attempts', 0) - self.max_attempts = int(instance_state.get('attempts', MAX_ATTEMPTS)) + self.max_attempts = static_data['max_attempts'] # Used for progress / grading. Currently get credit just for # completion (doesn't matter if you self-assessed correct/incorrect). - self._max_score = int(instance_state.get('max_score', MAX_SCORE)) + self._max_score = static_data['max_score'] self.setup_response(system, location, definition, descriptor) diff --git a/common/lib/xmodule/xmodule/self_assessment_module.py b/common/lib/xmodule/xmodule/self_assessment_module.py index e2651a080e..88c47f92ef 100644 --- a/common/lib/xmodule/xmodule/self_assessment_module.py +++ b/common/lib/xmodule/xmodule/self_assessment_module.py @@ -30,15 +30,6 @@ import openendedchild log = logging.getLogger("mitx.courseware") -# Set the default number of max attempts. Should be 1 for production -# Set higher for debugging/testing -# attempts specified in xml definition overrides this. -MAX_ATTEMPTS = 1 - -# Set maximum available number of points. -# Overriden by max_score specified in xml. -MAX_SCORE = 1 - class SelfAssessmentModule(openendedchild.OpenEndedChild): def setup_response(self, system, location, definition, descriptor): diff --git a/lms/templates/combined_open_ended_status.html b/lms/templates/combined_open_ended_status.html index bd4dce27e5..e53c8136e3 100644 --- a/lms/templates/combined_open_ended_status.html +++ b/lms/templates/combined_open_ended_status.html @@ -1,7 +1,7 @@
%for status in status_list: - Step ${status['task_number']} : ${status['score']} / ${status['max_score']} + Step ${status['task_number']} (${status['state']}) : ${status['score']} / ${status['max_score']} %if status['type']=="openended": ${status['post_assessment']} %endif