diff --git a/course/page/code.py b/course/page/code.py index e917a2127e73f235c27f9ac8e4bc5c13852b4b6b..c594cd663cccb6e30d3568731c2477e6a03e2a84 100644 --- a/course/page/code.py +++ b/course/page/code.py @@ -652,12 +652,32 @@ class PythonCodeQuestion(PageBaseWithTitle, PageBaseWithValue): error_msg = "\n".join(error_msg_parts) + review_url = "" + if not page_context.in_sandbox: + + from django.core.urlresolvers import reverse + review_url = reverse( + "relate-view_flow_page", + kwargs={'course_identifier': page_context.course.identifier, + 'flow_session_id': page_context.flow_session.id, + 'ordinal': page_context.ordinal + } + ) + + from six.moves.urllib.parse import urljoin + review_uri = urljoin(getattr(settings, "RELATE_BASE_URL"), + review_url) + + from relate.utils import local_now, format_datetime_local with translation.override(settings.RELATE_ADMIN_EMAIL_LOCALE): from django.template.loader import render_to_string message = render_to_string("course/broken-code-question-email.txt", { + "site": getattr(settings, "RELATE_BASE_URL"), "page_id": self.page_desc.id, "course": page_context.course, "error_message": error_msg, + "review_uri": review_uri, + "time": format_datetime_local(local_now()) }) if ( diff --git a/course/templates/course/broken-code-question-email.txt b/course/templates/course/broken-code-question-email.txt index bf87d3adb62e8dd7cc0868aa08e33ce42e457a9f..d89cfd0d15faddc39661dafbcbff2bc002d1f998 100644 --- a/course/templates/course/broken-code-question-email.txt +++ b/course/templates/course/broken-code-question-email.txt @@ -1,8 +1,17 @@ {% load i18n %}{% blocktrans with page_id=page_id course_identifier=course.identifier error_message=error_message|safe %}Hi there, +This message was sent from {{ site }} at {{ time }}. Bad news! A code question with ID '{{ page_id }}' in '{{ course_identifier }}' has just failed while a user was trying to get his or her code graded. Details of the problem are below: {{ error_message }} {% endblocktrans %} + +{% if review_uri %} +{% trans "You can navigate to the following url to check the problem:" %} +---------------- +{{ review_uri }} +---------------- +{% endif %} + - {% trans "RELATE" %}