'Create a dummy problem to represent any errors.
Change our problem to a dummy problem containing a warning message to
display to users. Returns the HTML to show to users
`err` is the Exception encountered while rendering the problem HTML.'

def handle_problem_html_error(self, err):

    log.exception(err.message)
    if self.runtime.DEBUG:
        msg = u'[courseware.capa.capa_module]    <font    size="+1"    color="red">Failed    to    generate    HTML    for    problem    {url}</font>'.format(url=cgi.escape(self.location.to_deprecated_string()))
        msg += u'<p>Error:</p><p><pre>{msg}</pre></p>'.format(msg=cgi.escape(err.message))
        msg += u'<p><pre>{tb}</pre></p>'.format(tb=cgi.escape(traceback.format_exc()))
        html = msg
    else:
        student_answers = self.lcp.student_answers
        answer_ids = student_answers.keys()
        hidden_state_keywords = ['dynamath']
        for answer_id in answer_ids:
            for hidden_state_keyword in hidden_state_keywords:
                if (answer_id.find(hidden_state_keyword) >= 0):
                    student_answers.pop(answer_id)
        self.lcp = self.new_lcp(None)
        self.set_state_from_lcp()
        self.set_score(self.score_from_lcp())
        _ = self.runtime.service(self, 'i18n').ugettext
        warning_msg = _('Warning:    The    problem    has    been    reset    to    its    initial    state!')
        warning = (('<div    class="capa_reset">    <h2>    ' + warning_msg) + '</h2>')
        warning_msg = _("The    problem's    state    was    corrupted    by    an    invalid    submission.    The    submission    consisted    of:")
        warning += (warning_msg + '<ul>')
        for student_answer in student_answers.values():
            if (student_answer != ''):
                warning += (('<li>' + cgi.escape(student_answer)) + '</li>')
        warning_msg = _('If    this    error    persists,    please    contact    the    course    staff.')
        warning += (('</ul>' + warning_msg) + '</div>')
        html = warning
        try:
            html += self.lcp.get_html()
        except Exception:
            log.exception('Unable    to    generate    html    from    LoncapaProblem')
            raise
    return html
