'Extracts choices for a few input types, such as ChoiceGroup, RadioGroup and
CheckboxGroup.
returns list of (choice_name, choice_text) tuples
TODO: allow order of choices to be randomized, following lon-capa spec.  Use
"location" attribute, ie random, top, bottom.'

@staticmethod
def extract_choices(element, i18n):

    choices = []
    _ = i18n.ugettext
    for choice in element:
        if (choice.tag == 'choice'):
            choices.append((choice.get('name'), stringify_children(choice)))
        elif (choice.tag != 'compoundhint'):
            msg = Text('[capa.inputtypes.extract_choices]    {error_message}').format(error_message=Text(_('Expected    a    <choice>    or    <compoundhint>    tag;    got    {given_tag}    instead')).format(given_tag=choice.tag))
            raise Exception(msg)
    return choices
