From b36d0dd9079508983497c21207f994b555129b9b Mon Sep 17 00:00:00 2001 From: ichuang Date: Mon, 4 Jun 2012 18:13:49 -0400 Subject: [PATCH] raise helpful error in NumericalResponse when missing required "answer" attribute --- djangoapps/courseware/capa/responsetypes.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/djangoapps/courseware/capa/responsetypes.py b/djangoapps/courseware/capa/responsetypes.py index 917a3f731b..75c90be77e 100644 --- a/djangoapps/courseware/capa/responsetypes.py +++ b/djangoapps/courseware/capa/responsetypes.py @@ -185,6 +185,10 @@ class OptionResponse(GenericResponse): class NumericalResponse(GenericResponse): def __init__(self, xml, context, system=None): 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','') + raise Exception,msg self.correct_answer = contextualize_text(xml.get('answer'), context) try: self.tolerance_xml = xml.xpath('//*[@id=$id]//responseparam[@type="tolerance"]/@default',