當前位置: 首頁>>代碼示例>>Python>>正文


Python factories.SampleCourseFactory類代碼示例

本文整理匯總了Python中xmodule.modulestore.tests.factories.SampleCourseFactory的典型用法代碼示例。如果您正苦於以下問題:Python SampleCourseFactory類的具體用法?Python SampleCourseFactory怎麽用?Python SampleCourseFactory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了SampleCourseFactory類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: setUp

    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,代碼行數:25,代碼來源:test_views.py

示例2: setUpClass

    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,代碼行數:9,代碼來源:test_api.py

示例3: test_hide_from_toc

    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,代碼行數:49,代碼來源:test_navigation.py

示例4: setUpClass

 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,代碼行數:19,代碼來源:test_api.py

示例5: setUp

 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,代碼行數:5,代碼來源:test_block_counts.py

示例6: _create_course

 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,代碼行數:6,代碼來源:test_api.py

示例7: setUp

 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,代碼行數:6,代碼來源:test_api.py


注:本文中的xmodule.modulestore.tests.factories.SampleCourseFactory類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。