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


Python models.CreditCourse类代码示例

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


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

示例1: add_credit_course

 def add_credit_course(self, enabled=True):
     """
     Mark the course as a credit.
     """
     credit_course = CreditCourse(course_key=self.course_key, enabled=enabled)
     credit_course.save()
     return credit_course
开发者ID:mtorrisi,项目名称:edx-platform,代码行数:7,代码来源:test_api.py

示例2: test_course_details_with_enabled_setting

    def test_course_details_with_enabled_setting(self):
        """
        Test that credit eligibility requirements are present in
        response if the feature flag 'ENABLE_CREDIT_ELIGIBILITY' is enabled.
        """
        # verify that credit eligibility requirements block don't show if the
        # course is not set as credit course
        response = self.client.get_html(self.course_details_url)
        self.assertEqual(response.status_code, 200)
        self.assertNotContains(response, "Course Credit Requirements")
        self.assertNotContains(response, "Steps required to earn course credit")

        # verify that credit eligibility requirements block shows if the
        # course is set as credit course and it has eligibility requirements
        credit_course = CreditCourse(course_key=unicode(self.course.id), enabled=True)
        credit_course.save()
        self.assertEqual(len(get_credit_requirements(self.course.id)), 0)
        # test that after publishing course, minimum grade requirement is added
        on_course_publish(self.course.id)
        self.assertEqual(len(get_credit_requirements(self.course.id)), 1)

        response = self.client.get_html(self.course_details_url)
        self.assertEqual(response.status_code, 200)
        self.assertContains(response, "Course Credit Requirements")
        self.assertContains(response, "Steps required to earn course credit")
开发者ID:AlexxNica,项目名称:edx-platform,代码行数:25,代码来源:test_credit_eligibility.py

示例3: add_credit_course

    def add_credit_course(self):
        """ Add the course as a credit

        Returns:
            CreditCourse object
        """
        credit_course = CreditCourse(course_key=self.course_key, enabled=True)
        credit_course.save()
        return credit_course
开发者ID:ahmadiga,项目名称:min_edx,代码行数:9,代码来源:test_models.py

示例4: add_credit_course

    def add_credit_course(self, course_key):
        """Add the course as a credit.

        Args:
            course_key(CourseKey): Identifier for the course

        Returns:
            CreditCourse object added
        """
        credit_course = CreditCourse(course_key=course_key, enabled=True)
        credit_course.save()
        return credit_course
开发者ID:digitalsatori,项目名称:edx-platform,代码行数:12,代码来源:test_tasks.py

示例5: update_course_requirements

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)
开发者ID:ISCLC,项目名称:edx-platform-for-isc,代码行数:29,代码来源:tasks.py

示例6: set_credit_requirements

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,代码行数:56,代码来源:eligibility.py

示例7: is_credit_course

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)
开发者ID:28554010,项目名称:edx-platform,代码行数:12,代码来源:eligibility.py

示例8: update_credit_course_requirements

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)
开发者ID:digitalsatori,项目名称:edx-platform,代码行数:22,代码来源:tasks.py

示例9: update_credit_course_requirements

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)
开发者ID:ramakpuppala,项目名称:edx-platform,代码行数:22,代码来源:tasks.py

示例10: test_is_credit_course

 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))
开发者ID:ahmadiga,项目名称:min_edx,代码行数:6,代码来源:test_models.py


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