示例#1
0
def generate_certificate_task(user, course_key):
    """
    Create a task to generate a certificate for this user in this course run, if the user is eligible and a certificate
    can be generated.

    If the allowlist is enabled for this course run and the user is on the allowlist, the allowlist logic will be used.
    Otherwise, the regular course certificate generation logic will be used.
    """
    return _generate_certificate_task(user, course_key)
示例#2
0
def generate_certificate_task(user, course_key, generation_mode=None):
    """
    Create a task to generate a certificate for this user in this course run, if the user is eligible and a certificate
    can be generated.

    If the allowlist is enabled for this course run and the user is on the allowlist, the allowlist logic will be used.
    Otherwise, the regular course certificate generation logic will be used.

    Args:
        user: user for whom to generate a certificate
        course_key: course run key for which to generate a certificate
        generation_mode: Used when emitting an events. Options are "self" (implying the user generated the cert
            themself) and "batch" for everything else.
    """
    return _generate_certificate_task(user, course_key, generation_mode)
示例#3
0
    def handle(self, *args, **options):
        if options.get('limit'):
            limit = int(options['limit'])
        else:
            limit = 1000

        # We started creating the incorrect certificate records around May 10th, 2021.
        certs = GeneratedCertificate.objects.filter(
            mode='honor',
            created_date__gte=datetime.date(2021, 5, 10)
        ).order_by(
            'created_date'
        )[:limit]

        for cert in certs:
            user = User.objects.get(id=cert.user_id)
            course_id = cert.course_id

            _generate_certificate_task(
                user,
                course_id,
                status=cert.status,
                generation_mode='batch'
            )