'Create a <choicegroup> XML element
Uses **kwargs:
*choice_type*: Can be "checkbox", "radio", or "multiple"
*choices*: List of True/False values indicating whether
a particular choice is correct or not.
Users must choose *all* correct options in order
to be marked correct.
DEFAULT: [True]
*choice_names": List of strings identifying the choices.
If specified, you must ensure that
len(choice_names) == len(choices)
*points*: List of strings giving partial credit values (0-1)
for each choice. Interpreted as floats in problem.
If specified, ensure len(points) == len(choices)'

@staticmethod
def choicegroup_input_xml(**kwargs):

    group_element_names = {'checkbox': 'checkboxgroup', 'radio': 'radiogroup', 'multiple': 'choicegroup'}
    choices = kwargs.get('choices', [True])
    choice_type = kwargs.get('choice_type', 'multiple')
    choice_names = kwargs.get('choice_names', ([None] * len(choices)))
    points = kwargs.get('points', ([None] * len(choices)))
    assert (choice_type in group_element_names)
    group_element = etree.Element(group_element_names[choice_type])
    for (correct_val, name, pointval) in zip(choices, choice_names, points):
        choice_element = etree.SubElement(group_element, 'choice')
        if (correct_val is True):
            correctness = 'true'
        elif (correct_val is False):
            correctness = 'false'
        elif ('partial' in correct_val):
            correctness = 'partial'
        else:
            correctness = correct_val
        choice_element.set('correct', correctness)
        if name:
            choice_element.text = str(name)
            choice_element.set('name', str(name))
        if pointval:
            choice_element.set('point_value', str(pointval))
    return group_element
