'Generate adaptive hints for this problem based on student answers, the old CorrectMap,
and the new CorrectMap produced by get_score.
Does not return anything.
Modifies new_cmap, by adding hints to answer_id entries as appropriate.'

def get_hints(self, student_answers, new_cmap, old_cmap):

    hintfn = None
    hint_function_provided = False
    hintgroup = self.xml.find('hintgroup')
    if (hintgroup is not None):
        hintfn = hintgroup.get('hintfn')
        if (hintfn is not None):
            hint_function_provided = True
    if hint_function_provided:
        global CORRECTMAP_PY
        if (CORRECTMAP_PY is None):
            CORRECTMAP_PY = inspect.getsource(correctmap)
        code = ((((CORRECTMAP_PY + '\n') + self.context['script_code']) + '\n') + textwrap.dedent('\n                                                                                new_cmap    =    CorrectMap()\n                                                                                new_cmap.set_dict(new_cmap_dict)\n                                                                                old_cmap    =    CorrectMap()\n                                                                                old_cmap.set_dict(old_cmap_dict)\n                                                                                {hintfn}(answer_ids,    student_answers,    new_cmap,    old_cmap)\n                                                                                new_cmap_dict.update(new_cmap.get_dict())\n                                                                                old_cmap_dict.update(old_cmap.get_dict())\n                                                                                ').format(hintfn=hintfn))
        globals_dict = {'answer_ids': self.answer_ids, 'student_answers': student_answers, 'new_cmap_dict': new_cmap.get_dict(), 'old_cmap_dict': old_cmap.get_dict()}
        try:
            safe_exec.safe_exec(code, globals_dict, python_path=self.context['python_path'], extra_files=self.context['extra_files'], slug=self.id, random_seed=self.context['seed'], unsafely=self.capa_system.can_execute_unsafe_code())
        except Exception as err:
            _ = self.capa_system.i18n.ugettext
            msg = _('Error    {err}    in    evaluating    hint    function    {hintfn}.').format(err=err, hintfn=hintfn)
            sourcenum = getattr(self.xml, 'sourceline', _('(Source    code    line    unavailable)'))
            msg += ('\n' + _('See    XML    source    line    {sourcenum}.').format(sourcenum=sourcenum))
            raise ResponseError(msg)
        new_cmap.set_dict(globals_dict['new_cmap_dict'])
        return
    if ((self.hint_tag is not None) and (hintgroup is not None) and (hintgroup.find(self.hint_tag) is not None) and hasattr(self, 'check_hint_condition')):
        rephints = hintgroup.findall(self.hint_tag)
        hints_to_show = self.check_hint_condition(rephints, student_answers)
        hintmode = hintgroup.get('mode', 'always')
        for hintpart in hintgroup.findall('hintpart'):
            if (hintpart.get('on') in hints_to_show):
                hint_text = hintpart.find('text').text
                aid = self.answer_ids[(-1)]
                new_cmap.set_hint_and_mode(aid, hint_text, hintmode)
        log.debug('after    hint:    new_cmap    =    %s', new_cmap)
    else:
        self.get_extended_hints(student_answers, new_cmap)
