Commit e2e79c96 by ichuang

multiplechoice inputs: allow <choice ...>item text</choice> format

parent 200bb5ca
...@@ -197,8 +197,12 @@ def choicegroup(element, value, status, msg=''): ...@@ -197,8 +197,12 @@ def choicegroup(element, value, status, msg=''):
type="radio" type="radio"
choices={} choices={}
for choice in element: for choice in element:
assert choice.tag =="choice", "only <choice> tags should be immediate children of a <choicegroup>" if not choice.tag=='choice':
choices[choice.get("name")] = etree.tostring(choice[0]) # TODO: what if choice[0] has math tags in it? raise Exception,"[courseware.capa.inputtypes.choicegroup] Error only <choice> tags should be immediate children of a <choicegroup>, 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} context={'id':eid, 'value':value, 'state':status, 'type':type, 'choices':choices}
html=render_to_string("choicegroup.html", context) html=render_to_string("choicegroup.html", context)
return etree.XML(html) return etree.XML(html)
......
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