Skip to content

Commit

Permalink
fix: also filter for show_dashboard for instructor (#34949)
Browse files Browse the repository at this point in the history
* fix: also filter for show_dashboard for instructor

* temp: attempting to craft tests

* chore: lint

* test: fixed xblock tests
  • Loading branch information
ilee2u authored Jun 18, 2024
1 parent 6f17017 commit 76fbcbe
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 5 deletions.
1 change: 0 additions & 1 deletion cms/djangoapps/contentstore/proctoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
41 changes: 41 additions & 0 deletions cms/djangoapps/contentstore/views/tests/test_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 7 additions & 3 deletions lms/djangoapps/instructor/views/instructor_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,24 +302,28 @@ 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',
'section_display_name': _('Special Exams'),
'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,
}
Expand Down

0 comments on commit 76fbcbe

Please sign in to comment.