Commit 7814805c by ichuang

improve capa error handling a bit - for better user experience

- if no answer given, then symbolicresponse + customrepsonse now
  give an error message, instead of doing nothing
- in capa_module if lcp.grade_answers fails, in DEBUG mode display
  alert with useful error message
parent 62f17179
...@@ -304,7 +304,8 @@ class LoncapaProblem(object): ...@@ -304,7 +304,8 @@ class LoncapaProblem(object):
try: try:
exec code in context, context # use "context" for global context; thus defs in code are global within code exec code in context, context # use "context" for global context; thus defs in code are global within code
except Exception: except Exception:
log.exception("Error while execing code: " + code) log.exception("Error while execing script code: " + code)
raise responsetypes.LoncapaProblemError("Error while executing script code")
return context return context
def _extract_html(self, problemtree): # private def _extract_html(self, problemtree): # private
......
...@@ -567,7 +567,7 @@ def sympy_check2(): ...@@ -567,7 +567,7 @@ def sympy_check2():
# if there is only one box, and it's empty, then don't evaluate # if there is only one box, and it's empty, then don't evaluate
if len(idset)==1 and not submission[0]: if len(idset)==1 and not submission[0]:
return {idset[0]:'no_answer_entered'} return CorrectMap(idset[0],'incorrect',msg='<font color="red">No answer entered!</font>')
correct = ['unknown'] * len(idset) correct = ['unknown'] * len(idset)
messages = [''] * len(idset) messages = [''] * len(idset)
......
...@@ -409,18 +409,21 @@ class Module(XModule): ...@@ -409,18 +409,21 @@ class Module(XModule):
correct_map = self.lcp.grade_answers(answers) correct_map = self.lcp.grade_answers(answers)
except StudentInputError as inst: except StudentInputError as inst:
# TODO (vshnayder): why is this line here? # TODO (vshnayder): why is this line here?
self.lcp = LoncapaProblem(self.filestore.open(self.filename), #self.lcp = LoncapaProblem(self.filestore.open(self.filename),
id=lcp_id, state=old_state, system=self.system) # id=lcp_id, state=old_state, system=self.system)
traceback.print_exc() traceback.print_exc()
return {'success': inst.message} return {'success': inst.message}
except: except Exception, err:
# TODO: why is this line here? # TODO: why is this line here?
self.lcp = LoncapaProblem(self.filestore.open(self.filename), #self.lcp = LoncapaProblem(self.filestore.open(self.filename),
id=lcp_id, state=old_state, system=self.system) # id=lcp_id, state=old_state, system=self.system)
if self.DEBUG:
msg = "Error checking problem: " + str(err)
msg += '\nTraceback:\n' + traceback.format_exc()
return {'success':msg}
traceback.print_exc() traceback.print_exc()
raise Exception,"error in capa_module" raise Exception,"error in capa_module"
# TODO: Dead code... is this a bug, or just old?
return {'success':'Unknown Error'}
self.attempts = self.attempts + 1 self.attempts = self.attempts + 1
self.lcp.done = True self.lcp.done = True
......
...@@ -77,6 +77,7 @@ class Module(XModule): ...@@ -77,6 +77,7 @@ class Module(XModule):
contents['progress_status'] = Progress.to_js_status_str(progress) contents['progress_status'] = Progress.to_js_status_str(progress)
contents['progress_detail'] = Progress.to_js_detail_str(progress) contents['progress_detail'] = Progress.to_js_detail_str(progress)
content = None
for (content, element_class) in zip(self.contents, child_classes): for (content, element_class) in zip(self.contents, child_classes):
new_class = 'other' new_class = 'other'
for c in class_priority: for c in class_priority:
......
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