diff --git a/lms/djangoapps/certificates/models.py b/lms/djangoapps/certificates/models.py index cb7e578caf..09c53c69fb 100644 --- a/lms/djangoapps/certificates/models.py +++ b/lms/djangoapps/certificates/models.py @@ -570,12 +570,13 @@ def certificate_info_for_user(user, course_id, grade, user_is_whitelisted, user_ """ certificate_is_delivered = 'N' certificate_type = 'N/A' - eligible_for_certificate = 'Y' if (user_is_whitelisted or grade is not None) and user.profile.allow_certificate \ - else 'N' - status = certificate_status(user_certificate) - can_have_certificate = CourseOverview.get_from_id(course_id).may_certify() certificate_generated = status['status'] == CertificateStatuses.downloadable + can_have_certificate = CourseOverview.get_from_id(course_id).may_certify() + + eligible_for_certificate = 'Y' if (user_is_whitelisted or grade is not None or certificate_generated) \ + and user.profile.allow_certificate else 'N' + if certificate_generated and can_have_certificate: certificate_is_delivered = 'Y' certificate_type = status['mode'] diff --git a/lms/djangoapps/certificates/tests/tests.py b/lms/djangoapps/certificates/tests/tests.py index d472288838..6698153f99 100644 --- a/lms/djangoapps/certificates/tests/tests.py +++ b/lms/djangoapps/certificates/tests/tests.py @@ -90,7 +90,9 @@ class CertificatesModelTest(ModuleStoreTestCase, MilestonesTestCaseMixin): {'allow_certificate': True, 'whitelisted': True, 'grade': None, 'output': ['Y', 'Y', 'honor']}, {'allow_certificate': True, 'whitelisted': False, 'grade': 0.9, 'output': ['Y', 'Y', 'honor']}, {'allow_certificate': False, 'whitelisted': True, 'grade': 0.8, 'output': ['N', 'Y', 'honor']}, - {'allow_certificate': False, 'whitelisted': None, 'grade': 0.8, 'output': ['N', 'Y', 'honor']} + {'allow_certificate': False, 'whitelisted': None, 'grade': 0.8, 'output': ['N', 'Y', 'honor']}, + {'allow_certificate': True, 'whitelisted': None, 'grade': None, 'output': ['Y', 'Y', 'honor']}, + {'allow_certificate': False, 'whitelisted': True, 'grade': None, 'output': ['N', 'Y', 'honor']} ) def test_certificate_info_for_user_when_grade_changes(self, allow_certificate, whitelisted, grade, output): """