'Construct data to be used for a11y.
Arguments:
response (object): xml response object
inputfields (list): list of inputfields in a responsetype
responsetype_id (str): responsetype id
problem_data (dict): dict to be filled with response data'

def response_a11y_data(self, response, inputfields, responsetype_id, problem_data):

    if (not inputfields):
        return
    element_to_be_deleted = None
    label = ''
    if (len(inputfields) > 1):
        response.set('multiple_inputtypes', 'true')
        group_label_tag = response.find('label')
        group_description_tags = response.findall('description')
        group_label_tag_id = u'multiinput-group-label-{}'.format(responsetype_id)
        group_label_tag_text = ''
        if (group_label_tag is not None):
            group_label_tag.tag = 'p'
            group_label_tag.set('id', group_label_tag_id)
            group_label_tag.set('class', 'multi-inputs-group-label')
            group_label_tag_text = stringify_children(group_label_tag)
            response.set('multiinput-group-label-id', group_label_tag_id)
        group_description_ids = []
        for (index, group_description_tag) in enumerate(group_description_tags):
            group_description_tag_id = u'multiinput-group-description-{}-{}'.format(responsetype_id, index)
            group_description_tag.tag = 'p'
            group_description_tag.set('id', group_description_tag_id)
            group_description_tag.set('class', 'multi-inputs-group-description    question-description')
            group_description_ids.append(group_description_tag_id)
        if group_description_ids:
            response.set('multiinput-group_description_ids', '    '.join(group_description_ids))
        for inputfield in inputfields:
            problem_data[inputfield.get('id')] = {'group_label': group_label_tag_text, 'label': inputfield.attrib.get('label', ''), 'descriptions': {}}
    else:
        responsetype_label_tag = response.find('label')
        if (responsetype_label_tag is not None):
            label = stringify_children(responsetype_label_tag)
            element_to_be_deleted = responsetype_label_tag
        elif ('label' in inputfields[0].attrib):
            p_tag = response.xpath('preceding-sibling::*[1][self::p]')
            if (p_tag and (p_tag[0].text == inputfields[0].attrib['label'])):
                label = stringify_children(p_tag[0])
                element_to_be_deleted = p_tag[0]
        else:
            label_tag = response.xpath('preceding-sibling::*[1][self::label]')
            if label_tag:
                label = stringify_children(label_tag[0])
                element_to_be_deleted = label_tag[0]
        if ((inputfields[0].tag in ACCESSIBLE_CAPA_INPUT_TYPES) and (element_to_be_deleted is not None)):
            element_to_be_deleted.getparent().remove(element_to_be_deleted)
        description_tags = response.findall('description')
        description_id = 1
        descriptions = OrderedDict()
        for description in description_tags:
            descriptions[('description_%s_%i' % (responsetype_id, description_id))] = HTML(stringify_children(description))
            response.remove(description)
            description_id += 1
        problem_data[inputfields[0].get('id')] = {'label': (HTML(label.strip()) if label else ''), 'descriptions': descriptions}
