refactor!: Remove generate_example_certificates and update Instructor Dashboard with updated messaging.

[MICROBA-1087]
[DEPR-155]

* Remove `generate_example_certificates` functionality
* Adjust Instructor dashboard slightly to prevent people from clicking the `Generate Example Certificates` button, remove form/code that called the `generate_example_certificates` endpoint.
This commit is contained in:
Justin Hynes
2021-07-30 15:02:24 -04:00
parent 1887f13fd2
commit d4a7a44909
6 changed files with 13 additions and 80 deletions

View File

@@ -351,33 +351,6 @@ def cert_generation_enabled(course_key):
)
def generate_example_certificates(course_key):
"""Generate example (PDF) certificates for a course.
Example certificates were used to validate that certificates were configured correctly for the course. Staff
members could view the example certificates before enabling the self-generated certificates button for students.
[07/20/2021 Update]
This function was updated to remove the references to queue.py, which has been removed as part of MICROBA-1227, and
no longer can fulfill the function it was originally created for. There is further cleanup around PDF certificate
generation code, part of DEPR-155, that will remove this function. See DEPR-155 and MICROBA-1094 for additional
info.
It may be important to note that this functionality has been broken since 2018 when the ability to generate PDF
certificates was ripped out of edx-platform. This will be removed as part of MICROBA-1394.
Arguments:
course_key (CourseKey): The course identifier.
Returns:
None
"""
log.warning(
"Generating example certificates is no longer supported. Skipping generation of example certificates for "
f"course {course_key}"
)
def example_certificates_status(course_key):
"""Check the status of example certificates for a course.

View File

@@ -14,7 +14,6 @@ from django.core.exceptions import ObjectDoesNotExist
from django.core.files.uploadedfile import SimpleUploadedFile
from django.test.utils import override_settings
from django.urls import reverse
from testfixtures import LogCapture
from common.djangoapps.student.models import CourseEnrollment
from common.djangoapps.student.tests.factories import GlobalStaffFactory
@@ -229,7 +228,7 @@ class CertificatesInstructorApiTest(SharedModuleStoreTestCase):
cache.clear()
CertificateGenerationConfiguration.objects.create(enabled=True)
@ddt.data('generate_example_certificates', 'enable_certificate_generation')
@ddt.data('enable_certificate_generation')
def test_allow_only_global_staff(self, url_name):
url = reverse(url_name, kwargs={'course_id': self.course.id})
@@ -243,28 +242,6 @@ class CertificatesInstructorApiTest(SharedModuleStoreTestCase):
response = self.client.post(url)
assert response.status_code == 302
def test_generate_example_certificates(self):
expected_log_message = (
"Generating example certificates is no longer supported. Skipping generation of example certificates for "
f"course {self.course.id}"
)
self.client.login(username=self.global_staff.username, password='test')
url = reverse(
'generate_example_certificates',
kwargs={'course_id': str(self.course.id)}
)
logging_messages = None
with LogCapture() as log:
response = self.client.post(url)
logging_messages = [log_msg.getMessage() for log_msg in log.records]
assert logging_messages is not None
assert expected_log_message in logging_messages
# Expect a redirect back to the instructor dashboard
self._assert_redirects_to_instructor_dash(response)
@ddt.data(True, False)
def test_enable_certificate_generation(self, is_enabled):
self.client.login(username=self.global_staff.username, password='test')

View File

@@ -2825,23 +2825,6 @@ def _instructor_dash_url(course_key, section=None):
return url
@require_global_staff
@require_POST
def generate_example_certificates(request, course_id=None):
"""Start generating a set of example certificates.
Example certificates are used to verify that certificates have
been configured correctly for the course.
Redirects back to the instructor dashboard once certificate
generation has begun.
"""
course_key = CourseKey.from_string(course_id)
certs_api.generate_example_certificates(course_key)
return redirect(_instructor_dash_url(course_key, section='certificates'))
@require_course_permission(permissions.ENABLE_CERTIFICATE_GENERATION)
@require_POST
def enable_certificate_generation(request, course_id=None):

View File

@@ -79,7 +79,6 @@ urlpatterns = [
url(r'^add_users_to_cohorts$', api.add_users_to_cohorts, name='add_users_to_cohorts'),
# Certificates
url(r'^generate_example_certificates$', api.generate_example_certificates, name='generate_example_certificates'),
url(r'^enable_certificate_generation$', api.enable_certificate_generation, name='enable_certificate_generation'),
url(r'^start_certificate_generation', api.start_certificate_generation, name='start_certificate_generation'),
url(r'^start_certificate_regeneration', api.start_certificate_regeneration, name='start_certificate_regeneration'),

View File

@@ -342,10 +342,6 @@ def _section_certificates(course):
'certificate_generation_history':
CertificateGenerationHistory.objects.filter(course_id=course.id).order_by("-created"),
'urls': {
'generate_example_certificates': reverse(
'generate_example_certificates',
kwargs={'course_id': course.id}
),
'enable_certificate_generation': reverse(
'enable_certificate_generation',
kwargs={'course_id': course.id}

View File

@@ -21,12 +21,15 @@ from openedx.core.djangolib.js_utils import dump_js_escaped_json, js_escaped_str
<h3 class="hd hd-3">${_('Example Certificates')}</h3>
<div class="generate-example-certificates-wrapper">
<p>${_('Generate example certificates for the course.')}</p>
<form id="generate-example-certificates-form" method="post" action="${section_data['urls']['generate_example_certificates']}">
<input type="hidden" name="csrfmiddlewaretoken" value="${csrf_token}">
<input type="submit" class="btn-blue" id="generate-example-certificates-submit" value="${_('Generate Example Certificates')}"/>
</form>
<p class="under-heading">
${_('This course is configured to generate PDF certificates and this certificate type is no longer supported. Example certificates cannot be generated.')}
</p>
<!--
The endpoint called to generate example certificates has been removed. The form that previously called this endpoint has been
replaced with a (permanently disabled) button. Further cleanup of the Instructor Dashboard will be handled in MICROBA-1415
(as part of DEPR-157 and the MICROBA-1265 Epic that will remove the remaining PDF certificate viewing code in edx-platform).
-->
<button class="is-disabled">${_('Generate Example Certificates')}</button>
</div>
% endif
@@ -68,7 +71,9 @@ from openedx.core.djangolib.js_utils import dump_js_escaped_json, js_escaped_str
<input type="submit" class="btn-blue" id="enable-certificates-submit" value="${_('Enable Student-Generated Certificates')}"/>
</form>
% else:
<p>${_("You must successfully generate example certificates before you enable student-generated certificates.")}</p>
<p class="under-heading">
${_("You must successfully generate example certificates before you enable student-generated certificates.")}
</p>
<button class="is-disabled" disabled>${_('Enable Student-Generated Certificates')}</button>
% endif
</div>