'Initializes capa Problem.
Arguments:
problem_text (string): xml defining the problem.
id (string): identifier for this problem, often a filename (no spaces).
capa_system (LoncapaSystem): LoncapaSystem instance which provides OS,
rendering, user context, and other resources.
capa_module: instance needed to access runtime/logging
state (dict): containing the following keys:
- `seed` (int) random number generator seed
- `student_answers` (dict) maps input id to the stored answer for that input
- \'has_saved_answers\' (Boolean) True if the answer has been saved since last submit.
- `correct_map` (CorrectMap) a map of each input to their \'correctness\'
- `done` (bool) indicates whether or not this problem is considered done
- `input_state` (dict) maps input_id to a dictionary that holds the state for that input
seed (int): random number generator seed.'

def __init__(self, problem_text, id, capa_system, capa_module, state=None, seed=None, minimal_init=False):

    self.do_reset()
    self.problem_id = id
    self.capa_system = capa_system
    self.capa_module = capa_module
    state = (state or {})
    self.seed = state.get('seed', seed)
    assert (self.seed is not None), 'Seed    must    be    provided    for    LoncapaProblem.'
    self.student_answers = state.get('student_answers', {})
    self.has_saved_answers = state.get('has_saved_answers', False)
    if ('correct_map' in state):
        self.correct_map.set_dict(state['correct_map'])
    self.done = state.get('done', False)
    self.input_state = state.get('input_state', {})
    problem_text = re.sub('startouttext\\s*/', 'text', problem_text)
    problem_text = re.sub('endouttext\\s*/', '/text', problem_text)
    self.problem_text = problem_text
    self.tree = etree.XML(problem_text)
    self.make_xml_compatible(self.tree)
    self._process_includes()
    if minimal_init:
        self.context = {}
    else:
        self.context = self._extract_context(self.tree)
    self.problem_data = self._preprocess_problem(self.tree, minimal_init)
    if (not minimal_init):
        if (not self.student_answers):
            self.set_initial_display()
        self.inputs = {}
        responses = self.responders.values()
        responses = sorted(responses, key=(lambda resp: int(resp.id[(resp.id.rindex('_') + 1):])))
        for response in responses:
            if hasattr(response, 'late_transforms'):
                response.late_transforms(self)
        self.extracted_tree = self._extract_html(self.tree)
