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


Python SampleCourseFactory.create方法代码示例

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


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

示例1: setUp

# 需要导入模块: from xmodule.modulestore.tests.factories import SampleCourseFactory [as 别名]
# 或者: from xmodule.modulestore.tests.factories.SampleCourseFactory import create [as 别名]
    def setUp(self):
        """
        Set up courses and enrollments.
        """
        super(TestStudentViewsWithCCX, self).setUp()

        # Create a Draft Mongo and a Split Mongo course and enroll a student user in them.
        self.student_password = "foobar"
        self.student = UserFactory.create(username="test", password=self.student_password, is_staff=False)
        self.draft_course = SampleCourseFactory.create(default_store=ModuleStoreEnum.Type.mongo)
        self.split_course = SampleCourseFactory.create(default_store=ModuleStoreEnum.Type.split)
        CourseEnrollment.enroll(self.student, self.draft_course.id)
        CourseEnrollment.enroll(self.student, self.split_course.id)

        # Create a CCX coach.
        self.coach = AdminFactory.create()
        role = CourseCcxCoachRole(self.split_course.id)
        role.add_users(self.coach)

        # Create a CCX course and enroll the user in it.
        self.ccx = CcxFactory(course_id=self.split_course.id, coach=self.coach)
        last_week = datetime.datetime.now(UTC()) - datetime.timedelta(days=7)
        override_field_for_ccx(self.ccx, self.split_course, 'start', last_week)  # Required by self.ccx.has_started().
        self.ccx_course_key = CCXLocator.from_course_locator(self.split_course.id, self.ccx.id)
        CourseEnrollment.enroll(self.student, self.ccx_course_key)
开发者ID:Akif-Vohra,项目名称:edx-platform,代码行数:27,代码来源:test_views.py

示例2: setUpClass

# 需要导入模块: from xmodule.modulestore.tests.factories import SampleCourseFactory [as 别名]
# 或者: from xmodule.modulestore.tests.factories.SampleCourseFactory import create [as 别名]
    def setUpClass(cls):
        super(TestGetBlocks, cls).setUpClass()
        with cls.store.default_store(ModuleStoreEnum.Type.split):
            cls.course = SampleCourseFactory.create()

        # hide the html block
        cls.html_block = cls.store.get_item(cls.course.id.make_usage_key('html', 'html_x1a_1'))
        cls.html_block.visible_to_staff_only = True
        cls.store.update_item(cls.html_block, ModuleStoreEnum.UserID.test)
开发者ID:Lektorium-LLC,项目名称:edx-platform,代码行数:11,代码来源:test_api.py

示例3: test_hide_from_toc

# 需要导入模块: from xmodule.modulestore.tests.factories import SampleCourseFactory [as 别名]
# 或者: from xmodule.modulestore.tests.factories.SampleCourseFactory import create [as 别名]
    def test_hide_from_toc(self):
        course_key = SampleCourseFactory.create().id
        course_usage_key = self.store.make_course_usage_key(course_key)

        # hide chapter_x from TOC
        chapter_x_key = course_key.make_usage_key('chapter', 'chapter_x')
        chapter_x = self.store.get_item(chapter_x_key)
        chapter_x.hide_from_toc = True
        self.store.update_item(chapter_x, ModuleStoreEnum.UserID.test)

        block_structure = BlockStructureFactory.create_from_modulestore(course_usage_key, self.store)

        # collect phase
        BlockDepthTransformer.collect(block_structure)
        BlockNavigationTransformer.collect(block_structure)
        block_structure._collect_requested_xblock_fields()

        self.assertIn(chapter_x_key, block_structure)

        # transform phase
        BlockDepthTransformer().transform(usage_info=None, block_structure=block_structure)
        BlockNavigationTransformer(0).transform(usage_info=None, block_structure=block_structure)
        block_structure._prune_unreachable()

        self.assertIn(chapter_x_key, block_structure)

        course_descendants = block_structure.get_transformer_block_field(
            course_usage_key,
            BlockNavigationTransformer,
            BlockNavigationTransformer.BLOCK_NAVIGATION,
        )

        # chapter_y and its descendants should be included
        for block_key in [
                course_key.make_usage_key('chapter', 'chapter_y'),
                course_key.make_usage_key('sequential', 'sequential_y1'),
                course_key.make_usage_key('vertical', 'vertical_y1a'),
                course_key.make_usage_key('problem', 'problem_y1a_1'),
        ]:
            self.assertIn(unicode(block_key), course_descendants)

        # chapter_x and its descendants should not be included
        for block_key in [
                chapter_x_key,
                course_key.make_usage_key('sequential', 'sequential_x1'),
                course_key.make_usage_key('vertical', 'vertical_x1a'),
                course_key.make_usage_key('problem', 'problem_x1a_1'),
        ]:
            self.assertNotIn(unicode(block_key), course_descendants)
开发者ID:shevious,项目名称:edx-platform,代码行数:51,代码来源:test_navigation.py

示例4: setUpClass

# 需要导入模块: from xmodule.modulestore.tests.factories import SampleCourseFactory [as 别名]
# 或者: from xmodule.modulestore.tests.factories.SampleCourseFactory import create [as 别名]
 def setUpClass(cls):
     super(TestGetBlocksMobileHack, cls).setUpClass()
     with cls.store.default_store(ModuleStoreEnum.Type.split):
         cls.course = SampleCourseFactory.create(
             block_info_tree=[
                 BlockInfo('empty_chapter', 'chapter', {}, [
                     BlockInfo('empty_sequential', 'sequential', {}, [
                         BlockInfo('empty_vertical', 'vertical', {}, []),
                     ]),
                 ]),
                 BlockInfo('full_chapter', 'chapter', {}, [
                     BlockInfo('full_sequential', 'sequential', {}, [
                         BlockInfo('full_vertical', 'vertical', {}, [
                             BlockInfo('html', 'html', {}, []),
                         ]),
                     ]),
                 ])
             ]
         )
开发者ID:digitalsatori,项目名称:edx-platform,代码行数:21,代码来源:test_api.py

示例5: setUp

# 需要导入模块: from xmodule.modulestore.tests.factories import SampleCourseFactory [as 别名]
# 或者: from xmodule.modulestore.tests.factories.SampleCourseFactory import create [as 别名]
 def setUp(self):
     super(TestBlockCountsTransformer, self).setUp()
     self.course_key = SampleCourseFactory.create().id
     self.course_usage_key = self.store.make_course_usage_key(self.course_key)
     self.block_structure = BlockStructureFactory.create_from_modulestore(self.course_usage_key, self.store)
开发者ID:digitalsatori,项目名称:edx-platform,代码行数:7,代码来源:test_block_counts.py

示例6: _create_course

# 需要导入模块: from xmodule.modulestore.tests.factories import SampleCourseFactory [as 别名]
# 或者: from xmodule.modulestore.tests.factories.SampleCourseFactory import create [as 别名]
 def _create_course(self, store_type):
     """
     Creates the sample course in the given store type.
     """
     with self.store.default_store(store_type):
         return SampleCourseFactory.create()
开发者ID:Lektorium-LLC,项目名称:edx-platform,代码行数:8,代码来源:test_api.py

示例7: setUp

# 需要导入模块: from xmodule.modulestore.tests.factories import SampleCourseFactory [as 别名]
# 或者: from xmodule.modulestore.tests.factories.SampleCourseFactory import create [as 别名]
 def setUp(self):
     super(TestGetBlocks, self).setUp()
     self.course = SampleCourseFactory.create()
     self.user = UserFactory.create()
     self.request = RequestFactory().get("/dummy")
     self.request.user = self.user
开发者ID:Certific-NET,项目名称:edx-platform,代码行数:8,代码来源:test_api.py


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