'Adjust tree xml in-place for compatibility before creating
a problem from it.
The idea here is to provide a central point for XML translation,
for example, supporting an old XML format. At present, there just two translations.
1. <additional_answer> compatibility translation:
old:    <additional_answer>ANSWER</additional_answer>
convert to
new:    <additional_answer answer="ANSWER">OPTIONAL-HINT</addional_answer>
2. <optioninput> compatibility translation:
optioninput works like this internally:
<optioninput options="(\'yellow\',\'blue\',\'green\')" correct="blue" />
With extended hints there is a new <option> tag, like this
<option correct="True">blue <optionhint>sky color</optionhint> </option>
This translation takes in the new format and synthesizes the old option= attribute
so all downstream logic works unchanged with the new <option> tag format.'

def make_xml_compatible(self, tree):

    additionals = tree.xpath('//stringresponse/additional_answer')
    for additional in additionals:
        answer = additional.get('answer')
        text = additional.text
        if ((not answer) and text):
            additional.set('answer', text)
            additional.text = ''
    for optioninput in tree.xpath('//optioninput'):
        correct_option = None
        child_options = []
        for option_element in optioninput.findall('./option'):
            option_name = option_element.text.strip()
            if (option_element.get('correct').upper() == 'TRUE'):
                correct_option = option_name
            child_options.append((("'" + option_name) + "'"))
        if (len(child_options) > 0):
            options_string = (('(' + ','.join(child_options)) + ')')
            optioninput.attrib.update({'options': options_string})
            if correct_option:
                optioninput.attrib.update({'correct': correct_option})
