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


Python GeneratedCertificate.certificate_for_student方法代码示例

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


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

示例1: _listen_for_passing_grade

# 需要导入模块: from certificates.models import GeneratedCertificate [as 别名]
# 或者: from certificates.models.GeneratedCertificate import certificate_for_student [as 别名]
def _listen_for_passing_grade(sender, user, course_id, **kwargs):  # pylint: disable=unused-argument
    """
    Listen for a learner passing a course, send cert generation task,
    downstream signal from COURSE_GRADE_CHANGED
    """

    # No flags enabled
    if (
        not waffle.waffle().is_enabled(waffle.SELF_PACED_ONLY) and
        not waffle.waffle().is_enabled(waffle.INSTRUCTOR_PACED_ONLY)
    ):
        return

    # Only SELF_PACED_ONLY flag enabled
    if waffle.waffle().is_enabled(waffle.SELF_PACED_ONLY):
        if not courses.get_course_by_id(course_key, depth=0).self_paced:
            return

    # Only INSTRUCTOR_PACED_ONLY flag enabled
    elif waffle.waffle().is_enabled(waffle.INSTRUCTOR_PACED_ONLY):
        if courses.get_course_by_id(course_key, depth=0).self_paced:
            return
    if GeneratedCertificate.certificate_for_student(self.user, self.course_id) is None:
        generate_certificate.apply_async(
            student=user,
            course_key=course_id,
        )
        log.info(u'Certificate generation task initiated for {user} : {course} via passing grade'.format(
            user=user.id,
            course=course_id
        ))
开发者ID:Stanford-Online,项目名称:edx-platform,代码行数:33,代码来源:signals.py

示例2: is_entitlement_regainable

# 需要导入模块: from certificates.models import GeneratedCertificate [as 别名]
# 或者: from certificates.models.GeneratedCertificate import certificate_for_student [as 别名]
    def is_entitlement_regainable(self, entitlement):
        """
        Determines from the policy if an entitlement can still be regained by the user, if they choose
        to by leaving and regaining their entitlement within policy.regain_period days from start date of
        the course or their redemption, whichever comes later, and the expiration period hasn't passed yet
        """
        if entitlement.enrollment_course_run:
            if GeneratedCertificate.certificate_for_student(
                    entitlement.user_id, entitlement.enrollment_course_run.course_id) is not None:
                return False

            # This is >= because a days_until_expiration 0 means that the expiration day has not fully passed yet
            # and that the entitlement should not be expired as there is still time
            return self.get_days_until_expiration(entitlement) >= 0
        return False
开发者ID:lduarte1991,项目名称:edx-platform,代码行数:17,代码来源:models.py

示例3: is_certificate_invalid

# 需要导入模块: from certificates.models import GeneratedCertificate [as 别名]
# 或者: from certificates.models.GeneratedCertificate import certificate_for_student [as 别名]
def is_certificate_invalid(student, course_key):
    """Check that whether the student in the course has been invalidated
    for receiving certificates.

    Arguments:
        student (user object): logged-in user
        course_key (CourseKey): The course identifier.

    Returns:
        Boolean denoting whether the student in the course is invalidated
        to receive certificates
    """
    is_invalid = False
    certificate = GeneratedCertificate.certificate_for_student(student, course_key)
    if certificate is not None:
        is_invalid = CertificateInvalidation.has_certificate_invalidation(student, course_key)

    return is_invalid
开发者ID:edx-solutions,项目名称:edx-platform,代码行数:20,代码来源:api.py

示例4: fire_ungenerated_certificate_task

# 需要导入模块: from certificates.models import GeneratedCertificate [as 别名]
# 或者: from certificates.models.GeneratedCertificate import certificate_for_student [as 别名]
def fire_ungenerated_certificate_task(user, course_key):
    """
    Helper function to fire un-generated certificate tasks

    The 'mode_is_verified' query is copied from the GeneratedCertificate model,
    but is done here in an attempt to reduce traffic to the workers.
    If the learner is verified and their cert has the 'unverified' status,
    we regenerate the cert.
    """
    enrollment_mode, __ = CourseEnrollment.enrollment_mode_for_user(user, course_key)
    mode_is_verified = enrollment_mode in GeneratedCertificate.VERIFIED_CERTS_MODES
    cert = GeneratedCertificate.certificate_for_student(user, course_key)
    if mode_is_verified and (cert is None or cert.status == 'unverified'):
        generate_certificate.apply_async(kwargs={
            'student': unicode(user.id),
            'course_key': unicode(course_key),
        })
        return True
开发者ID:Lektorium-LLC,项目名称:edx-platform,代码行数:20,代码来源:signals.py

示例5: refundable

# 需要导入模块: from certificates.models import GeneratedCertificate [as 别名]
# 或者: from certificates.models.GeneratedCertificate import certificate_for_student [as 别名]
    def refundable(self):
        """
        For paid/verified certificates, students may receive a refund if they have
        a verified certificate and the deadline for refunds has not yet passed.
        """
        # In order to support manual refunds past the deadline, set can_refund on this object.
        # On unenrolling, the "unenroll_done" signal calls CertificateItem.refund_cert_callback(),
        # which calls this method to determine whether to refund the order.
        # This can't be set directly because refunds currently happen as a side-effect of unenrolling.
        # (side-effects are bad)
        if getattr(self, 'can_refund', None) is not None:
            return True

        # If the student has already been given a certificate they should not be refunded
        if GeneratedCertificate.certificate_for_student(self.user, self.course_id) is not None:
            return False

        course_mode = CourseMode.mode_for_course(self.course_id, 'verified')
        if course_mode is None:
            return False
        else:
            return True
开发者ID:roadlit,项目名称:edx-platform,代码行数:24,代码来源:models.py

示例6: test_ineligible_cert_whitelisted

# 需要导入模块: from certificates.models import GeneratedCertificate [as 别名]
# 或者: from certificates.models.GeneratedCertificate import certificate_for_student [as 别名]
    def test_ineligible_cert_whitelisted(self):
        """Test that audit mode students can receive a certificate if they are whitelisted."""
        # Enroll as audit
        CourseEnrollmentFactory(
            user=self.user_2,
            course_id=self.course.id,
            is_active=True,
            mode='audit'
        )
        # Whitelist student
        CertificateWhitelistFactory(course_id=self.course.id, user=self.user_2)

        # Generate certs
        with patch('courseware.grades.grade', Mock(return_value={'grade': 'Pass', 'percent': 0.75})):
            with patch.object(XQueueInterface, 'send_to_queue') as mock_send:
                mock_send.return_value = (0, None)
                self.xqueue.add_cert(self.user_2, self.course.id)

        # Assert cert generated correctly
        self.assertTrue(mock_send.called)
        certificate = GeneratedCertificate.certificate_for_student(self.user_2, self.course.id)
        self.assertIsNotNone(certificate)
        self.assertEqual(certificate.mode, 'audit')
开发者ID:attiyaIshaque,项目名称:edx-platform,代码行数:25,代码来源:test_queue.py


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