本文整理汇总了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)
示例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)
示例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)
示例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)
示例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)
示例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
}
)