• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python api.get_course_milestones函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_add_course_milestone

    def test_add_course_milestone(self):
        """ Unit Test: test_add_course_milestone """
        with self.assertNumQueries(3):
            api.add_course_milestone(
                self.test_course_key,
                self.relationship_types['REQUIRES'],
                self.test_milestone
            )
        requirer_milestones = api.get_course_milestones(
            self.test_course_key,
            self.relationship_types['REQUIRES']
        )
        self.assertEqual(len(requirer_milestones), 1)

        with self.assertNumQueries(3):
            api.add_course_milestone(
                self.test_prerequisite_course_key,
                self.relationship_types['FULFILLS'],
                self.test_milestone
            )
        fulfiller_milestones = api.get_course_milestones(
            self.test_prerequisite_course_key,
            self.relationship_types['FULFILLS'],
        )
        self.assertEqual(len(fulfiller_milestones), 1)
开发者ID:edx,项目名称:edx-milestones,代码行数:25,代码来源:test_api.py


示例2: fulfill_course_milestone

def fulfill_course_milestone(course_key, user):
    """
    Marks the course specified by the given course_key as complete for the given user.
    If any other courses require this course as a prerequisite, their milestones will be appropriately updated.
    """
    if not settings.FEATURES.get('MILESTONES_APP'):
        return None
    try:
        course_milestones = milestones_api.get_course_milestones(course_key=course_key, relationship="fulfills")
    except InvalidMilestoneRelationshipTypeException:
        # we have not seeded milestone relationship types
        seed_milestone_relationship_types()
        course_milestones = milestones_api.get_course_milestones(course_key=course_key, relationship="fulfills")
    for milestone in course_milestones:
        milestones_api.add_user_milestone({'id': user.id}, milestone)
开发者ID:CraftAcademy,项目名称:edx-platform,代码行数:15,代码来源:milestones_helpers.py


示例3: test_remove_content_references

    def test_remove_content_references(self):
        """ Unit Test: test_remove_content_references """
        # Add a course dependency on the test milestone
        api.add_course_milestone(
            self.test_course_key,
            self.relationship_types['REQUIRES'],
            self.test_milestone
        )
        self.assertEqual(len(api.get_course_milestones(self.test_course_key)), 1)

        # Add a content fulfillment for the test milestone
        api.add_course_content_milestone(
            self.test_course_key,
            self.test_content_key,
            self.relationship_types['FULFILLS'],
            self.test_milestone
        )
        milestones = api.get_course_content_milestones(self.test_course_key, self.test_content_key)
        self.assertEqual(len(milestones), 1)

        # Remove the content dependency
        with self.assertNumQueries(2):
            api.remove_content_references(self.test_content_key)
        milestones = api.get_course_content_milestones(self.test_course_key, self.test_content_key)
        self.assertEqual(len(milestones), 0)
开发者ID:edx,项目名称:edx-milestones,代码行数:25,代码来源:test_api.py


示例4: test_remove_course_milestone

 def test_remove_course_milestone(self):
     """ Unit Test: test_remove_course_milestone """
     api.add_course_milestone(
         self.test_course_key,
         self.relationship_types['REQUIRES'],
         self.test_milestone
     )
     requirer_milestones = api.get_course_milestones(
         self.test_course_key,
         self.relationship_types['REQUIRES']
     )
     self.assertEqual(len(requirer_milestones), 1)
     with self.assertNumQueries(2):
         api.remove_course_milestone(self.test_course_key, self.test_milestone)
     requirer_milestones = api.get_course_milestones(self.test_course_key)
     self.assertEqual(len(requirer_milestones), 0)
开发者ID:edx,项目名称:edx-milestones,代码行数:16,代码来源:test_api.py


示例5: get_course_milestones

def get_course_milestones(course_id):
    """
    Client API operation adapter/wrapper
    """
    if not settings.FEATURES.get('MILESTONES_APP'):
        return []
    return milestones_api.get_course_milestones(course_id)
开发者ID:CraftAcademy,项目名称:edx-platform,代码行数:7,代码来源:milestones_helpers.py


示例6: get_course_milestones

def get_course_milestones(course_id):
    """
    Client API operation adapter/wrapper
    """
    if not settings.FEATURES.get('MILESTONES_APP', False):
        return []
    from milestones import api as milestones_api
    return milestones_api.get_course_milestones(course_id)
开发者ID:adoosii,项目名称:edx-platform,代码行数:8,代码来源:milestones_helpers.py


示例7: remove_course_milestones

def remove_course_milestones(course_key, user, relationship):
    """
    Remove all user milestones for the course specified by course_key.
    """
    if not settings.FEATURES.get('MILESTONES_APP'):
        return None
    course_milestones = milestones_api.get_course_milestones(course_key=course_key, relationship=relationship)
    for milestone in course_milestones:
        milestones_api.remove_user_milestone({'id': user.id}, milestone)
开发者ID:CraftAcademy,项目名称:edx-platform,代码行数:9,代码来源:milestones_helpers.py


示例8: fulfill_course_milestone

def fulfill_course_milestone(course_key, user):
    """
    Marks the course specified by the given course_key as complete for the given user.
    If any other courses require this course as a prerequisite, their milestones will be appropriately updated.
    """
    if settings.FEATURES.get('MILESTONES_APP', False):
        course_milestones = get_course_milestones(course_key=course_key, relationship="fulfills")
        for milestone in course_milestones:
            add_user_milestone({'id': user.id}, milestone)
开发者ID:mrgnr,项目名称:edx-platform,代码行数:9,代码来源:milestones_helpers.py


示例9: test_get_course_milestones_with_invalid_relationship_type

 def test_get_course_milestones_with_invalid_relationship_type(self):
     """ Unit Test: test_get_course_milestones_with_invalid_relationship_type """
     api.add_course_milestone(
         self.test_course_key,
         self.relationship_types['REQUIRES'],
         self.test_milestone
     )
     with self.assertNumQueries(1):
         requirer_milestones = api.get_course_milestones(
             self.test_course_key,
             'INVALID RELATIONSHIP TYPE'
         )
     self.assertEqual(len(requirer_milestones), 0)
开发者ID:edx,项目名称:edx-milestones,代码行数:13,代码来源:test_api.py


示例10: set_prerequisite_courses

def set_prerequisite_courses(course_key, prerequisite_course_keys):
    """
    It would remove any existing requirement milestones for the given `course_key`
    and create new milestones for each pre-requisite course in `prerequisite_course_keys`.
    To only remove course milestones pass `course_key` and empty list or
    None as `prerequisite_course_keys` .
    """
    if settings.FEATURES.get('MILESTONES_APP', False):
        #remove any existing requirement milestones with this pre-requisite course as requirement
        course_milestones = get_course_milestones(course_key=course_key, relationship="requires")
        if course_milestones:
            for milestone in course_milestones:
                remove_prerequisite_course(course_key, milestone)

        # add milestones if pre-requisite course is selected
        if prerequisite_course_keys:
            for prerequisite_course_key_string in prerequisite_course_keys:
                prerequisite_course_key = CourseKey.from_string(prerequisite_course_key_string)
                add_prerequisite_course(course_key, prerequisite_course_key)
开发者ID:mrgnr,项目名称:edx-platform,代码行数:19,代码来源:milestones_helpers.py


示例11: set_prerequisite_courses

def set_prerequisite_courses(course_key, prerequisite_course_keys):
    """
    It would remove any existing requirement milestones for the given `course_key`
    and create new milestones for each pre-requisite course in `prerequisite_course_keys`.
    To only remove course milestones pass `course_key` and empty list or
    None as `prerequisite_course_keys` .
    """
    if not is_prerequisite_courses_enabled():
        return None
    #remove any existing requirement milestones with this pre-requisite course as requirement
    course_milestones = milestones_api.get_course_milestones(course_key=course_key, relationship="requires")
    if course_milestones:
        for milestone in course_milestones:
            remove_prerequisite_course(course_key, milestone)

    # add milestones if pre-requisite course is selected
    if prerequisite_course_keys:
        for prerequisite_course_key_string in prerequisite_course_keys:
            prerequisite_course_key = CourseKey.from_string(prerequisite_course_key_string)
            add_prerequisite_course(course_key, prerequisite_course_key)
开发者ID:CraftAcademy,项目名称:edx-platform,代码行数:20,代码来源:milestones_helpers.py


示例12: set_prerequisite_courses

def set_prerequisite_courses(course_key, prerequisite_course_keys):
    """
    It would remove any existing requirement milestones for the given `course_key`
    and create new milestones for each pre-requisite course in `prerequisite_course_keys`.
    To only remove course milestones pass `course_key` and empty list or
    None as `prerequisite_course_keys` .
    """
    if not settings.FEATURES.get('ENABLE_PREREQUISITE_COURSES', False):
        return None
    from milestones import api as milestones_api
    #remove any existing requirement milestones with this pre-requisite course as requirement
    course_milestones = milestones_api.get_course_milestones(course_key=course_key, relationship="requires")
    if course_milestones:
        for milestone in course_milestones:
            remove_prerequisite_course(course_key, milestone)

    # add milestones if pre-requisite course is selected
    if prerequisite_course_keys:
        for prerequisite_course_key_string in prerequisite_course_keys:
            prerequisite_course_key = CourseKey.from_string(prerequisite_course_key_string)
            add_prerequisite_course(course_key, prerequisite_course_key)
开发者ID:nttks,项目名称:edx-platform,代码行数:21,代码来源:milestones_helpers.py


示例13: test_contentstore_views_entrance_exam_delete

        def test_contentstore_views_entrance_exam_delete(self):
            """
            Unit Test: test_contentstore_views_entrance_exam_delete
            """
            resp = self.client.post(self.exam_url, {}, http_accept='application/json')
            self.assertEqual(resp.status_code, 201)
            resp = self.client.get(self.exam_url)
            self.assertEqual(resp.status_code, 200)
            resp = self.client.delete(self.exam_url)
            self.assertEqual(resp.status_code, 204)
            resp = self.client.get(self.exam_url)
            self.assertEqual(resp.status_code, 404)

            user = User.objects.create(
                username='test_user',
                email='[email protected]',
                is_active=True,
            )
            user.set_password('test')
            user.save()
            milestones = milestones_api.get_course_milestones(unicode(self.course_key))
            self.assertEqual(len(milestones), 1)
            milestone_key = '{}.{}'.format(milestones[0]['namespace'], milestones[0]['name'])
            paths = milestones_api.get_course_milestones_fulfillment_paths(
                unicode(self.course_key),
                serialize_user(user)
            )

            # What we have now is a course milestone requirement and no valid fulfillment
            # paths for the specified user.  The LMS is going to have to ignore this situation,
            # because we can't confidently prevent it from occuring at some point in the future.
            # milestone_key_1 =
            self.assertEqual(len(paths[milestone_key]), 0)

            # Re-adding an entrance exam to the course should fix the missing link
            # It wipes out any old entrance exam artifacts and inserts a new exam course chapter/module
            resp = self.client.post(self.exam_url, {}, http_accept='application/json')
            self.assertEqual(resp.status_code, 201)
            resp = self.client.get(self.exam_url)
            self.assertEqual(resp.status_code, 200)
开发者ID:akbargumbira,项目名称:Labster.EdX,代码行数:40,代码来源:test_entrance_exam.py


示例14: test_contentstore_views_entrance_exam_post

        def test_contentstore_views_entrance_exam_post(self):
            """
            Unit Test: test_contentstore_views_entrance_exam_post
            """
            resp = self.client.post(self.exam_url, {}, http_accept='application/json')
            self.assertEqual(resp.status_code, 201)
            resp = self.client.get(self.exam_url)
            self.assertEqual(resp.status_code, 200)

            # Reload the test course now that the exam module has been added
            self.course = modulestore().get_course(self.course.id)
            metadata = CourseMetadata.fetch_all(self.course)
            self.assertTrue(metadata['entrance_exam_enabled'])
            self.assertIsNotNone(metadata['entrance_exam_minimum_score_pct'])
            self.assertIsNotNone(metadata['entrance_exam_id']['value'])
            self.assertTrue(len(milestones_api.get_course_milestones(unicode(self.course.id))))
            content_milestones = milestones_api.get_course_content_milestones(
                unicode(self.course.id),
                metadata['entrance_exam_id']['value'],
                self.milestone_relationship_types['FULFILLS']
            )
            self.assertTrue(len(content_milestones))
开发者ID:akbargumbira,项目名称:Labster.EdX,代码行数:22,代码来源:test_entrance_exam.py


示例15: test_remove_course_milestone_missing_milestone

 def test_remove_course_milestone_missing_milestone(self):
     """ Unit Test: test_remove_course_milestone_missing_milestone """
     with self.assertNumQueries(1):
         api.remove_course_milestone(self.test_course_key, self.test_milestone)
     requirer_milestones = api.get_course_milestones(self.test_course_key)
     self.assertEqual(len(requirer_milestones), 0)
开发者ID:edx,项目名称:edx-milestones,代码行数:6,代码来源:test_api.py


示例16: test_get_course_unfulfilled_milestones

    def test_get_course_unfulfilled_milestones(self):
        """ Unit Test: test_get_course_unfulfilled_milestones """
        namespace = 'test_get_milestones'
        milestone1 = api.add_milestone({
            'name': 'localmilestone1',
            'display_name': 'Local Milestone 1',
            'namespace': namespace,
            'description': 'Local Milestone 1 Description'
        })
        api.add_course_milestone(
            self.test_course_key,
            self.relationship_types['REQUIRES'],
            milestone1
        )

        milestone2 = api.add_milestone({
            'name': 'localmilestone2',
            'display_name': 'Local Milestone 2',
            'namespace': namespace,
            'description': 'Local Milestone 2 Description'
        })
        api.add_course_milestone(
            self.test_course_key,
            self.relationship_types['REQUIRES'],
            milestone2
        )

        # Confirm that the course has only two milestones, and that the User still needs to collect both
        course_milestones = api.get_course_milestones(self.test_course_key)
        self.assertEqual(len(course_milestones), 2)
        with self.assertNumQueries(2):
            required_milestones = api.get_course_required_milestones(
                self.test_course_key,
                self.serialized_test_user
            )

        # Link the User to Milestone 2 (this one is now 'collected')
        api.add_user_milestone(self.serialized_test_user, milestone2)
        user_milestones = api.get_user_milestones(self.serialized_test_user, namespace=namespace)
        self.assertEqual(len(user_milestones), 1)
        self.assertEqual(user_milestones[0]['id'], milestone2['id'])

        # Only Milestone 1 should be listed as 'required' for the course at this point
        with self.assertNumQueries(2):
            required_milestones = api.get_course_required_milestones(
                self.test_course_key,
                self.serialized_test_user
            )
        self.assertEqual(len(required_milestones), 1)
        self.assertEqual(required_milestones[0]['id'], milestone1['id'])

        # Link the User to Milestone 1 (this one is now 'collected', as well)
        api.add_user_milestone(self.serialized_test_user, milestone1)
        user_milestones = api.get_user_milestones(self.serialized_test_user, namespace=namespace)
        self.assertEqual(len(user_milestones), 2)

        # And there should be no more Milestones required for this User+Course
        with self.assertNumQueries(2):
            required_milestones = api.get_course_required_milestones(
                self.test_course_key,
                self.serialized_test_user
            )
        self.assertEqual(len(required_milestones), 0)
开发者ID:edx,项目名称:edx-milestones,代码行数:63,代码来源:test_api.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python milkman.deliver函数代码示例发布时间:2022-05-27
下一篇:
Python api.get_course_content_milestones函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap