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


Python api.get_course_milestones函数代码示例

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


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


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