From e5a7d811d73fc8cd3c69280e260c2024ea97c6ae Mon Sep 17 00:00:00 2001 From: ichuang Date: Mon, 28 May 2012 14:08:26 -0400 Subject: [PATCH] multiplechoice inputs: allow item text format --- djangoapps/courseware/capa/inputtypes.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/djangoapps/courseware/capa/inputtypes.py b/djangoapps/courseware/capa/inputtypes.py index 9992f7f679..ac8f2ac724 100644 --- a/djangoapps/courseware/capa/inputtypes.py +++ b/djangoapps/courseware/capa/inputtypes.py @@ -197,8 +197,12 @@ def choicegroup(element, value, status, msg=''): type="radio" choices={} for choice in element: - assert choice.tag =="choice", "only tags should be immediate children of a " - choices[choice.get("name")] = etree.tostring(choice[0]) # TODO: what if choice[0] has math tags in it? + if not choice.tag=='choice': + raise Exception,"[courseware.capa.inputtypes.choicegroup] Error only tags should be immediate children of a , found %s instead" % choice.tag + ctext = "" + ctext += ''.join([etree.tostring(x) for x in choice]) # TODO: what if choice[0] has math tags in it? + ctext += choice.text # TODO: fix order? + choices[choice.get("name")] = ctext context={'id':eid, 'value':value, 'state':status, 'type':type, 'choices':choices} html=render_to_string("choicegroup.html", context) return etree.XML(html)