Certificate messages must be dependent on active web configurations

Progress page is showing certificate messages for those courses in
which certificates are not offered.To avoid it,a check is added on
the existence of active course configuration so that it should be
displayed only for courses offering certificates.

LEARNER-3325
This commit is contained in:
uzairr
2018-08-10 17:52:13 +05:00
parent 098af33faa
commit a1a9e8e140
3 changed files with 15 additions and 6 deletions

View File

@@ -26,6 +26,7 @@ from django.http import Http404, QueryDict
from enrollment.api import get_course_enrollment_details
from edxmako.shortcuts import render_to_string
from fs.errors import ResourceNotFound
from lms.djangoapps.certificates import api as certs_api
from lms.djangoapps.courseware.courseware_access_exception import CoursewareAccessException
from lms.djangoapps.courseware.exceptions import CourseAccessRedirect
from opaque_keys.edx.keys import UsageKey
@@ -370,14 +371,15 @@ def get_course_date_blocks(course, user):
Return the list of blocks to display on the course info page,
sorted by date.
"""
block_classes = (
CertificateAvailableDate,
block_classes = [
CourseEndDate,
CourseStartDate,
TodaysDate,
VerificationDeadlineDate,
VerifiedUpgradeDeadlineDate,
)
]
if certs_api.get_active_web_certificate(course):
block_classes.insert(0, CertificateAvailableDate)
blocks = (cls(course, user) for cls in block_classes)

View File

@@ -1326,6 +1326,7 @@ class ProgressPageTests(ProgressPageBaseTests):
resp = self._get_progress_page()
self.assertNotContains(resp, 'Request Certificate')
@patch('lms.djangoapps.certificates.api.get_active_web_certificate', PropertyMock(return_value=True))
@patch.dict('django.conf.settings.FEATURES', {'CERTIFICATES_HTML_VIEW': True})
def test_view_certificate_link(self):
"""
@@ -1389,9 +1390,10 @@ class ProgressPageTests(ProgressPageBaseTests):
resp = self._get_progress_page()
self.assertNotContains(resp, u"View Your Certificate")
self.assertNotContains(resp, u"You can now view your certificate")
self.assertContains(resp, "working on it...")
self.assertContains(resp, "creating your certificate")
self.assertContains(resp, "Your certificate is available")
self.assertContains(resp, "earned a certificate for this course.")
@patch('lms.djangoapps.certificates.api.get_active_web_certificate', PropertyMock(return_value=True))
@patch.dict('django.conf.settings.FEATURES', {'CERTIFICATES_HTML_VIEW': False})
def test_view_certificate_link_hidden(self):
"""
@@ -1458,6 +1460,7 @@ class ProgressPageTests(ProgressPageBaseTests):
), check_mongo_calls(1):
self._get_progress_page()
@patch('lms.djangoapps.certificates.api.get_active_web_certificate', PropertyMock(return_value=True))
@ddt.data(
*itertools.product(
(
@@ -1589,6 +1592,7 @@ class ProgressPageTests(ProgressPageBaseTests):
self.assertContains(resp, u"View Certificate")
self.assert_invalidate_certificate(generated_certificate)
@patch('lms.djangoapps.certificates.api.get_active_web_certificate', PropertyMock(return_value=True))
def test_page_with_invalidated_certificate_with_pdf(self):
"""
Verify that for pdf certs if certificate is marked as invalidated than
@@ -1613,6 +1617,7 @@ class ProgressPageTests(ProgressPageBaseTests):
self.assert_invalidate_certificate(generated_certificate)
@patch('courseware.views.views.is_course_passed', PropertyMock(return_value=True))
@patch('lms.djangoapps.certificates.api.get_active_web_certificate', PropertyMock(return_value=True))
def test_message_for_audit_mode(self):
""" Verify that message appears on progress page, if learner is enrolled
in audit mode.
@@ -1634,6 +1639,7 @@ class ProgressPageTests(ProgressPageBaseTests):
)
@patch('courseware.views.views.is_course_passed', PropertyMock(return_value=True))
@patch('lms.djangoapps.certificates.api.get_active_web_certificate', PropertyMock(return_value=True))
def test_message_for_honor_mode(self):
""" Verify that message appears on progress page, if learner is enrolled
in honor mode.

View File

@@ -993,8 +993,9 @@ def _progress(request, course_key, student_id):
'supports_preview_menu': True,
'student': student,
'credit_course_requirements': _credit_course_requirements(course_key, student),
'certificate_data': _get_cert_data(student, course, enrollment_mode, course_grade),
}
if certs_api.get_active_web_certificate(course):
context['certificate_data'] = _get_cert_data(student, course, enrollment_mode, course_grade)
context.update(
get_experiment_user_metadata_context(
course,