'Extracts choices from the xml for this problem type.
If we have xml that is as follows(choice names will have been assigned
by now)
<radiotextgroup>
<choice correct = "true" name ="1_2_1_choiceinput_0bc">
The number
<numtolerance_input name = "1_2_1_choiceinput0_numtolerance_input_0" answer="5"/>
Is the mean of the list.
</choice>
<choice correct = "false" name = "1_2_1_choiceinput_1bc>
False demonstration choice
</choice>
</radiotextgroup>
Choices are used for rendering the problem properly
The function will setup choices as follows:
choices =[
("1_2_1_choiceinput_0bc",
[{\'type\': \'text\', \'contents\': "The number", \'tail_text\': \'\',
\'value\': \'\'
{\'type\': \'textinput\',
\'contents\': "1_2_1_choiceinput0_numtolerance_input_0",
\'tail_text\': \'Is the mean of the list\',
\'value\': \'\'
("1_2_1_choiceinput_1bc",
[{\'type\': \'text\', \'contents\': "False demonstration choice",
\'tail_text\': \'\',
\'value\': \'\''

@staticmethod
def extract_choices(element, i18n):

    _ = i18n.ugettext
    choices = []
    for choice in element:
        if (choice.tag != 'choice'):
            msg = Text('[capa.inputtypes.extract_choices]    {0}').format(Text(_('Expected    a    {expected_tag}    tag;    got    {given_tag}    instead')).format(expected_tag='<choice>', given_tag=choice.tag))
            raise Exception(msg)
        components = []
        choice_text = ''
        if (choice.text is not None):
            choice_text += choice.text
        adder = {'type': 'text', 'contents': choice_text, 'tail_text': '', 'value': ''}
        components.append(adder)
        for elt in choice:
            adder = {'type': 'text', 'contents': '', 'tail_text': '', 'value': ''}
            tag_type = elt.tag
            if (tag_type in ('numtolerance_input', 'decoy_input')):
                adder['type'] = 'textinput'
                adder['contents'] = elt.get('name')
            else:
                adder['contents'] = elt.text
            adder['tail_text'] = (elt.tail if elt.tail else '')
            components.append(adder)
        choices.append((choice.get('name'), components))
    return choices
