def _section_certificates(course):
    """Section information for the certificates panel.

    The certificates panel allows global staff to generate
    example certificates and enable self-generated certificates
    for a course.

    Arguments:
        course (Course)

    Returns:
        dict

    """
    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
        )
    instructor_generation_enabled = settings.FEATURES.get("CERTIFICATES_INSTRUCTOR_GENERATION", False)
    certificate_statuses_with_count = {
        certificate["status"]: certificate["count"]
        for certificate in GeneratedCertificate.get_unique_statuses(course_key=course.id)
    }

    return {
        "section_key": "certificates",
        "section_display_name": _("Certificates"),
        "example_certificate_status": example_cert_status,
        "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,
        "active_certificate": certs_api.get_active_web_certificate(course),
        "certificate_statuses_with_count": certificate_statuses_with_count,
        "status": CertificateStatuses,
        "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}),
            "start_certificate_generation": reverse("start_certificate_generation", kwargs={"course_id": course.id}),
            "start_certificate_regeneration": reverse(
                "start_certificate_regeneration", kwargs={"course_id": course.id}
            ),
            "list_instructor_tasks_url": reverse("list_instructor_tasks", kwargs={"course_id": course.id}),
        },
    }
Пример #2
0
def _section_certificates(course):
    """Section information for the certificates panel.

    The certificates panel allows global staff to generate
    example certificates and enable self-generated certificates
    for a course.

    Arguments:
        course (Course)

    Returns:
        dict

    """
    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
        )
    )
    instructor_generation_enabled = settings.FEATURES.get('CERTIFICATES_INSTRUCTOR_GENERATION', False)

    return {
        'section_key': 'certificates',
        'section_display_name': _('Certificates'),
        'example_certificate_status': example_cert_status,
        'can_enable_for_course': can_enable_for_course,
        'enabled_for_course': certs_api.cert_generation_enabled(course.id),
        'instructor_generation_enabled': instructor_generation_enabled,
        '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}
            ),
            'start_certificate_generation': reverse(
                'start_certificate_generation',
                kwargs={'course_id': course.id}
            ),
            'list_instructor_tasks_url': reverse(
                'list_instructor_tasks',
                kwargs={'course_id': course.id}
            ),
        }
    }
    def test_generate_example_certificates(self):
        self.client.login(username=self.global_staff.username, password="******")
        url = reverse("generate_example_certificates", kwargs={"course_id": unicode(self.course.id)})
        response = self.client.post(url)

        # Expect a redirect back to the instructor dashboard
        self._assert_redirects_to_instructor_dash(response)

        # Expect that certificate generation started
        # Cert generation will fail here because XQueue isn't configured,
        # but the status should at least not be None.
        status = certs_api.example_certificates_status(self.course.id)
        self.assertIsNot(status, None)
Пример #4
0
 def _assert_cert_status(self, *expected_statuses):
     """Check the example certificate status. """
     actual_status = certs_api.example_certificates_status(self.COURSE_KEY)
     self.assertEqual(list(expected_statuses), actual_status)
Пример #5
0
def _section_certificates(course):
    """Section information for the certificates panel.

    The certificates panel allows global staff to generate
    example certificates and enable self-generated certificates
    for a course.

    Arguments:
        course (Course)

    Returns:
        dict

    """
    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
            )
        )
    instructor_generation_enabled = settings.FEATURES.get('CERTIFICATES_INSTRUCTOR_GENERATION', False)
    certificate_statuses_with_count = {
        certificate['status']: certificate['count']
        for certificate in GeneratedCertificate.get_unique_statuses(course_key=course.id)
    }

    return {
        'section_key': 'certificates',
        'section_display_name': _('Certificates'),
        'example_certificate_status': example_cert_status,
        'can_enable_for_course': can_enable_for_course,
        'enabled_for_course': certs_api.cert_generation_enabled(course.id),
        'is_self_paced': course.self_paced,
        'instructor_generation_enabled': instructor_generation_enabled,
        'html_cert_enabled': html_cert_enabled,
        'active_certificate': certs_api.get_active_web_certificate(course),
        'certificate_statuses_with_count': certificate_statuses_with_count,
        'status': CertificateStatuses,
        '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}
            ),
            'start_certificate_generation': reverse(
                'start_certificate_generation',
                kwargs={'course_id': course.id}
            ),
            'start_certificate_regeneration': reverse(
                'start_certificate_regeneration',
                kwargs={'course_id': course.id}
            ),
            'list_instructor_tasks_url': reverse(
                'list_instructor_tasks',
                kwargs={'course_id': course.id}
            ),
        }
    }
Пример #6
0
 def _assert_cert_status(self, *expected_statuses):
     """Check the example certificate status. """
     actual_status = certs_api.example_certificates_status(self.COURSE_KEY)
     self.assertEqual(list(expected_statuses), actual_status)
Пример #7
0
def _section_certificates(course):
    """Section information for the certificates panel.

    The certificates panel allows global staff to generate
    example certificates and enable self-generated certificates
    for a course.

    Arguments:
        course (Course)

    Returns:
        dict

    """
    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))
    instructor_generation_enabled = settings.FEATURES.get(
        'CERTIFICATES_INSTRUCTOR_GENERATION', False)
    certificate_statuses_with_count = {
        certificate['status']: certificate['count']
        for certificate in GeneratedCertificate.get_unique_statuses(
            course_key=course.id)
    }

    return {
        'section_key':
        'certificates',
        'section_display_name':
        _('Certificates'),
        'example_certificate_status':
        example_cert_status,
        'can_enable_for_course':
        can_enable_for_course,
        'enabled_for_course':
        certs_api.cert_generation_enabled(course.id),
        'is_self_paced':
        course.self_paced,
        'instructor_generation_enabled':
        instructor_generation_enabled,
        'html_cert_enabled':
        html_cert_enabled,
        'active_certificate':
        certs_api.get_active_web_certificate(course),
        'certificate_statuses_with_count':
        certificate_statuses_with_count,
        'status':
        CertificateStatuses,
        '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}),
            'start_certificate_generation':
            reverse('start_certificate_generation',
                    kwargs={'course_id': course.id}),
            'start_certificate_regeneration':
            reverse('start_certificate_regeneration',
                    kwargs={'course_id': course.id}),
            'list_instructor_tasks_url':
            reverse('list_instructor_tasks', kwargs={'course_id': course.id}),
        }
    }