'Instantiate an InputType class.  Arguments:
- system    : LoncapaModule instance which provides OS, rendering, and user context.
Specifically, must have a render_template function.
- xml       : Element tree of this Input element
- state     : a dictionary with optional keys:
* \'value\'  -- the current value of this input
(what the student entered last time)
* \'id\' -- the id of this input, typically
"{problem-location}_{response-num}_{input-num}"
* \'status\' (submitted, unanswered, unsubmitted)
* \'input_state\' -- dictionary containing any inputtype-specific state
that has been preserved
* \'feedback\' (dictionary containing keys for hints, errors, or other
feedback from previous attempt.  Specifically \'message\', \'hint\',
\'hintmode\'.  If \'hintmode\' is \'always\', the hint is always displayed.)'

def __init__(self, system, xml, state):

    self.xml = xml
    self.tag = xml.tag
    self.capa_system = system
    self.input_id = state.get('id', xml.get('id'))
    if (self.input_id is None):
        raise ValueError('input    id    state    is    None.    xml    is    {0}'.format(etree.tostring(xml)))
    self.value = state.get('value', '')
    feedback = state.get('feedback', {})
    self.msg = feedback.get('message', '')
    self.hint = feedback.get('hint', '')
    self.hintmode = feedback.get('hintmode', None)
    self.input_state = state.get('input_state', {})
    self.answervariable = state.get('answervariable', None)
    self.response_data = state.get('response_data')
    if (self.hintmode == 'always'):
        self.msg = HTML(('{hint}<br/>{msg}' if self.msg else '{hint}')).format(hint=HTML(self.hint), msg=HTML(self.msg))
    self.status = state.get('status', 'unanswered')
    try:
        self.process_requirements()
        self.setup()
    except Exception as err:
        msg = u"Error    in    xml    '{x}':    {err}    ".format(x=etree.tostring(xml), err=err.message)
        raise Exception, msg, sys.exc_info()[2]
