diff --git a/lms/djangoapps/ccx/tests/test_field_override_performance.py b/lms/djangoapps/ccx/tests/test_field_override_performance.py index d978f8626e..82f8f3467f 100644 --- a/lms/djangoapps/ccx/tests/test_field_override_performance.py +++ b/lms/djangoapps/ccx/tests/test_field_override_performance.py @@ -231,21 +231,21 @@ class TestFieldOverrideMongoPerformance(FieldOverridePerformanceTestCase): # # of mongo queries, # # of xblocks # ) - ('no_overrides', 1, True, False): (48, 1, 6, 13), - ('no_overrides', 2, True, False): (120, 16, 6, 84), - ('no_overrides', 3, True, False): (400, 81, 6, 335), - ('ccx', 1, True, False): (48, 1, 6, 13), - ('ccx', 2, True, False): (120, 16, 6, 84), - ('ccx', 3, True, False): (400, 81, 6, 335), + ('no_overrides', 1, True, False): (47, 1, 6, 13), + ('no_overrides', 2, True, False): (119, 16, 6, 84), + ('no_overrides', 3, True, False): (399, 81, 6, 335), + ('ccx', 1, True, False): (47, 1, 6, 13), + ('ccx', 2, True, False): (119, 16, 6, 84), + ('ccx', 3, True, False): (399, 81, 6, 335), ('ccx', 1, True, True): (47, 1, 6, 13), ('ccx', 2, True, True): (119, 16, 6, 84), ('ccx', 3, True, True): (399, 81, 6, 335), - ('no_overrides', 1, False, False): (48, 1, 6, 13), - ('no_overrides', 2, False, False): (120, 16, 6, 84), - ('no_overrides', 3, False, False): (400, 81, 6, 335), - ('ccx', 1, False, False): (48, 1, 6, 13), - ('ccx', 2, False, False): (120, 16, 6, 84), - ('ccx', 3, False, False): (400, 81, 6, 335), + ('no_overrides', 1, False, False): (47, 1, 6, 13), + ('no_overrides', 2, False, False): (119, 16, 6, 84), + ('no_overrides', 3, False, False): (399, 81, 6, 335), + ('ccx', 1, False, False): (47, 1, 6, 13), + ('ccx', 2, False, False): (119, 16, 6, 84), + ('ccx', 3, False, False): (399, 81, 6, 335), ('ccx', 1, False, True): (47, 1, 6, 13), ('ccx', 2, False, True): (119, 16, 6, 84), ('ccx', 3, False, True): (399, 81, 6, 335), @@ -260,22 +260,22 @@ class TestFieldOverrideSplitPerformance(FieldOverridePerformanceTestCase): __test__ = True TEST_DATA = { - ('no_overrides', 1, True, False): (48, 1, 4, 9), - ('no_overrides', 2, True, False): (120, 16, 19, 54), - ('no_overrides', 3, True, False): (400, 81, 84, 215), - ('ccx', 1, True, False): (48, 1, 4, 9), - ('ccx', 2, True, False): (120, 16, 19, 54), - ('ccx', 3, True, False): (400, 81, 84, 215), - ('ccx', 1, True, True): (50, 1, 4, 13), - ('ccx', 2, True, True): (122, 16, 19, 84), - ('ccx', 3, True, True): (402, 81, 84, 335), - ('no_overrides', 1, False, False): (48, 1, 4, 9), - ('no_overrides', 2, False, False): (120, 16, 19, 54), - ('no_overrides', 3, False, False): (400, 81, 84, 215), - ('ccx', 1, False, False): (48, 1, 4, 9), - ('ccx', 2, False, False): (120, 16, 19, 54), - ('ccx', 3, False, False): (400, 81, 84, 215), + ('no_overrides', 1, True, False): (47, 1, 4, 9), + ('no_overrides', 2, True, False): (119, 16, 19, 54), + ('no_overrides', 3, True, False): (399, 81, 84, 215), + ('ccx', 1, True, False): (47, 1, 4, 9), + ('ccx', 2, True, False): (119, 16, 19, 54), + ('ccx', 3, True, False): (399, 81, 84, 215), + ('ccx', 1, True, True): (49, 1, 4, 13), + ('ccx', 2, True, True): (121, 16, 19, 84), + ('ccx', 3, True, True): (401, 81, 84, 335), + ('no_overrides', 1, False, False): (47, 1, 4, 9), + ('no_overrides', 2, False, False): (119, 16, 19, 54), + ('no_overrides', 3, False, False): (399, 81, 84, 215), + ('ccx', 1, False, False): (47, 1, 4, 9), + ('ccx', 2, False, False): (119, 16, 19, 54), + ('ccx', 3, False, False): (399, 81, 84, 215), ('ccx', 1, False, True): (47, 1, 4, 9), ('ccx', 2, False, True): (119, 16, 19, 54), - ('ccx', 3, False, True): (400, 81, 84, 215), + ('ccx', 3, False, True): (399, 81, 84, 215), } diff --git a/lms/djangoapps/courseware/tests/test_views.py b/lms/djangoapps/courseware/tests/test_views.py index 4b99466781..b944ea9ee2 100644 --- a/lms/djangoapps/courseware/tests/test_views.py +++ b/lms/djangoapps/courseware/tests/test_views.py @@ -1368,7 +1368,7 @@ class ProgressPageTests(ModuleStoreTestCase): self.assertContains(resp, u"Download Your Certificate") @ddt.data( - *itertools.product(((42, 4, True), (42, 4, False)), (True, False)) + *itertools.product(((41, 4, True), (41, 4, False)), (True, False)) ) @ddt.unpack def test_query_counts(self, (sql_calls, mongo_calls, self_paced), self_paced_enabled): @@ -1406,9 +1406,13 @@ class ProgressPageTests(ModuleStoreTestCase): ) as user_verify: user_verify.return_value = user_verified resp = views.progress(self.request, course_id=unicode(self.course.id)) + + cert_button_hidden = course_mode is CourseMode.AUDIT or \ + course_mode in CourseMode.VERIFIED_MODES and not user_verified + self.assertEqual( - course_mode is not CourseMode.AUDIT and user_verified, - 'Request Certificate' in resp.content) + cert_button_hidden, + 'Request Certificate' not in resp.content) @attr('shard_1') diff --git a/lms/djangoapps/courseware/views/views.py b/lms/djangoapps/courseware/views/views.py index 63c0bc2057..5a78c268e1 100644 --- a/lms/djangoapps/courseware/views/views.py +++ b/lms/djangoapps/courseware/views/views.py @@ -726,6 +726,12 @@ def _progress(request, course_key, student_id): # checking certificate generation configuration enrollment_mode, is_active = CourseEnrollment.enrollment_mode_for_user(student, course_key) + + # If the learner is in verified modes and the student did not have + # their ID verified, we need to show message to ask learner to verify their ID first + missing_required_verification = enrollment_mode in CourseMode.VERIFIED_MODES and \ + not SoftwareSecurePhotoVerification.user_is_verified(student) + show_generate_cert_btn = ( is_active and CourseMode.is_eligible_for_certificate(enrollment_mode) and certs_api.cert_generation_enabled(course_key) @@ -741,7 +747,7 @@ def _progress(request, course_key, student_id): 'passed': is_course_passed(course, grade_summary), 'show_generate_cert_btn': show_generate_cert_btn, 'credit_course_requirements': _credit_course_requirements(course_key, student), - 'is_id_verified': SoftwareSecurePhotoVerification.user_is_verified(student) + 'missing_required_verification': missing_required_verification } if show_generate_cert_btn: diff --git a/lms/templates/courseware/progress.html b/lms/templates/courseware/progress.html index 2e63897888..503858e5e9 100644 --- a/lms/templates/courseware/progress.html +++ b/lms/templates/courseware/progress.html @@ -80,7 +80,10 @@ from django.utils.http import urlquote_plus

${_("We're creating your certificate. You can keep working in your courses and a link to it will appear here and on your Dashboard when it is ready.")}

- %elif not is_id_verified or is_unverified: + %elif missing_required_verification or is_unverified: + ## The is_unverified variable comes from certificate status. + ## At the moment, the assumption is we should not show generate certificate button + ## if the certificate previously generated is in unverified status
## Translators: This message appears to users when the users have not completed identity verification.

${_("Certificate unavailable")}