diff --git a/common/lib/capa/capa/capa_problem.py b/common/lib/capa/capa/capa_problem.py index 7a2408e209..84af4db4b6 100644 --- a/common/lib/capa/capa/capa_problem.py +++ b/common/lib/capa/capa/capa_problem.py @@ -285,7 +285,9 @@ class LoncapaProblem(object): correct_option = None child_options = [] for option_element in optioninput.findall('./option'): - option_name = option_element.text.strip() + text = option_element.text + text = text or '' + option_name = text.strip() if option_element.get('correct').upper() == 'TRUE': correct_option = option_name child_options.append("'" + option_name + "'") diff --git a/common/lib/capa/capa/tests/test_capa_problem.py b/common/lib/capa/capa/tests/test_capa_problem.py index 6b2cc02fc4..f4cbf8eb2a 100644 --- a/common/lib/capa/capa/tests/test_capa_problem.py +++ b/common/lib/capa/capa/tests/test_capa_problem.py @@ -397,6 +397,26 @@ class CAPAProblemTest(unittest.TestCase): problem = new_loncapa_problem(xml.format(correctness=False)) assert problem is not None + def test_optionresponse_option_with_empty_text(self): + """ + Verify successful instantiation of an optionresponse problem + with an option with empty text + """ + xml = """ + + + + + + + + + + + """ + problem = new_loncapa_problem(xml) + assert problem is not None + @ddt.ddt class CAPAMultiInputProblemTest(unittest.TestCase):