Skip to content

Commit

Permalink
feat: update deprecated course URL (#1059)
Browse files Browse the repository at this point in the history
* feat: update deprecated course URL to mfe

* chore: release tasks
  • Loading branch information
zacharis278 authored Jun 29, 2022
1 parent 60b3d61 commit 644ce9e
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 20 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ Unreleased
~~~~~~~~~~
* Improved ``developing.rst`` docs for installing and running the mockprock proctoring provider.

[4.10.1] - 2022-04-06
[4.10.3] - 2022-04-06
~~~~~~~~~~~~~~~~~~~~~
* Fixed invalid course url in proctored attempt email

[4.10.2] - 2022-04-06
~~~~~~~~~~~~~~~~~~~~~
* Enabled Django40 testing
* Removed Deprecated and Removed Featured from Django40
Expand Down
2 changes: 1 addition & 1 deletion edx_proctoring/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"""

# Be sure to update the version number in edx_proctoring/package.json
__version__ = '4.10.2'
__version__ = '4.10.3'

default_app_config = 'edx_proctoring.apps.EdxProctoringConfig' # pylint: disable=invalid-name
20 changes: 4 additions & 16 deletions edx_proctoring/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
from edx_proctoring.utils import (
categorize_inaccessible_exams_by_date,
emit_event,
get_course_home_url,
get_exam_due_date,
get_exam_type,
get_exam_url,
Expand Down Expand Up @@ -1729,7 +1730,6 @@ def create_proctoring_attempt_status_email(user_id, exam_attempt_obj, course_nam
return None

user = USER_MODEL.objects.get(id=user_id)
course_info_url = ''
email_subject = (
_('Proctoring Results For {course_name} {exam_name}').format(
course_name=course_name,
Expand All @@ -1755,28 +1755,16 @@ def create_proctoring_attempt_status_email(user_id, exam_attempt_obj, course_nam

backend = exam_attempt_obj.proctored_exam.backend
email_template = loader.select_template(_get_email_template_paths(template_name, backend))
try:
course_info_url = reverse('info', args=[exam_attempt_obj.proctored_exam.course_id])
except NoReverseMatch:
log.exception(
('Attempted to create proctoring status email for user_id=%(user_id)s in exam_id=%(exam_id)s, '
'but could not find course info url for course_id=%(course_id)s'),
{
'user_id': user_id,
'exam_id': exam_attempt_obj.proctored_exam.id,
'course_id': course_id,
}
)
course_home_url = get_course_home_url(exam_attempt_obj.proctored_exam.course_id)

scheme = 'https' if getattr(settings, 'HTTPS', 'on') == 'on' else 'http'
course_url = f'{scheme}://{constants.SITE_NAME}{course_info_url}'
exam_name = exam_attempt_obj.proctored_exam.exam_name
support_email_subject = _('Proctored exam {exam_name} in {course_name} for user {username}').format(
exam_name=exam_name,
course_name=course_name,
username=user.username,
)

scheme = 'https' if getattr(settings, 'HTTPS', 'on') == 'on' else 'http'
default_contact_url = f'{scheme}://{constants.SITE_NAME}/support/contact_us'

# If the course has a proctoring escalation email set, use that rather than edX Support.
Expand All @@ -1792,7 +1780,7 @@ def create_proctoring_attempt_status_email(user_id, exam_attempt_obj, course_nam

body = email_template.render({
'username': user.username,
'course_url': course_url,
'course_url': course_home_url,
'course_name': course_name,
'exam_name': exam_name,
'status': status,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def setUp(self):
set_runtime_service('certificates', MockCertificateService())
set_runtime_service('instructor', MockInstructorService())
self.exam_id = create_exam(
course_id='foo',
course_id='a/b/c',
content_id='bar',
exam_name='Test Exam',
time_limit_mins=90)
Expand Down
7 changes: 7 additions & 0 deletions edx_proctoring/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,13 @@ def resolve_exam_url_for_learning_mfe(course_id, content_id):
return url


def get_course_home_url(course_id):
""" Helper that builds the course home url """
course_key = CourseKey.from_string(course_id)
url = f'{settings.LEARNING_MICROFRONTEND_URL}/course/{course_key}/home'
return url


def get_exam_url(course_id, content_id, is_learning_mfe):
""" Helper to build exam url depending if it is requested for the learning MFE app or not. """
if is_learning_mfe:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@edx/edx-proctoring",
"//": "Note that the version format is slightly different than that of the Python version when using prereleases.",
"version": "4.10.2",
"version": "4.10.3",
"main": "edx_proctoring/static/index.js",
"scripts": {
"test": "gulp test"
Expand Down
2 changes: 2 additions & 0 deletions test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
SITE_ID = 1
SITE_NAME = 'localhost:8000'

LEARNING_MICROFRONTEND_URL = 'https://learning.test.org'

INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
Expand Down

0 comments on commit 644ce9e

Please sign in to comment.