Skip to content

Commit

Permalink
fix: remove username and change the subject in emails
Browse files Browse the repository at this point in the history
Description: Remove username and change the subject in emails
VAN-1865
  • Loading branch information
ahtesham-quraish committed Mar 14, 2024
1 parent df957ae commit 5b88ccb
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 18 deletions.
12 changes: 4 additions & 8 deletions edx_proctoring/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1748,16 +1748,13 @@ def create_proctoring_attempt_status_email(user_id, exam_attempt_obj, course_nam
status = exam_attempt_obj.status
if status == ProctoredExamStudentAttemptStatus.submitted:
template_name = 'proctoring_attempt_submitted_email.html'
email_subject = (
_('Proctoring Review In Progress For {course_name} {exam_name}').format(
course_name=course_name,
exam_name=exam_attempt_obj.proctored_exam.exam_name
)
)
email_subject = 'Proctoring attempt submitted'
elif status == ProctoredExamStudentAttemptStatus.verified:
template_name = 'proctoring_attempt_satisfactory_email.html'
email_subject = 'Proctoring attempt verified'
elif status == ProctoredExamStudentAttemptStatus.rejected:
template_name = 'proctoring_attempt_unsatisfactory_email.html'
email_subject = 'Proctoring attempt rejected'
else:
# Don't send an email for any other attempt status codes
return None
Expand All @@ -1767,7 +1764,7 @@ def create_proctoring_attempt_status_email(user_id, exam_attempt_obj, course_nam
course_home_url = get_course_home_url(exam_attempt_obj.proctored_exam.course_id)

exam_name = exam_attempt_obj.proctored_exam.exam_name
support_email_subject = _('Proctored exam {exam_name} in {course_name} for user {username}').format(
support_email_subject = _('Proctored exam {exam_name} in {course_name}').format(
exam_name=exam_name,
course_name=course_name,
username=user.username,
Expand All @@ -1788,7 +1785,6 @@ def create_proctoring_attempt_status_email(user_id, exam_attempt_obj, course_nam
contact_url_text = contact_url

body = email_template.render({
'username': user.username,
'course_url': course_home_url,
'course_name': course_name,
'exam_name': exam_name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<p>
{% block introduction %}
{% blocktrans %}
Hello {{ username }},
Hello,
{% endblocktrans %}
{% endblock %}
</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<p>
{% block introduction %}
{% blocktrans %}
Hello {{ username }},
Hello,
{% endblocktrans %}
{% endblock %}
</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<p>
{% block introduction %}
{% blocktrans %}
Hello {{ username }},
Hello,
{% endblocktrans %}
{% endblock %}
</p>
Expand Down
12 changes: 5 additions & 7 deletions edx_proctoring/tests/test_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,17 @@ def tearDown(self):
@ddt.data(
[
ProctoredExamStudentAttemptStatus.submitted,
'Proctoring Review In Progress',
'Proctoring attempt submitted',
'was submitted successfully',
],
[
ProctoredExamStudentAttemptStatus.verified,
'Proctoring Results',
'Proctoring attempt verified',
'was reviewed and you met all proctoring requirements',
],
[
ProctoredExamStudentAttemptStatus.rejected,
'Proctoring Results',
'Proctoring attempt rejected',
'the course team has identified one or more violations',
]
)
Expand All @@ -84,11 +84,10 @@ def test_send_email(self, status, expected_subject, expected_message_string):
# Verify the subject
actual_subject = self._normalize_whitespace(mail.outbox[0].subject)
self.assertIn(expected_subject, actual_subject)
self.assertIn(self.exam_name, actual_subject)

# Verify the body
actual_body = self._normalize_whitespace(mail.outbox[0].body)
self.assertIn('Hello tester,', actual_body)
self.assertIn('Hello,', actual_body)
self.assertIn('Your proctored exam "Test Exam"', actual_body)
self.assertIn(credit_state['course_name'], actual_body)
self.assertIn(expected_message_string, actual_body)
Expand Down Expand Up @@ -223,8 +222,7 @@ def test_send_email_unicode(self):

# Verify the subject
actual_subject = self._normalize_whitespace(mail.outbox[0].subject)
self.assertIn('Proctoring Review In Progress', actual_subject)
self.assertIn(course_name, actual_subject)
self.assertIn('Proctoring attempt submitted', actual_subject)

# Verify the body
actual_body = self._normalize_whitespace(mail.outbox[0].body)
Expand Down

0 comments on commit 5b88ccb

Please sign in to comment.