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


Python VerificationStatus.get_user_attempts方法代码示例

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


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

示例1: test_get_user_attempts

# 需要导入模块: from verify_student.models import VerificationStatus [as 别名]
# 或者: from verify_student.models.VerificationStatus import get_user_attempts [as 别名]
    def test_get_user_attempts(self):
        """
        Test adding verification status.
        """
        VerificationStatus.add_verification_status(checkpoint=self.first_checkpoint, user=self.user, status="submitted")

        actual_attempts = VerificationStatus.get_user_attempts(
            self.user.id, self.course.id, self.first_checkpoint_location
        )
        self.assertEqual(actual_attempts, 1)
开发者ID:chauhanhardik,项目名称:populo,代码行数:12,代码来源:test_models.py

示例2: get_attempts

# 需要导入模块: from verify_student.models import VerificationStatus [as 别名]
# 或者: from verify_student.models.VerificationStatus import get_user_attempts [as 别名]
    def get_attempts(self, user_id, course_id, related_assessment_location):
        """Get re-verification attempts against a user for a given 'checkpoint'
        and 'course_id'.

        Args:
            user_id(str): User Id string
            course_id(str): A string of course id
            related_assessment_location(str): Location of Reverification XBlock

        Returns:
            Number of re-verification attempts of a user
        """
        course_key = CourseKey.from_string(course_id)
        return VerificationStatus.get_user_attempts(user_id, course_key, related_assessment_location)
开发者ID:Certific-NET,项目名称:edx-platform,代码行数:16,代码来源:services.py

示例3: test_get_user_attempts

# 需要导入模块: from verify_student.models import VerificationStatus [as 别名]
# 或者: from verify_student.models.VerificationStatus import get_user_attempts [as 别名]
    def test_get_user_attempts(self):

        # adding verification status
        VerificationStatus.add_verification_status(
            checkpoint=self.check_point1,
            user=self.user,
            status='submitted',
            location_id=self.dummy_reverification_item_id_1
        )

        self.assertEqual(VerificationStatus.get_user_attempts(
            course_key=self.course.id,
            user_id=self.user.id,
            related_assessment='midterm', location_id=self.dummy_reverification_item_id_1), 1)
开发者ID:Shubhi01,项目名称:edx-platform,代码行数:16,代码来源:test_models.py

示例4: test_get_user_attempts

# 需要导入模块: from verify_student.models import VerificationStatus [as 别名]
# 或者: from verify_student.models.VerificationStatus import get_user_attempts [as 别名]
    def test_get_user_attempts(self):
        """
        Test adding verification status.
        """
        VerificationStatus.add_verification_status(
            checkpoint=self.first_checkpoint,
            user=self.user,
            status='submitted'
        )

        self.assertEqual(
            VerificationStatus.get_user_attempts(
                user_id=self.user.id,
                course_key=self.course.id,
                related_assessment_location=self.first_checkpoint_location
            ),
            1
        )
开发者ID:benpatterson,项目名称:edx-platform,代码行数:20,代码来源:test_models.py

示例5: _compose_message_reverification_email

# 需要导入模块: from verify_student.models import VerificationStatus [as 别名]
# 或者: from verify_student.models.VerificationStatus import get_user_attempts [as 别名]
def _compose_message_reverification_email(
        course_key, user_id, related_assessment_location, status, request
):  # pylint: disable=invalid-name
    """
    Compose subject and message for photo reverification email.

    Args:
        course_key(CourseKey): CourseKey object
        user_id(str): User Id
        related_assessment_location(str): Location of reverification XBlock
        photo_verification(QuerySet): Queryset of SoftwareSecure objects
        status(str): Approval status
        is_secure(Bool): Is running on secure protocol or not

    Returns:
        None if any error occurred else Tuple of subject and message strings
    """
    try:
        usage_key = UsageKey.from_string(related_assessment_location)
        reverification_block = modulestore().get_item(usage_key)

        course = modulestore().get_course(course_key)
        redirect_url = get_redirect_url(course_key, usage_key.replace(course_key=course_key))

        subject = "Re-verification Status"
        context = {
            "status": status,
            "course_name": course.display_name_with_default,
            "assessment": reverification_block.related_assessment
        }

        # Allowed attempts is 1 if not set on verification block
        allowed_attempts = reverification_block.attempts + 1
        used_attempts = VerificationStatus.get_user_attempts(user_id, course_key, related_assessment_location)
        left_attempts = allowed_attempts - used_attempts
        is_attempt_allowed = left_attempts > 0
        verification_open = True
        if reverification_block.due:
            verification_open = timezone.now() <= reverification_block.due

        context["left_attempts"] = left_attempts
        context["is_attempt_allowed"] = is_attempt_allowed
        context["verification_open"] = verification_open
        context["due_date"] = get_default_time_display(reverification_block.due)

        context['platform_name'] = settings.PLATFORM_NAME
        context["used_attempts"] = used_attempts
        context["allowed_attempts"] = allowed_attempts
        context["support_link"] = microsite.get_value('email_from_address', settings.CONTACT_EMAIL)

        re_verification_link = reverse(
            'verify_student_incourse_reverify',
            args=(
                unicode(course_key),
                related_assessment_location
            )
        )

        context["course_link"] = request.build_absolute_uri(redirect_url)
        context["reverify_link"] = request.build_absolute_uri(re_verification_link)

        message = render_to_string('emails/reverification_processed.txt', context)
        log.info(
            "Sending email to User_Id=%s. Attempts left for this user are %s. "
            "Allowed attempts %s. "
            "Due Date %s",
            str(user_id), left_attempts, allowed_attempts, str(reverification_block.due)
        )
        return subject, message
    # Catch all exception to avoid raising back to view
    except:  # pylint: disable=bare-except
        log.exception("The email for re-verification sending failed for user_id %s", user_id)
开发者ID:mushtaqak,项目名称:edx-platform,代码行数:74,代码来源:views.py


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