Commit c2e10e56 by Awais Jibran Committed by GitHub

Merge pull request #15997 from edx/aj/audit-course-with-course-info

EDUCATOR-1333 - Auto-certs: Courses w/o certificates still display certificate issue date
parents 67a246ad b4d4041f
......@@ -214,6 +214,7 @@ class CertificateAvailableDate(DateSummary):
def is_enabled(self):
return (
can_show_certificate_available_date_field(self.course) and
self.has_certificate_modes and
self.date is not None and
datetime.datetime.now(utc) <= self.date and
len(self.active_certificates) > 0
......@@ -227,6 +228,14 @@ class CertificateAvailableDate(DateSummary):
def date(self):
return self.course.certificate_available_date
@property
def has_certificate_modes(self):
return any([
mode.slug for mode in CourseMode.modes_for_course(
course_id=self.course.id, include_expired=True
) if mode.slug != CourseMode.AUDIT
])
class VerifiedUpgradeDeadlineDate(DateSummary):
"""
......
......@@ -60,6 +60,17 @@ class CourseDateSummaryTest(SharedModuleStoreTestCase):
return user
def enable_course_certificates(self, course):
""" Enable course certificate configuration """
course.certificates = {
u'certificates': [{
u'course_title': u'Test',
u'name': u'',
u'is_active': True,
}]
}
course.save()
def test_course_info_feature_flag(self):
SelfPacedConfiguration(enable_course_home_improvements=False).save()
course = create_course_run()
......@@ -339,6 +350,30 @@ class CourseDateSummaryTest(SharedModuleStoreTestCase):
self.assertNotEqual(block.date, None)
self.assertFalse(block.is_enabled)
# @waffle.testutils.override_switch('certificates.instructor_paced_only', True)
def test_no_certificate_available_date_for_audit_course(self):
"""
Tests that Certificate Available Date is not visible in the course "Important Course Dates" section
if the course only has audit mode.
"""
course = create_course_run()
audit_user = self.create_user()
# Enroll learner in the audit mode and verify the course only has 1 mode (audit)
CourseEnrollmentFactory(course_id=course.id, user=audit_user, mode=CourseMode.AUDIT)
CourseMode.objects.get(course_id=course.id, mode_slug=CourseMode.VERIFIED).delete()
all_course_modes = CourseMode.modes_for_course(course.id)
self.assertEqual(len(all_course_modes), 1)
self.assertEqual(all_course_modes[0].slug, CourseMode.AUDIT)
course.certificate_available_date = datetime.now(utc) + timedelta(days=7)
course.save()
# Verify Certificate Available Date is not enabled for learner.
block = CertificateAvailableDate(course, audit_user)
self.assertFalse(block.is_enabled)
self.assertNotEqual(block.date, None)
@waffle.testutils.override_switch('certificates.instructor_paced_only', True)
def test_certificate_available_date_defined(self):
course = create_course_run()
......@@ -347,14 +382,7 @@ class CourseDateSummaryTest(SharedModuleStoreTestCase):
verified_user = self.create_user()
CourseEnrollmentFactory(course_id=course.id, user=verified_user, mode=CourseMode.VERIFIED)
course.certificate_available_date = datetime.now(utc) + timedelta(days=7)
course.certificates = {
u'certificates': [{
u'course_title': u'Test',
u'name': u'',
u'is_active': True,
}]
}
course.save()
self.enable_course_certificates(course)
CertificateAvailableDate(course, audit_user)
for block in (CertificateAvailableDate(course, audit_user), CertificateAvailableDate(course, verified_user)):
self.assertIsNotNone(course.certificate_available_date)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment