'Return a map of inputs to their corresponding summarized metadata.
Returns:
A map whose keys are a unique identifier for the input (in this case a capa input_id) and
whose values are:
question (str): Is the prompt that was presented to the student.  It corresponds to the
label of the input.
answer (mixed): Is the answer the student provided.  This may be a rich structure,
however it must be json serializable.
response_type (str): The XML tag of the capa response type.
input_type (str): The XML tag of the capa input type.
correct (bool): Whether or not the provided answer is correct.  Will be an empty
string if correctness could not be determined.
variant (str): In some cases the same question can have several different variants.
This string should uniquely identify the variant of the question that was answered.
In the capa context this corresponds to the `seed`.
This function attempts to be very conservative and make very few assumptions about the structure
of the problem.  If problem related metadata cannot be located it should be replaced with empty
strings \'\'.'

def get_submission_metadata(self, answers, correct_map):

    input_metadata = {}
    for (input_id, internal_answer) in answers.iteritems():
        answer_input = self.lcp.inputs.get(input_id)
        if (answer_input is None):
            log.warning('Input    id    %s    is    not    mapped    to    an    input    type.', input_id)
        answer_response = None
        for responder in self.lcp.responders.itervalues():
            if (input_id in responder.answer_ids):
                answer_response = responder
        if (answer_response is None):
            log.warning('Answer    responder    could    not    be    found    for    input_id    %s.', input_id)
        user_visible_answer = internal_answer
        if hasattr(answer_input, 'get_user_visible_answer'):
            user_visible_answer = answer_input.get_user_visible_answer(internal_answer)
        variant = ''
        if (self.rerandomize != RANDOMIZATION.NEVER):
            variant = self.seed
        is_correct = correct_map.is_correct(input_id)
        if (is_correct is None):
            is_correct = ''
        response_data = getattr(answer_input, 'response_data', {})
        input_metadata[input_id] = {'question': response_data.get('label', ''), 'answer': user_visible_answer, 'response_type': getattr(getattr(answer_response, 'xml', None), 'tag', ''), 'input_type': getattr(answer_input, 'tag', ''), 'correct': is_correct, 'variant': variant, 'group_label': response_data.get('group_label', '')}
    return input_metadata
