Merge pull request #8952 from edx/ziafazal/SOL-1045
SOL-1045: Enable certificate generation by students for self-paced courses
This commit is contained in:
@@ -7,6 +7,7 @@ import json
|
||||
from nose.plugins.attrib import attr
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.test.utils import override_settings
|
||||
from django.conf import settings
|
||||
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
|
||||
from xmodule.modulestore.tests.factories import CourseFactory
|
||||
from config_models.models import cache
|
||||
@@ -94,6 +95,22 @@ class CertificatesInstructorDashTest(ModuleStoreTestCase):
|
||||
certs_api.set_cert_generation_enabled(self.course.id, True)
|
||||
self._assert_enable_certs_button(False)
|
||||
|
||||
@mock.patch.dict(settings.FEATURES, {'CERTIFICATES_HTML_VIEW': True})
|
||||
def test_show_enabled_button_for_html_certs(self):
|
||||
"""
|
||||
Tests `Enable Student-Generated Certificates` button is enabled
|
||||
and `Generate Example Certificates` button is not available if
|
||||
course has Web/HTML certificates view enabled.
|
||||
"""
|
||||
self.course.cert_html_view_enabled = True
|
||||
self.course.save()
|
||||
self.store.update_item(self.course, self.global_staff.id) # pylint: disable=no-member
|
||||
self.client.login(username=self.global_staff.username, password="test")
|
||||
response = self.client.get(self.url)
|
||||
self.assertContains(response, 'Enable Student-Generated Certificates')
|
||||
self.assertContains(response, 'enable-certificates-submit')
|
||||
self.assertNotContains(response, 'Generate Example Certificates')
|
||||
|
||||
def _assert_certificates_visible(self, is_visible):
|
||||
"""Check that the certificates section is visible on the instructor dash. """
|
||||
response = self.client.get(self.url)
|
||||
|
||||
@@ -236,20 +236,25 @@ def _section_certificates(course):
|
||||
dict
|
||||
|
||||
"""
|
||||
example_cert_status = certs_api.example_certificates_status(course.id)
|
||||
example_cert_status = None
|
||||
html_cert_enabled = certs_api.has_html_certificates_enabled(course.id, course)
|
||||
if html_cert_enabled:
|
||||
can_enable_for_course = True
|
||||
else:
|
||||
example_cert_status = certs_api.example_certificates_status(course.id)
|
||||
|
||||
# Allow the user to enable self-generated certificates for students
|
||||
# *only* once a set of example certificates has been successfully generated.
|
||||
# If certificates have been misconfigured for the course (for example, if
|
||||
# the PDF template hasn't been uploaded yet), then we don't want
|
||||
# to turn on self-generated certificates for students!
|
||||
can_enable_for_course = (
|
||||
example_cert_status is not None and
|
||||
all(
|
||||
cert_status['status'] == 'success'
|
||||
for cert_status in example_cert_status
|
||||
# Allow the user to enable self-generated certificates for students
|
||||
# *only* once a set of example certificates has been successfully generated.
|
||||
# If certificates have been misconfigured for the course (for example, if
|
||||
# the PDF template hasn't been uploaded yet), then we don't want
|
||||
# to turn on self-generated certificates for students!
|
||||
can_enable_for_course = (
|
||||
example_cert_status is not None and
|
||||
all(
|
||||
cert_status['status'] == 'success'
|
||||
for cert_status in example_cert_status
|
||||
)
|
||||
)
|
||||
)
|
||||
instructor_generation_enabled = settings.FEATURES.get('CERTIFICATES_INSTRUCTOR_GENERATION', False)
|
||||
|
||||
return {
|
||||
@@ -259,6 +264,7 @@ def _section_certificates(course):
|
||||
'can_enable_for_course': can_enable_for_course,
|
||||
'enabled_for_course': certs_api.cert_generation_enabled(course.id),
|
||||
'instructor_generation_enabled': instructor_generation_enabled,
|
||||
'html_cert_enabled': html_cert_enabled,
|
||||
'urls': {
|
||||
'generate_example_certificates': reverse(
|
||||
'generate_example_certificates',
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
<div class="certificates-wrapper">
|
||||
|
||||
<div class="example-certificates">
|
||||
% if not section_data['html_cert_enabled']:
|
||||
<h2>${_('Example Certificates')}</h2>
|
||||
|
||||
<div class="generate-example-certificates-wrapper">
|
||||
@@ -13,6 +14,7 @@
|
||||
<input type="submit" id="generate-example-certificates-submit" value="${_('Generate Example Certificates')}"/>
|
||||
</form>
|
||||
</div>
|
||||
% endif
|
||||
|
||||
% if section_data['example_certificate_status'] is not None:
|
||||
<div class="example-certificate-status-wrapper">
|
||||
|
||||
Reference in New Issue
Block a user