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


Python CreditRequirement.get_course_requirement方法代码示例

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


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

示例1: remove_credit_requirement_status

# 需要导入模块: from openedx.core.djangoapps.credit.models import CreditRequirement [as 别名]
# 或者: from openedx.core.djangoapps.credit.models.CreditRequirement import get_course_requirement [as 别名]
def remove_credit_requirement_status(username, course_key, req_namespace, req_name):
    """
    Remove the user's requirement status.

    This will remove the record from the credit requirement status table.
    The user will still be eligible for the credit in a course.

    Args:
        username (str): Username of the user
        course_key (CourseKey): Identifier for the course associated
                                with the requirement.
        req_namespace (str): Namespace of the requirement
                            (e.g. "grade" or "reverification")
        req_name (str): Name of the requirement
                        (e.g. "grade" or the location of the ICRV XBlock)

    """

    # Find the requirement we're trying to remove
    req_to_remove = CreditRequirement.get_course_requirement(course_key, req_namespace, req_name)

    # If we can't find the requirement, then the most likely explanation
    # is that there was a lag removing the credit requirements after the course
    # was published.  We *could* attempt to remove the requirement here,
    # but that could cause serious performance issues if many users attempt to
    # lock the row at the same time.
    # Instead, we skip removing the requirement and log an error.
    if not req_to_remove:
        log.error(
            (
                u'Could not remove credit requirement in course "%s" '
                u'with namespace "%s" and name "%s" '
                u'because the requirement does not exist. '
            ),
            unicode(course_key), req_namespace, req_name
        )
        return

    # Remove the requirement status
    CreditRequirementStatus.remove_requirement_status(
        username, req_to_remove
    )
开发者ID:cmscom,项目名称:edx-platform,代码行数:44,代码来源:eligibility.py

示例2: test_set_credit_requirement_status

# 需要导入模块: from openedx.core.djangoapps.credit.models import CreditRequirement [as 别名]
# 或者: from openedx.core.djangoapps.credit.models.CreditRequirement import get_course_requirement [as 别名]
    def test_set_credit_requirement_status(self):
        self.add_credit_course()
        requirements = [
            {
                "namespace": "grade",
                "name": "grade",
                "display_name": "Grade",
                "criteria": {
                    "min_grade": 0.8
                }
            },
            {
                "namespace": "reverification",
                "name": "i4x://edX/DemoX/edx-reverification-block/assessment_uuid",
                "display_name": "Assessment 1",
                "criteria": {}
            }
        ]

        set_credit_requirements(self.course_key, requirements)
        course_requirements = CreditRequirement.get_course_requirements(self.course_key)
        self.assertEqual(len(course_requirements), 2)

        requirement = get_credit_requirement(self.course_key, "grade", "grade")
        set_credit_requirement_status("staff", requirement, 'satisfied', {})
        course_requirement = CreditRequirement.get_course_requirement(
            requirement['course_key'], requirement['namespace'], requirement['name']
        )
        status = CreditRequirementStatus.objects.get(username="staff", requirement=course_requirement)
        self.assertEqual(status.requirement.namespace, requirement['namespace'])
        self.assertEqual(status.status, "satisfied")

        set_credit_requirement_status(
            "staff", requirement, 'failed', {'failure_reason': "requirements not satisfied"}
        )
        status = CreditRequirementStatus.objects.get(username="staff", requirement=course_requirement)
        self.assertEqual(status.requirement.namespace, requirement['namespace'])
        self.assertEqual(status.status, "failed")
开发者ID:redukyo,项目名称:edx-platform,代码行数:40,代码来源:test_api.py


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