本文整理汇总了Python中xmodule.modulestore.tests.factories.ItemFactory类的典型用法代码示例。如果您正苦于以下问题:Python ItemFactory类的具体用法?Python ItemFactory怎么用?Python ItemFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ItemFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_xblock_studio_url
def test_xblock_studio_url(self):
# Verify course URL
course_url = u"/course/{}".format(unicode(self.course.id))
self.assertEqual(xblock_studio_url(self.course), course_url)
# Verify chapter URL
chapter = ItemFactory.create(parent_location=self.course.location, category="chapter", display_name="Week 1")
self.assertEqual(xblock_studio_url(chapter), u"{}?show={}".format(course_url, http.urlquote(chapter.location)))
# Verify sequential URL
sequential = ItemFactory.create(
parent_location=chapter.location, category="sequential", display_name="Lesson 1"
)
self.assertEqual(
xblock_studio_url(sequential), u"{}?show={}".format(course_url, http.urlquote(sequential.location))
)
# Verify unit URL
vertical = ItemFactory.create(parent_location=sequential.location, category="vertical", display_name="Unit")
self.assertEqual(xblock_studio_url(vertical), u"/container/{}".format(vertical.location))
# Verify child vertical URL
child_vertical = ItemFactory.create(
parent_location=vertical.location, category="vertical", display_name="Child Vertical"
)
self.assertEqual(xblock_studio_url(child_vertical), u"/container/{}".format(child_vertical.location))
# Verify video URL
video = ItemFactory.create(parent_location=child_vertical.location, category="video", display_name="My Video")
self.assertIsNone(xblock_studio_url(video))
示例2: setUp
def setUp(self):
self.course = CourseFactory.create(number='999', display_name='Robot_Super_Course')
self.overview_chapter = ItemFactory.create(display_name='Overview')
self.courseware_chapter = ItemFactory.create(display_name='courseware')
self.test_course = CourseFactory.create(number='666', display_name='Robot_Sub_Course')
self.other_org_course = CourseFactory.create(org='Other_Org_Course')
self.sub_courseware_chapter = ItemFactory.create(
parent_location=self.test_course.location, display_name='courseware'
)
self.sub_overview_chapter = ItemFactory.create(
parent_location=self.sub_courseware_chapter.location,
display_name='Overview'
)
self.welcome_section = ItemFactory.create(
parent_location=self.overview_chapter.location,
display_name='Welcome'
)
self.global_staff_user = GlobalStaffFactory()
self.unenrolled_user = UserFactory(last_name="Unenrolled")
self.enrolled_user = UserFactory(last_name="Enrolled")
CourseEnrollmentFactory(user=self.enrolled_user, course_id=self.course.id)
CourseEnrollmentFactory(user=self.enrolled_user, course_id=self.test_course.id)
self.staff_user = StaffFactory(course=self.course.location)
self.instructor_user = InstructorFactory(
course=self.course.location)
self.org_staff_user = OrgStaffFactory(course=self.course.location)
self.org_instructor_user = OrgInstructorFactory(
course=self.course.location)
示例3: test_repeated_course_module_instantiation
def test_repeated_course_module_instantiation(self, loops, default_store, course_depth):
with modulestore().default_store(default_store):
course = CourseFactory.create()
chapter = ItemFactory(parent=course, category='chapter', graded=True)
section = ItemFactory(parent=chapter, category='sequential')
__ = ItemFactory(parent=section, category='problem')
fake_request = self.factory.get(
reverse('progress', kwargs={'course_id': unicode(course.id)})
)
course = modulestore().get_course(course.id, depth=course_depth)
for _ in xrange(loops):
field_data_cache = FieldDataCache.cache_for_descriptor_descendents(
course.id, self.user, course, depth=course_depth
)
course_module = get_module_for_descriptor(
self.user,
fake_request,
course,
field_data_cache,
course.id,
course=course
)
for chapter in course_module.get_children():
for section in chapter.get_children():
for item in section.get_children():
self.assertTrue(item.graded)
示例4: setup_course
def setup_course(self):
self.course = CourseFactory.create(data=self.COURSE_DATA)
# Turn off cache.
modulestore().request_cache = None
modulestore().metadata_inheritance_cache_subsystem = None
chapter = ItemFactory.create(
parent_location=self.course.location,
category="sequential",
)
self.section = ItemFactory.create(
parent_location=chapter.location,
category="sequential"
)
# username = robot{0}, password = 'test'
self.users = [
UserFactory.create()
for i in range(self.USER_COUNT)
]
for user in self.users:
CourseEnrollmentFactory.create(user=user, course_id=self.course.id)
# login all users for acces to Xmodule
self.clients = {user.username: Client() for user in self.users}
self.login_statuses = [
self.clients[user.username].login(
username=user.username, password='test')
for user in self.users
]
self.assertTrue(all(self.login_statuses))
示例5: setUp
def setUp(self):
self.partition = UserPartition(
0,
'first_partition',
'First Partition',
[
Group(0, 'alpha'),
Group(1, 'beta')
]
)
self.course = CourseFactory.create(
number=self.COURSE_NUMBER,
user_partitions=[self.partition]
)
self.chapter = ItemFactory.create(
parent_location=self.course.location,
category="chapter",
display_name="test chapter",
)
self.sequential = ItemFactory.create(
parent_location=self.chapter.location,
category="sequential",
display_name="Split Test Tests",
)
self.student = UserFactory.create()
CourseEnrollmentFactory.create(user=self.student, course_id=self.course.id)
self.client.login(username=self.student.username, password='test')
示例6: _add_entrance_exam
def _add_entrance_exam(self):
""" Sets up entrance exam """
with self.store.bulk_operations(self.course.id):
self.course.entrance_exam_enabled = True
self.entrance_exam = ItemFactory.create(
parent=self.course,
category="chapter",
display_name="Entrance Exam Chapter",
is_entrance_exam=True,
in_entrance_exam=True,
)
self.subsection_1 = ItemFactory.create(
parent=self.entrance_exam,
category='sequential',
display_name="The Only Exam Sequential",
graded=True,
in_entrance_exam=True,
)
self.problem_1 = ItemFactory.create(
parent=self.subsection_1,
category='problem',
display_name="The Only Exam Problem",
graded=True,
in_entrance_exam=True,
)
add_entrance_exam_milestone(self.course, self.entrance_exam)
self.course.entrance_exam_minimum_score_pct = 0.50
self.course.entrance_exam_id = unicode(self.entrance_exam.location)
self.store.update_item(self.course, self.user.id)
示例7: setUpClass
def setUpClass(cls):
super(SplitTestBase, cls).setUpClass()
cls.partition = UserPartition(
0,
'first_partition',
'First Partition',
[
Group(0, 'alpha'),
Group(1, 'beta')
]
)
cls.course = CourseFactory.create(
number=cls.COURSE_NUMBER,
user_partitions=[cls.partition]
)
cls.chapter = ItemFactory.create(
parent_location=cls.course.location,
category="chapter",
display_name="test chapter",
)
cls.sequential = ItemFactory.create(
parent_location=cls.chapter.location,
category="sequential",
display_name="Split Test Tests",
)
示例8: setUp
def setUp(self):
"""
Initial data setup
"""
super(TestHandleItemDeleted, self).setUp()
self.course = CourseFactory.create()
self.course.enable_subsection_gating = True
self.course.save()
self.chapter = ItemFactory.create(
parent=self.course,
category="chapter",
display_name="Chapter"
)
self.open_seq = ItemFactory.create(
parent=self.chapter,
category='sequential',
display_name="Open Sequential"
)
self.gated_seq = ItemFactory.create(
parent=self.chapter,
category='sequential',
display_name="Gated Sequential"
)
gating_api.add_prerequisite(self.course.id, self.open_seq.location)
gating_api.set_required_content(self.course.id, self.gated_seq.location, self.open_seq.location, 100)
示例9: setUp
def setUp(self):
"""
Create a simple course with a video component.
"""
super(AuthoringMixinTestCase, self).setUp()
self.course = CourseFactory.create()
chapter = ItemFactory.create(
category='chapter',
parent_location=self.course.location,
display_name='Test Chapter'
)
sequential = ItemFactory.create(
category='sequential',
parent_location=chapter.location,
display_name='Test Sequential'
)
vertical = ItemFactory.create(
category='vertical',
parent_location=sequential.location,
display_name='Test Vertical'
)
video = ItemFactory.create(
category='video',
parent_location=vertical.location,
display_name='Test Vertical'
)
self.vertical_location = vertical.location
self.video_location = video.location
self.pet_groups = [Group(1, 'Cat Lovers'), Group(2, 'Dog Lovers')]
示例10: setUp
def setUp(self):
"""
Fixtures.
"""
super(TestSetDueDateExtension, self).setUp()
self.due = due = datetime.datetime(2010, 5, 12, 2, 42, tzinfo=utc)
course = CourseFactory.create()
week1 = ItemFactory.create(due=due, parent=course)
week2 = ItemFactory.create(due=due, parent=course)
week3 = ItemFactory.create(parent=course)
homework = ItemFactory.create(parent=week1)
assignment = ItemFactory.create(parent=homework, due=due)
user = UserFactory.create()
self.course = course
self.week1 = week1
self.homework = homework
self.assignment = assignment
self.week2 = week2
self.week3 = week3
self.user = user
inject_field_overrides((course, week1, week2, week3, homework, assignment), course, user)
示例11: setUpClass
def setUpClass(cls):
super(MasqueradeTestCase, cls).setUpClass()
cls.course = CourseFactory.create(number="masquerade-test", metadata={"start": datetime.now(UTC())})
cls.info_page = ItemFactory.create(
category="course_info", parent_location=cls.course.location, data="OOGIE BLOOGIE", display_name="updates"
)
cls.chapter = ItemFactory.create(
parent_location=cls.course.location, category="chapter", display_name="Test Section"
)
cls.sequential_display_name = "Test Masquerade Subsection"
cls.sequential = ItemFactory.create(
parent_location=cls.chapter.location, category="sequential", display_name=cls.sequential_display_name
)
cls.vertical = ItemFactory.create(
parent_location=cls.sequential.location, category="vertical", display_name="Test Unit"
)
problem_xml = OptionResponseXMLFactory().build_xml(
question_text="The correct answer is Correct",
num_inputs=2,
weight=2,
options=["Correct", "Incorrect"],
correct_option="Correct",
)
cls.problem_display_name = "TestMasqueradeProblem"
cls.problem = ItemFactory.create(
parent_location=cls.vertical.location,
category="problem",
data=problem_xml,
display_name=cls.problem_display_name,
)
示例12: setup_course
def setup_course(self, default_store=None):
"""
Helper method to create the course.
"""
if not default_store:
default_store = self.store.default_modulestore.get_modulestore_type()
with self.store.default_store(default_store):
self.course = CourseFactory.create(**self.course_options())
chapter = ItemFactory.create(parent=self.course, category='chapter')
self.vertical_block = ItemFactory.create(
parent_location=chapter.location,
category='vertical',
display_name="Vertical"
)
self.html_block = ItemFactory.create(
parent=self.vertical_block,
category='html',
data="<p>Test HTML Content<p>"
)
# block_name_to_be_tested can be `html_block` or `vertical_block`.
# These attributes help ensure the positive and negative tests are in sync.
self.block_to_be_tested = getattr(self, self.block_name_to_be_tested)
self.block_specific_chrome_html_elements = self.BLOCK_SPECIFIC_CHROME_HTML_ELEMENTS[
self.block_name_to_be_tested
]
示例13: setUp
def setUp(self):
"""
Fixtures.
"""
super(TestDataDumps, self).setUp()
due = datetime.datetime(2010, 5, 12, 2, 42, tzinfo=UTC)
course = CourseFactory.create()
week1 = ItemFactory.create(due=due, parent=course)
week2 = ItemFactory.create(due=due, parent=course)
homework = ItemFactory.create(
parent=week1,
due=due
)
user1 = UserFactory.create()
user2 = UserFactory.create()
self.course = course
self.week1 = week1
self.homework = homework
self.week2 = week2
self.user1 = user1
self.user2 = user2
signals.extract_dates(None, course.id)
示例14: setUp
def setUp(self):
super(GradesServiceTests, self).setUp()
self.service = GradesService()
self.course = CourseFactory.create(org='edX', number='DemoX', display_name='Demo_Course', run='Spring2019')
self.subsection = ItemFactory.create(parent=self.course, category="subsection", display_name="Subsection")
self.subsection_without_grade = ItemFactory.create(
parent=self.course,
category="subsection",
display_name="Subsection without grade"
)
self.user = UserFactory()
self.grade = PersistentSubsectionGrade.update_or_create_grade(
user_id=self.user.id,
course_id=self.course.id,
usage_key=self.subsection.location,
first_attempted=None,
visible_blocks=[],
earned_all=6.0,
possible_all=6.0,
earned_graded=5.0,
possible_graded=5.0
)
self.signal_patcher = patch('lms.djangoapps.grades.signals.signals.SUBSECTION_OVERRIDE_CHANGED.send')
self.mock_signal = self.signal_patcher.start()
self.id_patcher = patch('lms.djangoapps.grades.services.create_new_event_transaction_id')
self.mock_create_id = self.id_patcher.start()
self.mock_create_id.return_value = 1
self.type_patcher = patch('lms.djangoapps.grades.services.set_event_transaction_type')
self.mock_set_type = self.type_patcher.start()
self.flag_patcher = patch('lms.djangoapps.grades.services.waffle_flags')
self.mock_waffle_flags = self.flag_patcher.start()
self.mock_waffle_flags.return_value = {
REJECTED_EXAM_OVERRIDES_GRADE: MockWaffleFlag(True)
}
示例15: test_resume_course_visibility
def test_resume_course_visibility(self):
SelfPacedConfiguration(enable_course_home_improvements=True).save()
chapter = ItemFactory.create(
category="chapter", parent_location=self.course.location
)
section = ItemFactory.create(
category='section', parent_location=chapter.location
)
section_url = reverse(
'courseware_section',
kwargs={
'section': section.url_name,
'chapter': chapter.url_name,
'course_id': self.course.id
}
)
self.client.get(section_url)
info_url = reverse('info', args=(unicode(self.course.id),))
# Assuring a non-authenticated user cannot see the resume course button.
resume_course_url = self.get_resume_course_url(info_url)
self.assertEqual(resume_course_url, None)
# Assuring an unenrolled user cannot see the resume course button.
self.setup_user()
resume_course_url = self.get_resume_course_url(info_url)
self.assertEqual(resume_course_url, None)
# Assuring an enrolled user can see the resume course button.
self.enroll(self.course)
resume_course_url = self.get_resume_course_url(info_url)
self.assertEqual(resume_course_url, section_url)