本文整理汇总了Python中xmodule.modulestore.tests.factories.ItemFactory类的典型用法代码示例。如果您正苦于以下问题:Python ItemFactory类的具体用法?Python ItemFactory怎么用?Python ItemFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ItemFactory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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))
开发者ID:pwilkins,项目名称:edx-platform,代码行数:31,代码来源:test_helpers.py
示例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)
开发者ID:Chitrank-Dixit,项目名称:edx-platform,代码行数:33,代码来源:test_view_authentication.py
示例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)
开发者ID:ZheJiuShiMing,项目名称:edx-platform,代码行数:30,代码来源:test_courses.py
示例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))
开发者ID:BeiLuoShiMen,项目名称:edx-platform,代码行数:34,代码来源:__init__.py
示例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')
开发者ID:TabEd,项目名称:edx-platform,代码行数:30,代码来源:test_split_module.py
示例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)
开发者ID:digitalsatori,项目名称:edx-platform,代码行数:32,代码来源:test_milestones.py
示例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",
)
开发者ID:shevious,项目名称:edx-platform,代码行数:27,代码来源:test_split_module.py
示例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)
开发者ID:10clouds,项目名称:edx-platform,代码行数:26,代码来源:test_gating.py
示例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')]
开发者ID:jazkarta,项目名称:edx-platform,代码行数:29,代码来源:test_authoring_mixin.py
示例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)
开发者ID:weicliu,项目名称:edx-platform-local,代码行数:25,代码来源:test_tools.py
示例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,
)
开发者ID:zhenzhai,项目名称:edx-platform,代码行数:30,代码来源:test_masquerade.py
示例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
]
开发者ID:Lektorium-LLC,项目名称:edx-platform,代码行数:26,代码来源:testutils.py
示例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)
开发者ID:edx,项目名称:edx-platform,代码行数:25,代码来源:test_tools.py
示例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)
}
开发者ID:digitalsatori,项目名称:edx-platform,代码行数:34,代码来源:test_services.py
示例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)
开发者ID:AlexxNica,项目名称:edx-platform,代码行数:32,代码来源:test_course_info.py
示例16: setUp
def setUp(self):
super(TestGetProblemGradeDistribution, self).setUp()
self.request_factory = RequestFactory()
self.instructor = AdminFactory.create()
self.client.login(username=self.instructor.username, password='test')
self.attempts = 3
self.course = CourseFactory.create(
display_name=u"test course omega \u03a9",
)
section = ItemFactory.create(
parent_location=self.course.location,
category="chapter",
display_name=u"test factory section omega \u03a9",
)
self.sub_section = ItemFactory.create(
parent_location=section.location,
category="sequential",
display_name=u"test subsection omega \u03a9",
)
unit = ItemFactory.create(
parent_location=self.sub_section.location,
category="vertical",
metadata={'graded': True, 'format': 'Homework'},
display_name=u"test unit omega \u03a9",
)
self.users = [UserFactory.create(username="metric" + str(__)) for __ in xrange(USER_COUNT)]
for user in self.users:
CourseEnrollmentFactory.create(user=user, course_id=self.course.id)
for i in xrange(USER_COUNT - 1):
category = "problem"
self.item = ItemFactory.create(
parent_location=unit.location,
category=category,
data=StringResponseXMLFactory().build_xml(answer='foo'),
metadata={'rerandomize': 'always'},
display_name=u"test problem omega \u03a9 " + str(i)
)
for j, user in enumerate(self.users):
StudentModuleFactory.create(
grade=1 if i < j else 0,
max_grade=1 if i < j else 0.5,
student=user,
course_id=self.course.id,
module_state_key=self.item.location,
state=json.dumps({'attempts': self.attempts}),
)
for j, user in enumerate(self.users):
StudentModuleFactory.create(
course_id=self.course.id,
module_type='sequential',
module_state_key=self.item.location,
)
开发者ID:Cgruppo,项目名称:edx-platform,代码行数:60,代码来源:test_dashboard_data.py
示例17: setUpClass
def setUpClass(cls):
super(TestStudentModuleGrading, cls).setUpClass()
cls.course = CourseFactory.create()
cls.chapter = ItemFactory.create(
parent=cls.course,
category="chapter",
display_name="Test Chapter"
)
cls.sequence = ItemFactory.create(
parent=cls.chapter,
category='sequential',
display_name="Test Sequential 1",
graded=True
)
cls.vertical = ItemFactory.create(
parent=cls.sequence,
category='vertical',
display_name='Test Vertical 1'
)
problem_xml = MultipleChoiceResponseXMLFactory().build_xml(
question_text='The correct answer is Choice 3',
choices=[False, False, True, False],
choice_names=['choice_0', 'choice_1', 'choice_2', 'choice_3']
)
cls.problem = ItemFactory.create(
parent=cls.vertical,
category="problem",
display_name="Test Problem",
data=problem_xml
)
cls.request = get_mock_request(UserFactory())
cls.user = cls.request.user
cls.instructor = UserFactory(username='staff', is_staff=True)
开发者ID:jolyonb,项目名称:edx-platform,代码行数:33,代码来源:test_enrollment.py
示例18: _test_not_indexing_unpublished_content
def _test_not_indexing_unpublished_content(self, store):
""" add a new one, only appers in index once added """
# Publish the vertical to start with
self.publish_item(store, self.vertical.location)
self.reindex_course(store)
response = self.search()
self.assertEqual(response["total"], 4)
# Now add a new unit to the existing vertical
ItemFactory.create(
parent_location=self.vertical.location,
category="html",
display_name="Some other content",
publish_item=False,
modulestore=store,
)
self.reindex_course(store)
response = self.search()
self.assertEqual(response["total"], 4)
# Now publish it and we should find it
# Publish the vertical as is, and everything should be available
self.publish_item(store, self.vertical.location)
self.reindex_course(store)
response = self.search()
self.assertEqual(response["total"], 5)
开发者ID:HowestX,项目名称:edx-platform,代码行数:26,代码来源:test_courseware_index.py
示例19: setUpClass
def setUpClass(cls):
super(TestGradebook, cls).setUpClass()
# Create a course with the desired grading policy (from our class attribute)
kwargs = {}
if cls.grading_policy is not None:
kwargs['grading_policy'] = cls.grading_policy
cls.course = CourseFactory.create(**kwargs)
# Now give it some content
with cls.store.bulk_operations(cls.course.id, emit_signals=False):
chapter = ItemFactory.create(
parent_location=cls.course.location,
category="sequential",
)
section = ItemFactory.create(
parent_location=chapter.location,
category="sequential",
metadata={'graded': True, 'format': 'Homework'}
)
cls.items = [
ItemFactory.create(
parent_location=section.location,
category="problem",
data=StringResponseXMLFactory().build_xml(answer='foo'),
metadata={'rerandomize': 'always'}
)
for __ in xrange(USER_COUNT - 1)
]
开发者ID:Lektorium-LLC,项目名称:edx-platform,代码行数:29,代码来源:test_spoc_gradebook.py
示例20: _test_not_indexable
def _test_not_indexable(self, store):
""" test not indexable items """
# Publish the vertical to start with
self.publish_item(store, self.vertical.location)
self.reindex_course(store)
response = self.search()
self.assertEqual(response["total"], 4)
# Add a non-indexable item
ItemFactory.create(
parent_location=self.vertical.location,
category="openassessment",
display_name="Some other content",
publish_item=False,
modulestore=store,
)
self.reindex_course(store)
response = self.search()
self.assertEqual(response["total"], 4)
# even after publishing, we should not find the non-indexable item
self.publish_item(store, self.vertical.location)
self.reindex_course(store)
response = self.search()
self.assertEqual(response["total"], 4)
开发者ID:HowestX,项目名称:edx-platform,代码行数:25,代码来源:test_courseware_index.py
注:本文中的xmodule.modulestore.tests.factories.ItemFactory类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论