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


Python BlockUsageLocator.make_relative方法代码示例

本文整理汇总了Python中xmodule.modulestore.locator.BlockUsageLocator.make_relative方法的典型用法代码示例。如果您正苦于以下问题:Python BlockUsageLocator.make_relative方法的具体用法?Python BlockUsageLocator.make_relative怎么用?Python BlockUsageLocator.make_relative使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在xmodule.modulestore.locator.BlockUsageLocator的用法示例。


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

示例1: test_relative

# 需要导入模块: from xmodule.modulestore.locator import BlockUsageLocator [as 别名]
# 或者: from xmodule.modulestore.locator.BlockUsageLocator import make_relative [as 别名]
 def test_relative(self):
     """
     Test making a relative usage locator.
     """
     package_id = 'mit.eecs-1'
     branch = 'foo'
     baseobj = CourseLocator(package_id=package_id, branch=branch)
     block_id = 'problem:with-colon~2'
     testobj = BlockUsageLocator.make_relative(baseobj, block_id)
     self.check_block_locn_fields(
         testobj, 'Cannot make relative to course', package_id=package_id, branch=branch, block=block_id
     )
     block_id = 'completely_different'
     testobj = BlockUsageLocator.make_relative(testobj, block_id)
     self.check_block_locn_fields(
         testobj, 'Cannot make relative to block usage', package_id=package_id, branch=branch, block=block_id
     )
开发者ID:Caesar73,项目名称:edx-platform,代码行数:19,代码来源:test_locators.py

示例2: test_relative

# 需要导入模块: from xmodule.modulestore.locator import BlockUsageLocator [as 别名]
# 或者: from xmodule.modulestore.locator.BlockUsageLocator import make_relative [as 别名]
 def test_relative(self):
     """
     Test making a relative usage locator.
     """
     org = 'mit.eecs'
     offering = '1'
     branch = 'foo'
     baseobj = CourseLocator(org=org, offering=offering, branch=branch)
     block_id = 'problem:with-colon~2'
     testobj = BlockUsageLocator.make_relative(baseobj, 'problem', block_id)
     self.check_block_locn_fields(
         testobj, org=org, offering=offering, branch=branch, block=block_id
     )
     block_id = 'completely_different'
     testobj = BlockUsageLocator.make_relative(testobj, 'problem', block_id)
     self.check_block_locn_fields(
         testobj, org=org, offering=offering, branch=branch, block=block_id
     )
开发者ID:aemilcar,项目名称:edx-platform,代码行数:20,代码来源:test_locators.py

示例3: test_block_generations

# 需要导入模块: from xmodule.modulestore.locator import BlockUsageLocator [as 别名]
# 或者: from xmodule.modulestore.locator.BlockUsageLocator import make_relative [as 别名]
    def test_block_generations(self):
        """
        Test get_block_generations
        """
        test_course = persistent_factories.PersistentCourseFactory.create(
            offering='history.hist101', org='edu.harvard',
            display_name='history test course',
            user_id='testbot'
        )
        chapter = persistent_factories.ItemFactory.create(display_name='chapter 1',
            parent_location=test_course.location, user_id='testbot')
        sub = persistent_factories.ItemFactory.create(display_name='subsection 1',
            parent_location=chapter.location, user_id='testbot', category='vertical')
        first_problem = persistent_factories.ItemFactory.create(
            display_name='problem 1', parent_location=sub.location, user_id='testbot', category='problem',
            data="<problem></problem>"
        )
        first_problem.max_attempts = 3
        first_problem.save()  # decache the above into the kvs
        updated_problem = modulestore('split').update_item(first_problem, '**replace_user**')
        self.assertIsNotNone(updated_problem.previous_version)
        self.assertEqual(updated_problem.previous_version, first_problem.update_version)
        self.assertNotEqual(updated_problem.update_version, first_problem.update_version)
        updated_loc = modulestore('split').delete_item(updated_problem.location, 'testbot', delete_children=True)

        second_problem = persistent_factories.ItemFactory.create(
            display_name='problem 2',
            parent_location=BlockUsageLocator.make_relative(
                updated_loc, block_type='problem', block_id=sub.location.block_id
            ),
            user_id='testbot', category='problem',
            data="<problem></problem>"
        )

        # course root only updated 2x
        version_history = modulestore('split').get_block_generations(test_course.location)
        self.assertEqual(version_history.locator.version_guid, test_course.location.version_guid)
        self.assertEqual(len(version_history.children), 1)
        self.assertEqual(version_history.children[0].children, [])
        self.assertEqual(version_history.children[0].locator.version_guid, chapter.location.version_guid)

        # sub changed on add, add problem, delete problem, add problem in strict linear seq
        version_history = modulestore('split').get_block_generations(sub.location)
        self.assertEqual(len(version_history.children), 1)
        self.assertEqual(len(version_history.children[0].children), 1)
        self.assertEqual(len(version_history.children[0].children[0].children), 1)
        self.assertEqual(len(version_history.children[0].children[0].children[0].children), 0)

        # first and second problem may show as same usage_id; so, need to ensure their histories are right
        version_history = modulestore('split').get_block_generations(updated_problem.location)
        self.assertEqual(version_history.locator.version_guid, first_problem.location.version_guid)
        self.assertEqual(len(version_history.children), 1)  # updated max_attempts
        self.assertEqual(len(version_history.children[0].children), 0)

        version_history = modulestore('split').get_block_generations(second_problem.location)
        self.assertNotEqual(version_history.locator.version_guid, first_problem.location.version_guid)
开发者ID:PaoloC68,项目名称:edx-platform,代码行数:58,代码来源:test_crud.py

示例4: mapper

# 需要导入模块: from xmodule.modulestore.locator import BlockUsageLocator [as 别名]
# 或者: from xmodule.modulestore.locator.BlockUsageLocator import make_relative [as 别名]
 def mapper(found_id):
     """
     Convert the found id to Location block_id
     """
     locator = BlockUsageLocator.make_relative(from_base_addr, found_id)
     return loc_mapper().translate_locator_to_location(locator).name
开发者ID:Caesar73,项目名称:edx-platform,代码行数:8,代码来源:mixed.py


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