Merge pull request #11151 from edx/peter-fogg/disable-audit-cert-gen
[wip] Mark GeneratedCertificate records for audit mode as not eligible for a certificate.
This commit is contained in:
@@ -592,6 +592,18 @@ class CourseMode(models.Model):
|
||||
modes = cls.modes_for_course(course_id)
|
||||
return min(mode.min_price for mode in modes if mode.currency.lower() == currency.lower())
|
||||
|
||||
@classmethod
|
||||
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' 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' and
|
||||
eligible_for_certificate=True.
|
||||
"""
|
||||
return mode_slug != cls.AUDIT
|
||||
|
||||
def to_tuple(self):
|
||||
"""
|
||||
Takes a mode model and turns it into a model named tuple.
|
||||
|
||||
@@ -430,3 +430,16 @@ class CourseModeModelTest(TestCase):
|
||||
verified_mode.expiration_datetime = None
|
||||
self.assertFalse(verified_mode.expiration_datetime_is_explicit)
|
||||
self.assertIsNone(verified_mode.expiration_datetime)
|
||||
|
||||
@ddt.data(
|
||||
(CourseMode.AUDIT, False),
|
||||
(CourseMode.HONOR, True),
|
||||
(CourseMode.VERIFIED, True),
|
||||
(CourseMode.CREDIT_MODE, True),
|
||||
(CourseMode.PROFESSIONAL, True),
|
||||
(CourseMode.NO_ID_PROFESSIONAL_MODE, True),
|
||||
)
|
||||
@ddt.unpack
|
||||
def test_eligible_for_cert(self, 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)
|
||||
|
||||
@@ -97,7 +97,9 @@ class Command(BaseCommand):
|
||||
cert_grades = {
|
||||
cert.user.username: cert.grade
|
||||
for cert in list(
|
||||
GeneratedCertificate.objects.filter(course_id=course_key).prefetch_related('user')
|
||||
GeneratedCertificate.objects.filter( # pylint: disable=no-member
|
||||
course_id=course_key
|
||||
).prefetch_related('user')
|
||||
)
|
||||
}
|
||||
print "Grading students"
|
||||
|
||||
Reference in New Issue
Block a user