本文整理汇总了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)
示例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)
示例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)
示例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', {}, []),
]),
]),
])
]
)
示例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)
示例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()
示例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