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


Python CreditRequirement.add_or_update_course_requirement方法代码示例

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


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

示例1: test_add_course_requirement_namespace

# 需要导入模块: from openedx.core.djangoapps.credit.models import CreditRequirement [as 别名]
# 或者: from openedx.core.djangoapps.credit.models.CreditRequirement import add_or_update_course_requirement [as 别名]
    def test_add_course_requirement_namespace(self):
        credit_course = add_credit_course(self.course_key)
        requirement = {
            "namespace": "grade",
            "name": "grade",
            "display_name": "Grade",
            "criteria": {
                "min_grade": 0.8
            },
        }
        credit_req, created = CreditRequirement.add_or_update_course_requirement(credit_course, requirement, 0)
        self.assertEqual(credit_course, credit_req.course)
        self.assertEqual(created, True)

        requirement = {
            "namespace": "new_grade",
            "name": "new_grade",
            "display_name": "New Grade",
            "criteria": {},
        }
        credit_req, created = CreditRequirement.add_or_update_course_requirement(credit_course, requirement, 1)
        self.assertEqual(credit_course, credit_req.course)
        self.assertEqual(created, True)

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

        requirements = CreditRequirement.get_course_requirements(self.course_key, namespace="grade")
        self.assertEqual(len(requirements), 1)
开发者ID:cmscom,项目名称:edx-platform,代码行数:31,代码来源:test_models.py

示例2: test_add_course_requirement_namespace

# 需要导入模块: from openedx.core.djangoapps.credit.models import CreditRequirement [as 别名]
# 或者: from openedx.core.djangoapps.credit.models.CreditRequirement import add_or_update_course_requirement [as 别名]
    def test_add_course_requirement_namespace(self):
        credit_course = self.add_credit_course()
        requirement = {
            "namespace": "grade",
            "name": "grade",
            "display_name": "Grade",
            "criteria": {
                "min_grade": 0.8
            }
        }
        credit_req, created = CreditRequirement.add_or_update_course_requirement(credit_course, requirement)
        self.assertEqual(credit_course, credit_req.course)
        self.assertEqual(created, True)

        requirement = {
            "namespace": "reverification",
            "name": "i4x://edX/DemoX/edx-reverification-block/assessment_uuid",
            "display_name": "Assessment 1",
            "criteria": {}
        }
        credit_req, created = CreditRequirement.add_or_update_course_requirement(credit_course, requirement)
        self.assertEqual(credit_course, credit_req.course)
        self.assertEqual(created, True)

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

        requirements = CreditRequirement.get_course_requirements(self.course_key, namespace="grade")
        self.assertEqual(len(requirements), 1)
开发者ID:mtorrisi,项目名称:edx-platform,代码行数:31,代码来源:test_models.py

示例3: test_add_course_requirement_namespace

# 需要导入模块: from openedx.core.djangoapps.credit.models import CreditRequirement [as 别名]
# 或者: from openedx.core.djangoapps.credit.models.CreditRequirement import add_or_update_course_requirement [as 别名]
    def test_add_course_requirement_namespace(self):
        credit_course = self.add_credit_course()
        requirement = {
            "namespace": "grade",
            "name": "grade",
            "criteria": {
                "min_grade": 0.8
            }
        }
        credit_req, created = CreditRequirement.add_or_update_course_requirement(credit_course, requirement)
        self.assertEqual(credit_course, credit_req.course)
        self.assertEqual(created, True)

        requirement = {
            "namespace": "icrv",
            "name": "midterm",
            "criteria": ""
        }
        credit_req, created = CreditRequirement.add_or_update_course_requirement(credit_course, requirement)
        self.assertEqual(credit_course, credit_req.course)
        self.assertEqual(created, True)

        requirements = CreditRequirement.get_course_requirements(self.course_key)
        self.assertEqual(len(requirements), 2)
        requirements = CreditRequirement.get_course_requirements(self.course_key, namespace="grade")
        self.assertEqual(len(requirements), 1)
开发者ID:ISCLC,项目名称:edx-platform-for-isc,代码行数:28,代码来源:test_models.py

示例4: set_credit_requirements

# 需要导入模块: from openedx.core.djangoapps.credit.models import CreditRequirement [as 别名]
# 或者: from openedx.core.djangoapps.credit.models.CreditRequirement import add_or_update_course_requirement [as 别名]
def set_credit_requirements(course_key, requirements):
    """
    Add requirements to given course.

    Args:
        course_key(CourseKey): The identifier for course
        requirements(list): List of requirements to be added

    Example:
        >>> set_credit_requirements(
                "course-v1-edX-DemoX-1T2015",
                [
                    {
                        "namespace": "reverification",
                        "name": "i4x://edX/DemoX/edx-reverification-block/assessment_uuid",
                        "display_name": "Assessment 1",
                        "criteria": {},
                    },
                    {
                        "namespace": "proctored_exam",
                        "name": "i4x://edX/DemoX/proctoring-block/final_uuid",
                        "display_name": "Final Exam",
                        "criteria": {},
                    },
                    {
                        "namespace": "grade",
                        "name": "grade",
                        "display_name": "Grade",
                        "criteria": {"min_grade": 0.8},
                    },
                ])

    Raises:
        InvalidCreditRequirements

    Returns:
        None
    """

    invalid_requirements = _validate_requirements(requirements)
    if invalid_requirements:
        invalid_requirements = ", ".join(invalid_requirements)
        raise InvalidCreditRequirements(invalid_requirements)

    try:
        credit_course = CreditCourse.get_credit_course(course_key=course_key)
    except CreditCourse.DoesNotExist:
        raise InvalidCreditCourse()

    old_requirements = CreditRequirement.get_course_requirements(course_key=course_key)
    requirements_to_disable = _get_requirements_to_disable(old_requirements, requirements)
    if requirements_to_disable:
        CreditRequirement.disable_credit_requirements(requirements_to_disable)

    for order, requirement in enumerate(requirements):
        CreditRequirement.add_or_update_course_requirement(credit_course, requirement, order)
开发者ID:28554010,项目名称:edx-platform,代码行数:58,代码来源:eligibility.py

示例5: test_get_course_requirements

# 需要导入模块: from openedx.core.djangoapps.credit.models import CreditRequirement [as 别名]
# 或者: from openedx.core.djangoapps.credit.models.CreditRequirement import add_or_update_course_requirement [as 别名]
 def test_get_course_requirements(self):
     credit_course = self.add_credit_course()
     requirement = {
         "namespace": "grade",
         "name": "grade",
         "display_name": "Grade",
         "criteria": {
             "min_grade": 0.8
         }
     }
     credit_req, created = CreditRequirement.add_or_update_course_requirement(credit_course, requirement)
     self.assertEqual(credit_course, credit_req.course)
     self.assertEqual(created, True)
     requirements = CreditRequirement.get_course_requirements(self.course_key)
     self.assertEqual(len(requirements), 1)
开发者ID:mtorrisi,项目名称:edx-platform,代码行数:17,代码来源:test_models.py

示例6: add_course_requirements

# 需要导入模块: from openedx.core.djangoapps.credit.models import CreditRequirement [as 别名]
# 或者: from openedx.core.djangoapps.credit.models.CreditRequirement import add_or_update_course_requirement [as 别名]
    def add_course_requirements(self):
        """
        Add requirements to course.
        """
        requirements = (
            {
                "namespace": "grade",
                "name": "grade",
                "display_name": "Grade",
                "criteria": {
                    "min_grade": 0.8
                }
            },
            {
                "namespace": "new_grade",
                "name": "new_grade",
                "display_name": "new_grade",
                "criteria": {
                    "min_grade": 0.8
                },
            }
        )

        for i, requirement in enumerate(requirements):
            credit_requirement, _ = CreditRequirement.add_or_update_course_requirement(
                self.credit_course,
                requirement,
                i
            )
            CreditRequirementStatus.add_or_update_requirement_status(
                self.old_username,
                credit_requirement,
                "satisfied",
                {
                    "final_grade": 0.95
                }
            )
开发者ID:cmscom,项目名称:edx-platform,代码行数:39,代码来源:test_models.py


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