Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add feature flag to disable honor mode certificates. #20648

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions common/djangoapps/course_modes/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -687,16 +687,18 @@ def min_course_price_for_currency(cls, course_id, currency):
def is_eligible_for_certificate(cls, mode_slug):
"""
Returns whether or not the given mode_slug is eligible for a
certificate. Currently all modes other than 'audit' and `honor`
grant a certificate. Note that audit enrollments which existed
prior to December 2015 *were* given certificates, so there will
be GeneratedCertificate records with mode='audit' which are
certificate. Currently all modes other than 'audit' grant a
certificate. Note that audit enrollments which existed prior
to December 2015 *were* given certificates, so there will be
GeneratedCertificate records with mode='audit' which are
eligible.
"""
if mode_slug == cls.AUDIT or mode_slug == cls.HONOR:
return False
ineligible_modes = [cls.AUDIT]

if settings.FEATURES['DISABLE_HONOR_CERTIFICATES']:
ineligible_modes.append(cls.HONOR)

return True
return mode_slug not in ineligible_modes

def to_tuple(self):
"""
Expand Down
23 changes: 15 additions & 8 deletions common/djangoapps/course_modes/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,17 +455,24 @@ def test_expiration_datetime_explicitly_set_to_none(self):
self.assertIsNone(verified_mode.expiration_datetime)

@ddt.data(
(CourseMode.AUDIT, False),
(CourseMode.HONOR, False),
(CourseMode.VERIFIED, True),
(CourseMode.CREDIT_MODE, True),
(CourseMode.PROFESSIONAL, True),
(CourseMode.NO_ID_PROFESSIONAL_MODE, True),
(False, CourseMode.AUDIT, False),
(False, CourseMode.HONOR, True),
(False, CourseMode.VERIFIED, True),
(False, CourseMode.CREDIT_MODE, True),
(False, CourseMode.PROFESSIONAL, True),
(False, CourseMode.NO_ID_PROFESSIONAL_MODE, True),
(True, CourseMode.AUDIT, False),
(True, CourseMode.HONOR, False),
(True, CourseMode.VERIFIED, True),
(True, CourseMode.CREDIT_MODE, True),
(True, CourseMode.PROFESSIONAL, True),
(True, CourseMode.NO_ID_PROFESSIONAL_MODE, True),
)
@ddt.unpack
def test_eligible_for_cert(self, mode_slug, expected_eligibility):
def test_eligible_for_cert(self, disable_honor_cert, mode_slug, expected_eligibility):
"""Verify that non-audit modes are eligible for a cert."""
self.assertEqual(CourseMode.is_eligible_for_certificate(mode_slug), expected_eligibility)
with override_settings(FEATURES={'DISABLE_HONOR_CERTIFICATES': disable_honor_cert}):
self.assertEqual(CourseMode.is_eligible_for_certificate(mode_slug), expected_eligibility)

@ddt.data(
(CourseMode.AUDIT, False),
Expand Down
Loading