Commit b36d0dd9 by ichuang

raise helpful error in NumericalResponse when missing required "answer" attribute

parent 613ff49d
...@@ -185,6 +185,10 @@ class OptionResponse(GenericResponse): ...@@ -185,6 +185,10 @@ class OptionResponse(GenericResponse):
class NumericalResponse(GenericResponse): class NumericalResponse(GenericResponse):
def __init__(self, xml, context, system=None): def __init__(self, xml, context, system=None):
self.xml = xml self.xml = xml
if not xml.get('answer'):
msg = "Error in problem specification: numericalresponse missing required answer attribute\n"
msg += "See XML source line %s" % getattr(xml,'sourceline','<unavailable>')
raise Exception,msg
self.correct_answer = contextualize_text(xml.get('answer'), context) self.correct_answer = contextualize_text(xml.get('answer'), context)
try: try:
self.tolerance_xml = xml.xpath('//*[@id=$id]//responseparam[@type="tolerance"]/@default', self.tolerance_xml = xml.xpath('//*[@id=$id]//responseparam[@type="tolerance"]/@default',
......
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