Commit 4240ebab by Isaac Chuang Committed by Piotr Mitros

More minor cleanups

parent e4a783b1
#
# File: courseware/capa/inputtypes.py
#
'''
Module containing the problem elements which render into input objects
- textline
- textbox (change this to textarea?)
- schemmatic
These are matched by *.html files templates/*.html which are mako templates with the actual html.
'''
from lxml.etree import Element
from lxml import etree
from mitxmako.shortcuts import render_to_string
#-----------------------------------------------------------------------------
#takes the xml tree as 'element', the student's previous answer as 'value', and the graded status as 'state'
def choicegroup(element, value, state):
'''
Radio button inputs: multiple choice or true/false
TODO: allow order of choices to be randomized, following lon-capa spec. Use "location" attribute,
ie random, top, bottom.
'''
eid=element.get('id')
if element.get('type') == "MultipleChoice":
type="radio"
......@@ -16,7 +39,7 @@ def choicegroup(element, value, state):
choices={}
for choice in element:
assert choice.tag =="choice", "only <choice> tags should be immediate children of a <choicegroup>"
choices[choice.get("name")] = etree.tostring(choice[0])
choices[choice.get("name")] = etree.tostring(choice[0]) # TODO: what if choice[0] has math tags in it?
context={'id':eid, 'value':value, 'state':state, 'type':type, 'choices':choices}
html=render_to_string("choicegroup.html", context)
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