From 76fbcbe437eebfbad113a4a2c72e0a2121df40fa Mon Sep 17 00:00:00 2001 From: Isaac Lee <124631592+ilee2u@users.noreply.github.com> Date: Tue, 18 Jun 2024 15:13:01 -0400 Subject: [PATCH] fix: also filter for show_dashboard for instructor (#34949) * fix: also filter for show_dashboard for instructor * temp: attempting to craft tests * chore: lint * test: fixed xblock tests --- cms/djangoapps/contentstore/proctoring.py | 1 - .../contentstore/views/tests/test_block.py | 41 +++++++++++++++++++ .../xblock_storage_handlers/view_handlers.py | 2 +- .../instructor/views/instructor_dashboard.py | 10 +++-- 4 files changed, 49 insertions(+), 5 deletions(-) diff --git a/cms/djangoapps/contentstore/proctoring.py b/cms/djangoapps/contentstore/proctoring.py index 9b289bb9fee7..bd33049006c4 100644 --- a/cms/djangoapps/contentstore/proctoring.py +++ b/cms/djangoapps/contentstore/proctoring.py @@ -100,7 +100,6 @@ def register_special_exams(course_key): except ProctoredExamNotFoundException: exam_metadata['course_id'] = str(course_key) exam_metadata['content_id'] = str(timed_exam.location) - exam_id = create_exam(**exam_metadata) msg = f'Created new timed exam {exam_id}' log.info(msg) diff --git a/cms/djangoapps/contentstore/views/tests/test_block.py b/cms/djangoapps/contentstore/views/tests/test_block.py index a41f902524bc..2e8f60c01150 100644 --- a/cms/djangoapps/contentstore/views/tests/test_block.py +++ b/cms/djangoapps/contentstore/views/tests/test_block.py @@ -3665,6 +3665,47 @@ def test_special_exam_xblock_info( self.course.id, xblock_info["id"] ) + @patch_get_exam_configuration_dashboard_url + @patch_does_backend_support_onboarding + @patch_get_exam_by_content_id_success + @ddt.data( + ("lti_external", False), + ("other_proctoring_backend", True), + ) + @ddt.unpack + def test_support_onboarding_is_correct_depending_on_lti_external( + self, + external_id, + expected_value, + mock_get_exam_by_content_id, + mock_does_backend_support_onboarding, + _mock_get_exam_configuration_dashboard_url, + ): + sequential = BlockFactory.create( + parent_location=self.chapter.location, + category="sequential", + display_name="Test Lesson 1", + user_id=self.user.id, + is_proctored_enabled=False, + is_time_limited=False, + is_onboarding_exam=False, + ) + + # set course.proctoring_provider to lti_external + self.course.proctoring_provider = external_id + mock_get_exam_by_content_id.return_value = {"external_id": external_id} + + # mock_does_backend_support_onboarding returns True + mock_does_backend_support_onboarding.return_value = True + sequential = modulestore().get_item(sequential.location) + xblock_info = create_xblock_info( + sequential, + include_child_info=True, + include_children_predicate=ALWAYS, + course=self.course, + ) + assert xblock_info["supports_onboarding"] is expected_value + @patch_get_exam_configuration_dashboard_url @patch_does_backend_support_onboarding @patch_get_exam_by_content_id_success diff --git a/cms/djangoapps/contentstore/xblock_storage_handlers/view_handlers.py b/cms/djangoapps/contentstore/xblock_storage_handlers/view_handlers.py index 2be43c7911de..6959e22b94dc 100644 --- a/cms/djangoapps/contentstore/xblock_storage_handlers/view_handlers.py +++ b/cms/djangoapps/contentstore/xblock_storage_handlers/view_handlers.py @@ -1146,7 +1146,7 @@ def create_xblock_info( # lint-amnesty, pylint: disable=too-many-statements "online_proctoring_rules", "" ) - # Only call does_backend_support_onboarding if not using an LTI proctoring provider + # Only call does_backend_support_onboarding if not using an LTI proctoring provider if course.proctoring_provider != 'lti_external': supports_onboarding = does_backend_support_onboarding( course.proctoring_provider diff --git a/lms/djangoapps/instructor/views/instructor_dashboard.py b/lms/djangoapps/instructor/views/instructor_dashboard.py index a068ffdf1c9d..b6057f819452 100644 --- a/lms/djangoapps/instructor/views/instructor_dashboard.py +++ b/lms/djangoapps/instructor/views/instructor_dashboard.py @@ -302,16 +302,20 @@ def _section_special_exams(course, access): proctoring_provider = course.proctoring_provider escalation_email = None mfe_view_url = None + show_dashboard = None if proctoring_provider == 'lti_external': mfe_view_url = f'{settings.EXAMS_DASHBOARD_MICROFRONTEND_URL}/course/{course_key}/exams/embed' # NOTE: LTI proctoring doesn't support onboarding. If that changes, this value should change to True. show_onboarding = False + # Dashboard should always appear with LTI proctoring + show_dashboard = True else: - # Only call does_backend_support_onboarding if not using an LTI proctoring provider + # Only call does_backend_support_onboarding if not using an LTI proctoring provider show_onboarding = does_backend_support_onboarding(course.proctoring_provider) if proctoring_provider == 'proctortrack': escalation_email = course.proctoring_escalation_email - from edx_proctoring.api import is_backend_dashboard_available + from edx_proctoring.api import is_backend_dashboard_available + show_dashboard = is_backend_dashboard_available(course_key) section_data = { 'section_key': 'special_exams', @@ -319,7 +323,7 @@ def _section_special_exams(course, access): 'access': access, 'course_id': course_key, 'escalation_email': escalation_email, - 'show_dashboard': is_backend_dashboard_available(course_key), + 'show_dashboard': show_dashboard, 'show_onboarding': show_onboarding, 'mfe_view_url': mfe_view_url, }