From 41c27e8cbde0c215ef867bf5af6b679ece29d040 Mon Sep 17 00:00:00 2001 From: Zachary Hancock Date: Tue, 20 Jun 2023 10:21:43 -0400 Subject: [PATCH] Add exams dashboard MFE to instructor dash (#32493) * feat: use new exams mfe for lti enabled courses --- .../instructor/tests/test_proctoring.py | 21 ++++++++ .../instructor/views/instructor_dashboard.py | 4 ++ lms/envs/common.py | 4 ++ lms/envs/devstack.py | 1 + .../instructor_dashboard_2/special_exams.html | 54 ++++++++++--------- 5 files changed, 60 insertions(+), 24 deletions(-) diff --git a/lms/djangoapps/instructor/tests/test_proctoring.py b/lms/djangoapps/instructor/tests/test_proctoring.py index 42fdb13a7f..491a2ee1f7 100644 --- a/lms/djangoapps/instructor/tests/test_proctoring.py +++ b/lms/djangoapps/instructor/tests/test_proctoring.py @@ -180,6 +180,27 @@ class TestProctoringDashboardViews(SharedModuleStoreTestCase): self.instructor.save() self._assert_escalation_email_available(True) + @patch.dict( + settings.PROCTORING_BACKENDS, + { + 'DEFAULT': 'test_proctoring_provider', + 'test_proctoring_provider': {}, + 'lti_external': {} + }, + ) + @patch.dict(settings.FEATURES, {'ENABLE_PROCTORED_EXAMS': True}) + def test_lti_proctoring_dashboard(self): + """ + The exams dasboard MFE will be shown instead of the default special exams tab content + """ + self.setup_course_with_proctoring_backend('lti_external', 'foo@bar.com') + + self.instructor.is_staff = True + self.instructor.save() + response = self.client.get(self.url) + self.assertIn('proctoring-mfe-view', response.content.decode('utf-8')) + self.assertNotIn('proctoring-accordion', response.content.decode('utf-8')) + def test_review_dashboard(self): """ The exam review dashboard will appear for backends that support the feature diff --git a/lms/djangoapps/instructor/views/instructor_dashboard.py b/lms/djangoapps/instructor/views/instructor_dashboard.py index 579b8d035f..94b4175682 100644 --- a/lms/djangoapps/instructor/views/instructor_dashboard.py +++ b/lms/djangoapps/instructor/views/instructor_dashboard.py @@ -286,8 +286,11 @@ def _section_special_exams(course, access): course_key = str(course.id) proctoring_provider = course.proctoring_provider escalation_email = None + mfe_view_url = None if proctoring_provider == 'proctortrack': escalation_email = course.proctoring_escalation_email + elif proctoring_provider == 'lti_external': + mfe_view_url = f'{settings.EXAMS_DASHBOARD_MICROFRONTEND_URL}/course/{course_key}/exams/embed' from edx_proctoring.api import is_backend_dashboard_available section_data = { @@ -298,6 +301,7 @@ def _section_special_exams(course, access): 'escalation_email': escalation_email, 'show_dashboard': is_backend_dashboard_available(course_key), 'show_onboarding': does_backend_support_onboarding(course.proctoring_provider), + 'mfe_view_url': mfe_view_url, } return section_data diff --git a/lms/envs/common.py b/lms/envs/common.py index 13f71438e5..16382b6175 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -4963,6 +4963,10 @@ DISCUSSIONS_MICROFRONTEND_URL = None # .. setting_default: None # .. setting_description: Base URL of the discussions micro-frontend google form based feedback. DISCUSSIONS_MFE_FEEDBACK_URL = None +# .. setting_name: EXAMS_DASHBOARD_MICROFRONTEND_URL +# .. setting_default: None +# .. setting_description: Base URL of the exams dashboard micro-frontend for instructors. +EXAMS_DASHBOARD_MICROFRONTEND_URL = None # .. toggle_name: ENABLE_AUTHN_RESET_PASSWORD_HIBP_POLICY # .. toggle_implementation: DjangoSetting # .. toggle_default: False diff --git a/lms/envs/devstack.py b/lms/envs/devstack.py index ca65998e1d..88aba2fd9a 100644 --- a/lms/envs/devstack.py +++ b/lms/envs/devstack.py @@ -382,6 +382,7 @@ ACCOUNT_MICROFRONTEND_URL = 'http://localhost:1997' COMMUNICATIONS_MICROFRONTEND_URL = 'http://localhost:1984' AUTHN_MICROFRONTEND_URL = 'http://localhost:1999' AUTHN_MICROFRONTEND_DOMAIN = 'localhost:1999' +EXAMS_DATE_MICROFRONTEND_URL = 'http://localhost:2020' ################### FRONTEND APPLICATION DISCUSSIONS ################### DISCUSSIONS_MICROFRONTEND_URL = 'http://localhost:2002' diff --git a/lms/templates/instructor/instructor_dashboard_2/special_exams.html b/lms/templates/instructor/instructor_dashboard_2/special_exams.html index 2b568cd78e..b00a55aae5 100644 --- a/lms/templates/instructor/instructor_dashboard_2/special_exams.html +++ b/lms/templates/instructor/instructor_dashboard_2/special_exams.html @@ -5,29 +5,35 @@ from datetime import datetime, timedelta import pytz %>
- % if section_data.get('escalation_email'): -
${_('Proctortrack Escalation Email:')} ${ section_data['escalation_email'] }
- % endif -
-
-

${_('Allowance Section')}

-
-
- % if section_data['show_onboarding']: -
-

${_('Student Onboarding Status')}

-
-
- % endif -
-

${_('Student Special Exam Attempts')}

-
-
- % if section_data['show_dashboard']: -
-

${_('Review Dashboard')}

-
-
- % endif + % if section_data.get('mfe_view_url'): +
+
+ % else: + % if section_data.get('escalation_email'): +
${_('Proctortrack Escalation Email:')} ${ section_data['escalation_email'] }
+ % endif +
+
+

${_('Allowance Section')}

+
+
+ % if section_data['show_onboarding']: +
+

${_('Student Onboarding Status')}

+
+
+ % endif +
+

${_('Student Special Exam Attempts')}

+
+
+ % if section_data['show_dashboard']: +
+

${_('Review Dashboard')}

+
+
+ % endif +
+ % endif