From 95616d7d11aaeae5ed336f9b8a0fa311ce19ef08 Mon Sep 17 00:00:00 2001
From: Alan Zarembok Error formatting HTML for problem:{msg}
Could not format HTML for problem. ' + u'Contact course staff in the discussion forum for assistance.
' + ) + def submit_button_name(self): """ Determine the name for the "submit" button. @@ -549,8 +564,8 @@ class CapaMixin(ScorableXBlockMixin, CapaFields): # TODO (vshnayder): another switch on DEBUG. if self.runtime.DEBUG: msg = HTML( - u'[courseware.capa.capa_module] ' - u'Failed to generate HTML for problem {url}' + u'[courseware.capa.capa_module] ' + u'Failed to generate HTML for problem {url}' ).format( url=text_type(self.location) ) @@ -564,6 +579,7 @@ class CapaMixin(ScorableXBlockMixin, CapaFields): # Presumably, student submission has corrupted LoncapaProblem HTML. # First, pull down all student answers + student_answers = self.lcp.student_answers answer_ids = list(student_answers.keys()) diff --git a/common/lib/xmodule/xmodule/capa_module.py b/common/lib/xmodule/xmodule/capa_module.py index 53778a2a59..9384d4d2d5 100644 --- a/common/lib/xmodule/xmodule/capa_module.py +++ b/common/lib/xmodule/xmodule/capa_module.py @@ -103,13 +103,18 @@ class ProblemBlock( if 'lcp' in self.__dict__: del self.__dict__['lcp'] - def student_view(self, _context): + def student_view(self, _context, show_detailed_errors=False): """ Return the student view. """ # self.score is initialized in self.lcp but in this method is accessed before self.lcp so just call it first. - self.lcp - fragment = Fragment(self.get_html()) + try: + self.lcp + except Exception as err: + html = self.handle_fatal_lcp_error(err if show_detailed_errors else None) + else: + html = self.get_html() + fragment = Fragment(html) add_webpack_to_fragment(fragment, 'ProblemBlockPreview') shim_xmodule_js(fragment, 'Problem') return fragment @@ -118,7 +123,7 @@ class ProblemBlock( """ Renders the Studio preview view. """ - return self.student_view(context) + return self.student_view(context, show_detailed_errors=True) def studio_view(self, _context): """