diff --git a/common/lib/xmodule/xmodule/capa_module.py b/common/lib/xmodule/xmodule/capa_module.py index a344d2981d..894d23c342 100644 --- a/common/lib/xmodule/xmodule/capa_module.py +++ b/common/lib/xmodule/xmodule/capa_module.py @@ -1,3 +1,4 @@ +import cgi import datetime import dateutil import dateutil.parser @@ -236,16 +237,33 @@ class CapaModule(XModule): # to avoid bricking of problem as much as possible # Presumably, student submission has corrupted LoncapaProblem HTML. - # So, let's try generate a fresh LoncapaProblem + # First, pull down all student answers + student_answers = self.lcp.student_answers + answer_ids = student_answers.keys() + + # Some inputtypes, such as dynamath, have additional "hidden" state that + # is not exposed to the student. Keep those hidden + hidden_state_keywords = ['dynamath'] + for answer_id in answer_ids: + for hidden_state_keyword in hidden_state_keywords: + if answer_id.find(hidden_state_keyword) >= 0: + student_answers.pop(answer_id) + + # Next, generate a fresh LoncapaProblem self.lcp = LoncapaProblem(self.definition['data'], self.location.html_id(), state=None, # Tabula rasa seed=self.seed, system=self.system) # Prepend a scary warning to the student warning = '
Problem state was corruped by invalid input. ' - warning += 'Problem reset to initial state! ' - warning += 'If problem persists, please contact the course staff.
' + warning += 'Problem state was corruped by invalid submission. The submission consisted of:
' + warning += 'If problem persists, please contact the course staff.
' warning += '