当前位置: 首页>>代码示例>>Python>>正文


Python GeneratedCertificate.get_unique_statuses方法代码示例

本文整理汇总了Python中certificates.models.GeneratedCertificate.get_unique_statuses方法的典型用法代码示例。如果您正苦于以下问题:Python GeneratedCertificate.get_unique_statuses方法的具体用法?Python GeneratedCertificate.get_unique_statuses怎么用?Python GeneratedCertificate.get_unique_statuses使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在certificates.models.GeneratedCertificate的用法示例。


在下文中一共展示了GeneratedCertificate.get_unique_statuses方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _section_certificates

# 需要导入模块: from certificates.models import GeneratedCertificate [as 别名]
# 或者: from certificates.models.GeneratedCertificate import get_unique_statuses [as 别名]
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}),
        },
    }
开发者ID:lemontreeran,项目名称:edx-platform,代码行数:61,代码来源:instructor_dashboard.py

示例2: _section_certificates

# 需要导入模块: from certificates.models import GeneratedCertificate [as 别名]
# 或者: from certificates.models.GeneratedCertificate import get_unique_statuses [as 别名]
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}
            ),
        }
    }
开发者ID:NhaTrang,项目名称:edx-platform,代码行数:78,代码来源:instructor_dashboard.py


注:本文中的certificates.models.GeneratedCertificate.get_unique_statuses方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。