From a86164d6e41f58ff17c3f9a7ac8076b469a787eb Mon Sep 17 00:00:00 2001 From: dzhuang Date: Wed, 25 Jan 2017 09:47:30 +0800 Subject: [PATCH] Adding more info in broken-code-question-email --- course/page/code.py | 20 +++++++++++++++++++ .../course/broken-code-question-email.txt | 9 +++++++++ 2 files changed, 29 insertions(+) diff --git a/course/page/code.py b/course/page/code.py index 9da3ea3d..a8cdaf70 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 bf87d3ad..d89cfd0d 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" %} -- GitLab