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


Python ItemFactory.create方法代码示例

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


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

示例1: setUpClass

# 需要导入模块: from xmodule.modulestore.tests.factories import ItemFactory [as 别名]
# 或者: from xmodule.modulestore.tests.factories.ItemFactory import create [as 别名]
 def setUpClass(cls):
     super(TestGetProblemGradeDistribution, cls).setUpClass()
     cls.course = CourseFactory.create(
         display_name=u"test course omega \u03a9",
     )
     with cls.store.bulk_operations(cls.course.id, emit_signals=False):
         section = ItemFactory.create(
             parent_location=cls.course.location,
             category="chapter",
             display_name=u"test factory section omega \u03a9",
         )
         cls.sub_section = ItemFactory.create(
             parent_location=section.location,
             category="sequential",
             display_name=u"test subsection omega \u03a9",
         )
         cls.unit = ItemFactory.create(
             parent_location=cls.sub_section.location,
             category="vertical",
             metadata={'graded': True, 'format': 'Homework'},
             display_name=u"test unit omega \u03a9",
         )
         cls.items = []
         for i in xrange(USER_COUNT - 1):
             item = ItemFactory.create(
                 parent_location=cls.unit.location,
                 category="problem",
                 data=StringResponseXMLFactory().build_xml(answer='foo'),
                 metadata={'rerandomize': 'always'},
                 display_name=u"test problem omega \u03a9 " + str(i)
             )
             cls.items.append(item)
             cls.item = item
开发者ID:AlexxNica,项目名称:edx-platform,代码行数:35,代码来源:test_dashboard_data.py

示例2: setUpClass

# 需要导入模块: from xmodule.modulestore.tests.factories import ItemFactory [as 别名]
# 或者: from xmodule.modulestore.tests.factories.ItemFactory import create [as 别名]
 def setUpClass(cls):
     super(GradesEventIntegrationTest, cls).setUpClass()
     cls.store = modulestore()
     with cls.store.default_store(ModuleStoreEnum.Type.split):
         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,
             format="Homework"
         )
         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 2',
             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="p1",
             data=problem_xml,
             metadata={'weight': 2}
         )
开发者ID:bryanlandia,项目名称:edx-platform,代码行数:36,代码来源:test_events.py

示例3: set_up_course

# 需要导入模块: from xmodule.modulestore.tests.factories import ItemFactory [as 别名]
# 或者: from xmodule.modulestore.tests.factories.ItemFactory import create [as 别名]
    def set_up_course(self, enable_subsection_grades=True):
        """
        Configures the course for this test.
        """
        # pylint: disable=attribute-defined-outside-init,no-member
        self.course = CourseFactory.create(
            org='edx',
            name='course',
            run='run',
        )
        if not enable_subsection_grades:
            PersistentGradesEnabledFlag.objects.create(enabled=False)

        self.chapter = ItemFactory.create(parent=self.course, category="chapter", display_name="Chapter")
        self.sequential = ItemFactory.create(parent=self.chapter, category='sequential', display_name="Open Sequential")
        self.problem = ItemFactory.create(parent=self.sequential, category='problem', display_name='problem')

        self.score_changed_kwargs = {
            'points_possible': 10,
            'points_earned': 5,
            'user': self.user,
            'course_id': unicode(self.course.id),
            'usage_id': unicode(self.problem.location),
        }

        # this call caches the anonymous id on the user object, saving 4 queries in all happy path tests
        _ = anonymous_id_for_user(self.user, self.course.id)
开发者ID:singingwolfboy,项目名称:edx-platform,代码行数:29,代码来源:test_signals.py

示例4: setUp

# 需要导入模块: from xmodule.modulestore.tests.factories import ItemFactory [as 别名]
# 或者: from xmodule.modulestore.tests.factories.ItemFactory import create [as 别名]
    def setUp(self):
        super(TestTaskExecution, self).setUp()

        self.course = CourseFactory.create(start=datetime(2015, 3, 1))
        self.section = ItemFactory.create(parent=self.course, category='chapter', display_name='Test Section')
        self.subsection = ItemFactory.create(parent=self.section, category='sequential', display_name='Test Subsection')
        self.vertical = ItemFactory.create(parent=self.subsection, category='vertical', display_name='Test Unit')
开发者ID:digitalsatori,项目名称:edx-platform,代码行数:9,代码来源:test_tasks.py

示例5: setUp

# 需要导入模块: from xmodule.modulestore.tests.factories import ItemFactory [as 别名]
# 或者: from xmodule.modulestore.tests.factories.ItemFactory import create [as 别名]
    def setUp(self):
        """
        Creates a basic course structure for our course
        """
        super(CourseStatusAPITestCase, self).setUp()

        self.section = ItemFactory.create(
            parent=self.course,
            category='chapter',
        )
        self.sub_section = ItemFactory.create(
            parent=self.section,
            category='sequential',
        )
        self.unit = ItemFactory.create(
            parent=self.sub_section,
            category='vertical',
        )
        self.other_sub_section = ItemFactory.create(
            parent=self.section,
            category='sequential',
        )
        self.other_unit = ItemFactory.create(
            parent=self.other_sub_section,
            category='vertical',
        )
开发者ID:TeachAtTUM,项目名称:edx-platform,代码行数:28,代码来源:tests.py

示例6: setUpClass

# 需要导入模块: from xmodule.modulestore.tests.factories import ItemFactory [as 别名]
# 或者: from xmodule.modulestore.tests.factories.ItemFactory import create [as 别名]
 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,代码行数:35,代码来源:test_enrollment.py

示例7: setUpClass

# 需要导入模块: from xmodule.modulestore.tests.factories import ItemFactory [as 别名]
# 或者: from xmodule.modulestore.tests.factories.ItemFactory import create [as 别名]
    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,代码行数:31,代码来源:test_spoc_gradebook.py

示例8: setUpClass

# 需要导入模块: from xmodule.modulestore.tests.factories import ItemFactory [as 别名]
# 或者: from xmodule.modulestore.tests.factories.ItemFactory import create [as 别名]
 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,代码行数:32,代码来源:test_masquerade.py

示例9: setUp

# 需要导入模块: from xmodule.modulestore.tests.factories import ItemFactory [as 别名]
# 或者: from xmodule.modulestore.tests.factories.ItemFactory import create [as 别名]
    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,代码行数:28,代码来源:test_gating.py

示例10: setup_course

# 需要导入模块: from xmodule.modulestore.tests.factories import ItemFactory [as 别名]
# 或者: from xmodule.modulestore.tests.factories.ItemFactory import create [as 别名]
    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,代码行数:28,代码来源:testutils.py

示例11: setUp

# 需要导入模块: from xmodule.modulestore.tests.factories import ItemFactory [as 别名]
# 或者: from xmodule.modulestore.tests.factories.ItemFactory import create [as 别名]
    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,代码行数:27,代码来源:test_tools.py

示例12: setUp

# 需要导入模块: from xmodule.modulestore.tests.factories import ItemFactory [as 别名]
# 或者: from xmodule.modulestore.tests.factories.ItemFactory import create [as 别名]
    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,代码行数:27,代码来源:test_tools.py

示例13: setUp

# 需要导入模块: from xmodule.modulestore.tests.factories import ItemFactory [as 别名]
# 或者: from xmodule.modulestore.tests.factories.ItemFactory import create [as 别名]
 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,代码行数:36,代码来源:test_services.py

示例14: test_xblock_studio_url

# 需要导入模块: from xmodule.modulestore.tests.factories import ItemFactory [as 别名]
# 或者: from xmodule.modulestore.tests.factories.ItemFactory import create [as 别名]
    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,代码行数:33,代码来源:test_helpers.py

示例15: setUpClass

# 需要导入模块: from xmodule.modulestore.tests.factories import ItemFactory [as 别名]
# 或者: from xmodule.modulestore.tests.factories.ItemFactory import create [as 别名]
    def setUpClass(cls):
        super(TestCCXGrades, cls).setUpClass()
        cls._course = course = CourseFactory.create(enable_ccx=True)

        # Create a course outline
        cls.mooc_start = start = datetime.datetime(
            2010, 5, 12, 2, 42, tzinfo=pytz.UTC
        )
        chapter = ItemFactory.create(
            start=start, parent=course, category='sequential'
        )
        cls.sections = sections = [
            ItemFactory.create(
                parent=chapter,
                category="sequential",
                metadata={'graded': True, 'format': 'Homework'})
            for _ in xrange(4)
        ]
        # making problems available at class level for possible future use in tests
        cls.problems = [
            [
                ItemFactory.create(
                    parent=section,
                    category="problem",
                    data=StringResponseXMLFactory().build_xml(answer='foo'),
                    metadata={'rerandomize': 'always'}
                ) for _ in xrange(4)
            ] for section in sections
        ]
开发者ID:Akif-Vohra,项目名称:edx-platform,代码行数:31,代码来源:test_views.py


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