-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change use of get_active_enrollments_by_course method of the LMS Enro…
…llments service to get_enrollments_can_take_proctored_exams, which is more performant. This shifts the responsibility of checking learners' ability to access proctored exams to the LMS, allowing the LMS to construst a bulk query for all learners in a course with active enrollments instead of needing to execute multiple queries on a per learner basis.
- Loading branch information
1 parent
34f03ad
commit 8d8f920
Showing
8 changed files
with
31 additions
and
221 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -855,182 +855,6 @@ def test_pagination_maintains_query_params(self): | |
self.assertIn(text_search_string, next_url) | ||
self.assertIn(statuses_filter_string, next_url) | ||
|
||
def test_partial_text_search_username(self): | ||
response = self.client.get(reverse( | ||
'edx_proctoring:user_onboarding.status.course', | ||
kwargs={'course_id': self.onboarding_exam.course_id} | ||
), | ||
{ | ||
'text_search': 'use', | ||
} | ||
) | ||
response_data = json.loads(response.content.decode('utf-8')) | ||
|
||
expected_data = { | ||
'results': [ | ||
{ | ||
'username': self.learner_1.username, | ||
'status': InstructorDashboardOnboardingAttemptStatus.not_started, | ||
'modified': None, | ||
}, | ||
{ | ||
'username': self.learner_2.username, | ||
'status': InstructorDashboardOnboardingAttemptStatus.not_started, | ||
'modified': None, | ||
} | ||
], | ||
'count': 2, | ||
'previous': None, | ||
'next': None, | ||
'num_pages': 1, | ||
} | ||
|
||
self.assertEqual(response.status_code, 200) | ||
self.assertEqual(response_data, expected_data) | ||
|
||
def test_partial_text_search_email(self): | ||
response = self.client.get(reverse( | ||
'edx_proctoring:user_onboarding.status.course', | ||
kwargs={'course_id': self.onboarding_exam.course_id} | ||
), | ||
{ | ||
'text_search': 'learner', | ||
} | ||
) | ||
response_data = json.loads(response.content.decode('utf-8')) | ||
|
||
expected_data = { | ||
'results': [ | ||
{ | ||
'username': self.learner_1.username, | ||
'status': InstructorDashboardOnboardingAttemptStatus.not_started, | ||
'modified': None, | ||
}, | ||
{ | ||
'username': self.learner_2.username, | ||
'status': InstructorDashboardOnboardingAttemptStatus.not_started, | ||
'modified': None, | ||
} | ||
], | ||
'count': 2, | ||
'previous': None, | ||
'next': None, | ||
'num_pages': 1, | ||
} | ||
|
||
self.assertEqual(response.status_code, 200) | ||
self.assertEqual(response_data, expected_data) | ||
|
||
def test_full_text_search_email(self): | ||
response = self.client.get(reverse( | ||
'edx_proctoring:user_onboarding.status.course', | ||
kwargs={'course_id': self.onboarding_exam.course_id} | ||
), | ||
{ | ||
'text_search': '[email protected]', | ||
} | ||
) | ||
response_data = json.loads(response.content.decode('utf-8')) | ||
|
||
expected_data = { | ||
'results': [ | ||
{ | ||
'username': self.learner_1.username, | ||
'status': InstructorDashboardOnboardingAttemptStatus.not_started, | ||
'modified': None, | ||
}, | ||
], | ||
'count': 1, | ||
'previous': None, | ||
'next': None, | ||
'num_pages': 1, | ||
} | ||
|
||
self.assertEqual(response.status_code, 200) | ||
self.assertEqual(response_data, expected_data) | ||
|
||
def test_full_text_search_username(self): | ||
response = self.client.get(reverse( | ||
'edx_proctoring:user_onboarding.status.course', | ||
kwargs={'course_id': self.onboarding_exam.course_id} | ||
), | ||
{ | ||
'text_search': 'user1', | ||
} | ||
) | ||
response_data = json.loads(response.content.decode('utf-8')) | ||
|
||
expected_data = { | ||
'results': [ | ||
{ | ||
'username': self.learner_1.username, | ||
'status': InstructorDashboardOnboardingAttemptStatus.not_started, | ||
'modified': None, | ||
}, | ||
], | ||
'count': 1, | ||
'previous': None, | ||
'next': None, | ||
'num_pages': 1, | ||
} | ||
|
||
self.assertEqual(response.status_code, 200) | ||
self.assertEqual(response_data, expected_data) | ||
|
||
@ddt.data( | ||
'USER1', | ||
'LeaRner_1', | ||
) | ||
def test_text_search_case_insensitivity(self, text_search): | ||
response = self.client.get(reverse( | ||
'edx_proctoring:user_onboarding.status.course', | ||
kwargs={'course_id': self.onboarding_exam.course_id} | ||
), | ||
{ | ||
'text_search': text_search, | ||
} | ||
) | ||
response_data = json.loads(response.content.decode('utf-8')) | ||
|
||
expected_data = { | ||
'results': [ | ||
{ | ||
'username': self.learner_1.username, | ||
'status': InstructorDashboardOnboardingAttemptStatus.not_started, | ||
'modified': None, | ||
}, | ||
], | ||
'count': 1, | ||
'previous': None, | ||
'next': None, | ||
'num_pages': 1, | ||
} | ||
|
||
self.assertEqual(response.status_code, 200) | ||
self.assertEqual(response_data, expected_data) | ||
|
||
def test_text_search_no_results(self): | ||
response = self.client.get(reverse( | ||
'edx_proctoring:user_onboarding.status.course', | ||
kwargs={'course_id': self.onboarding_exam.course_id} | ||
), | ||
{ | ||
'text_search': 'abc', | ||
} | ||
) | ||
response_data = json.loads(response.content.decode('utf-8')) | ||
|
||
expected_data = { | ||
'results': [], | ||
'count': 0, | ||
'previous': None, | ||
'next': None, | ||
'num_pages': 1, | ||
} | ||
|
||
self.assertEqual(response.status_code, 200) | ||
self.assertEqual(response_data, expected_data) | ||
|
||
def test_one_status_filter(self): | ||
first_attempt_id = create_exam_attempt(self.onboarding_exam.id, self.user.id, True) | ||
second_attempt_id = create_exam_attempt(self.onboarding_exam.id, self.learner_1.id, True) | ||
|
@@ -1262,9 +1086,10 @@ def test_multiple_exam_attempts(self): | |
self.assertEqual(response.status_code, 200) | ||
self.assertEqual(response_data, expected_data) | ||
|
||
def test_ineligible_for_exam(self): | ||
with mock_perm('edx_proctoring.can_take_proctored_exam'): | ||
response = self.client.get(reverse( | ||
def test_no_enrollments(self): | ||
set_runtime_service('enrollments', MockEnrollmentsService([])) | ||
|
||
response = self.client.get(reverse( | ||
'edx_proctoring:user_onboarding.status.course', | ||
kwargs={'course_id': self.onboarding_exam.course_id} | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters