'Create a <formularesponse> element.
*sample_dict*: A dictionary of the form:
{ VARIABLE_NAME: (MIN, MAX), ....}
This specifies the range within which
to numerically sample each variable to check
student answers.
[REQUIRED]
*num_samples*: The number of times to sample the student\'s answer
to numerically compare it to the correct answer.
*tolerance*: The tolerance within which answers will be accepted
[DEFAULT: 0.01]
*answer*: The answer to the problem.  Can be a formula string
or a Python variable defined in a script
(e.g. "$calculated_answer" for a Python variable
called calculated_answer)
[REQUIRED]
*hints*: List of (hint_prompt, hint_name, hint_text) tuples
Where *hint_prompt* is the formula for which we show the hint,
*hint_name* is an internal identifier for the hint,
and *hint_text* is the text we show for the hint.'

def create_response_element(self, **kwargs):

    sample_dict = kwargs.get('sample_dict', None)
    num_samples = kwargs.get('num_samples', None)
    tolerance = kwargs.get('tolerance', 0.01)
    answer = kwargs.get('answer', None)
    hint_list = kwargs.get('hints', None)
    assert answer
    assert (sample_dict and num_samples)
    response_element = etree.Element('formularesponse')
    sample_str = self._sample_str(sample_dict, num_samples, tolerance)
    response_element.set('samples', sample_str)
    responseparam_element = etree.SubElement(response_element, 'responseparam')
    responseparam_element.set('type', 'tolerance')
    responseparam_element.set('default', str(tolerance))
    response_element.set('answer', str(answer))
    if hint_list:
        hintgroup_element = etree.SubElement(response_element, 'hintgroup')
        for (hint_prompt, hint_name, hint_text) in hint_list:
            formulahint_element = etree.SubElement(hintgroup_element, 'formulahint')
            formulahint_element.set('samples', sample_str)
            formulahint_element.set('answer', str(hint_prompt))
            formulahint_element.set('name', str(hint_name))
            hintpart_element = etree.SubElement(hintgroup_element, 'hintpart')
            hintpart_element.set('on', str(hint_name))
            text_element = etree.SubElement(hintpart_element, 'text')
            text_element.text = str(hint_text)
    return response_element
