Skip to content

Commit

Permalink
Certificate messages must be dependent on active web configurations
Browse files Browse the repository at this point in the history
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
  • Loading branch information
uzairr committed Aug 16, 2018
1 parent 098af33 commit a1a9e8e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
8 changes: 5 additions & 3 deletions lms/djangoapps/courseware/courses.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
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
Expand Down Expand Up @@ -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)

Expand Down
10 changes: 8 additions & 2 deletions lms/djangoapps/courseware/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1326,6 +1326,7 @@ def test_generate_cert_config(self):
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):
"""
Expand Down Expand Up @@ -1389,9 +1390,10 @@ def test_view_certificate_link(self):
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):
"""
Expand Down Expand Up @@ -1458,6 +1460,7 @@ def test_progress_queries(self, enable_waffle, initial, subsequent):
), 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(
(
Expand Down Expand Up @@ -1589,6 +1592,7 @@ def test_page_with_whitelisted_certificate_with_html_view(self):
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
Expand All @@ -1613,6 +1617,7 @@ def test_page_with_invalidated_certificate_with_pdf(self):
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.
Expand All @@ -1634,6 +1639,7 @@ def test_message_for_audit_mode(self):
)

@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.
Expand Down
3 changes: 2 additions & 1 deletion lms/djangoapps/courseware/views/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit a1a9e8e

Please sign in to comment.