Commit 4cda8044 by Sanford Student

add cert available date to lms

for EDUCATOR-525
parent 4f25d1aa
......@@ -15,7 +15,8 @@ from courseware.date_summary import (
CourseStartDate,
TodaysDate,
VerificationDeadlineDate,
VerifiedUpgradeDeadlineDate
VerifiedUpgradeDeadlineDate,
CertificateAvailableDate
)
from courseware.model_data import FieldDataCache
from courseware.module_render import get_module
......@@ -367,6 +368,7 @@ def get_course_date_blocks(course, user):
sorted by date.
"""
block_classes = (
CertificateAvailableDate,
CourseEndDate,
CourseStartDate,
TodaysDate,
......
......@@ -16,6 +16,7 @@ from pytz import timezone, utc
from course_modes.models import CourseMode
from lms.djangoapps.commerce.utils import EcommerceService
from lms.djangoapps.verify_student.models import SoftwareSecurePhotoVerification, VerificationDeadline
from openedx.core.djangoapps.certificates.config import waffle
from student.models import CourseEnrollment
......@@ -195,6 +196,28 @@ class CourseEndDate(DateSummary):
return self.course.end
class CertificateAvailableDate(DateSummary):
"""
Displays the end date of the course.
"""
css_class = 'certificate-available-date'
title = ugettext_lazy('Certificate Available')
@property
def is_enabled(self):
return self.date is not None and datetime.datetime.now(utc) <= self.date and waffle.waffle().is_enabled(
waffle.INSTRUCTOR_PACED_ONLY
)
@property
def description(self):
return _('Day certificates will become available for passing verified learners.')
@property
def date(self):
return self.course.certificate_available_date
class VerifiedUpgradeDeadlineDate(DateSummary):
"""
Displays the date before which learners must upgrade to the
......
......@@ -18,7 +18,8 @@ from courseware.date_summary import (
CourseStartDate,
TodaysDate,
VerificationDeadlineDate,
VerifiedUpgradeDeadlineDate
VerifiedUpgradeDeadlineDate,
CertificateAvailableDate
)
from courseware.models import DynamicUpgradeDeadlineConfiguration, CourseDynamicUpgradeDeadlineConfiguration
from lms.djangoapps.verify_student.models import VerificationDeadline
......@@ -351,6 +352,31 @@ class CourseDateSummaryTest(SharedModuleStoreTestCase):
block = VerifiedUpgradeDeadlineDate(course, user)
self.assertEqual(block.link, '{}?sku={}'.format(configuration.MULTIPLE_ITEMS_BASKET_PAGE_URL, sku))
## CertificateAvailableDate
@waffle.testutils.override_switch('certificates.instructor_paced_only', True)
def test_no_certificate_available_date(self):
course = self.create_course_run(days_till_start=-1)
user = self.create_user()
CourseEnrollmentFactory(course_id=course.id, user=user, mode=CourseMode.AUDIT)
block = CertificateAvailableDate(course, user)
self.assertEqual(block.date, None)
self.assertFalse(block.is_enabled)
@waffle.testutils.override_switch('certificates.instructor_paced_only', True)
def test_certificate_available_date_defined(self):
course = self.create_course_run()
audit_user = self.create_user()
CourseEnrollmentFactory(course_id=course.id, user=audit_user, mode=CourseMode.AUDIT)
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.save()
CertificateAvailableDate(course, audit_user)
for block in (CertificateAvailableDate(course, audit_user), CertificateAvailableDate(course, verified_user)):
self.assertIsNotNone(course.certificate_available_date)
self.assertEqual(block.date, course.certificate_available_date)
self.assertTrue(block.is_enabled)
## VerificationDeadlineDate
def test_no_verification_deadline(self):
course = self.create_course_run(days_till_start=-1, days_till_verification_deadline=None)
......
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