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
This commit is contained in:
@@ -304,7 +304,8 @@ class LoncapaProblem(object):
|
||||
try:
|
||||
exec code in context, context # use "context" for global context; thus defs in code are global within code
|
||||
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
|
||||
|
||||
def _extract_html(self, problemtree): # private
|
||||
|
||||
@@ -567,7 +567,7 @@ def sympy_check2():
|
||||
|
||||
# if there is only one box, and it's empty, then don't evaluate
|
||||
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)
|
||||
messages = [''] * len(idset)
|
||||
|
||||
@@ -409,18 +409,21 @@ class Module(XModule):
|
||||
correct_map = self.lcp.grade_answers(answers)
|
||||
except StudentInputError as inst:
|
||||
# TODO (vshnayder): why is this line here?
|
||||
self.lcp = LoncapaProblem(self.filestore.open(self.filename),
|
||||
id=lcp_id, state=old_state, system=self.system)
|
||||
#self.lcp = LoncapaProblem(self.filestore.open(self.filename),
|
||||
# id=lcp_id, state=old_state, system=self.system)
|
||||
traceback.print_exc()
|
||||
return {'success': inst.message}
|
||||
except:
|
||||
except Exception, err:
|
||||
# TODO: why is this line here?
|
||||
self.lcp = LoncapaProblem(self.filestore.open(self.filename),
|
||||
id=lcp_id, state=old_state, system=self.system)
|
||||
#self.lcp = LoncapaProblem(self.filestore.open(self.filename),
|
||||
# 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()
|
||||
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.lcp.done = True
|
||||
|
||||
@@ -77,6 +77,7 @@ class Module(XModule):
|
||||
contents['progress_status'] = Progress.to_js_status_str(progress)
|
||||
contents['progress_detail'] = Progress.to_js_detail_str(progress)
|
||||
|
||||
content = None
|
||||
for (content, element_class) in zip(self.contents, child_classes):
|
||||
new_class = 'other'
|
||||
for c in class_priority:
|
||||
|
||||
Reference in New Issue
Block a user