本文整理汇总了Python中openedx.core.djangoapps.credit.models.CreditCourse.is_credit_course方法的典型用法代码示例。如果您正苦于以下问题:Python CreditCourse.is_credit_course方法的具体用法?Python CreditCourse.is_credit_course怎么用?Python CreditCourse.is_credit_course使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openedx.core.djangoapps.credit.models.CreditCourse
的用法示例。
在下文中一共展示了CreditCourse.is_credit_course方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_course_requirements
# 需要导入模块: from openedx.core.djangoapps.credit.models import CreditCourse [as 别名]
# 或者: from openedx.core.djangoapps.credit.models.CreditCourse import is_credit_course [as 别名]
def update_course_requirements(course_id):
""" Updates course requirements table for a course.
Args:
course_id(str): A string representation of course identifier
Returns:
None
"""
try:
course_key = CourseKey.from_string(course_id)
is_credit_course = CreditCourse.is_credit_course(course_key)
if is_credit_course:
course = modulestore().get_course(course_key)
requirements = [
{
"namespace": "grade",
"name": "grade",
"criteria": {
"min_grade": get_min_grade_for_credit(course)
}
}
]
set_credit_requirements(course_key, requirements)
except (InvalidKeyError, ItemNotFoundError, InvalidCreditRequirements) as exc:
LOGGER.error('Error on adding the requirements for course %s - %s', course_id, unicode(exc))
raise update_course_requirements.retry(args=[course_id], exc=exc)
else:
LOGGER.info('Requirements added for course %s', course_id)
示例2: is_credit_course
# 需要导入模块: from openedx.core.djangoapps.credit.models import CreditCourse [as 别名]
# 或者: from openedx.core.djangoapps.credit.models.CreditCourse import is_credit_course [as 别名]
def is_credit_course(course_key):
"""
Check whether the course has been configured for credit.
Args:
course_key (CourseKey): Identifier of the course.
Returns:
bool: True iff this is a credit course.
"""
return CreditCourse.is_credit_course(course_key=course_key)
示例3: update_credit_course_requirements
# 需要导入模块: from openedx.core.djangoapps.credit.models import CreditCourse [as 别名]
# 或者: from openedx.core.djangoapps.credit.models.CreditCourse import is_credit_course [as 别名]
def update_credit_course_requirements(course_id):
"""
Updates course requirements table for a course.
Args:
course_id(str): A string representation of course identifier
Returns:
None
"""
try:
course_key = CourseKey.from_string(course_id)
is_credit_course = CreditCourse.is_credit_course(course_key)
if is_credit_course:
requirements = _get_course_credit_requirements(course_key)
set_credit_requirements(course_key, requirements)
except (InvalidKeyError, ItemNotFoundError, InvalidCreditRequirements) as exc:
LOGGER.error(u'Error on adding the requirements for course %s - %s', course_id, six.text_type(exc))
raise update_credit_course_requirements.retry(args=[course_id], exc=exc)
else:
LOGGER.info(u'Requirements added for course %s', course_id)
示例4: update_credit_course_requirements
# 需要导入模块: from openedx.core.djangoapps.credit.models import CreditCourse [as 别名]
# 或者: from openedx.core.djangoapps.credit.models.CreditCourse import is_credit_course [as 别名]
def update_credit_course_requirements(course_id): # pylint: disable=invalid-name
"""Updates course requirements table for a course.
Args:
course_id(str): A string representation of course identifier
Returns:
None
"""
try:
course_key = CourseKey.from_string(course_id)
is_credit_course = CreditCourse.is_credit_course(course_key)
if is_credit_course:
course = modulestore().get_course(course_key)
requirements = _get_course_credit_requirements(course)
set_credit_requirements(course_key, requirements)
except (InvalidKeyError, ItemNotFoundError, InvalidCreditRequirements) as exc:
LOGGER.error("Error on adding the requirements for course %s - %s", course_id, unicode(exc))
raise update_credit_course_requirements.retry(args=[course_id], exc=exc)
else:
LOGGER.info("Requirements added for course %s", course_id)
示例5: test_is_credit_course
# 需要导入模块: from openedx.core.djangoapps.credit.models import CreditCourse [as 别名]
# 或者: from openedx.core.djangoapps.credit.models.CreditCourse import is_credit_course [as 别名]
def test_is_credit_course(self, is_credit):
CreditCourse(course_key=self.course_key, enabled=is_credit).save()
if is_credit:
self.assertTrue(CreditCourse.is_credit_course(self.course_key))
else:
self.assertFalse(CreditCourse.is_credit_course(self.course_key))