コード例 #1
0
 def setUp(self):
     super().setUp()
     self.course_key = ToyCourseFactory.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)
コード例 #2
0
 def setUp(self):
     super(TestStudentViewTransformer, self).setUp()  # lint-amnesty, pylint: disable=super-with-arguments
     self.course_key = ToyCourseFactory.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)
コード例 #3
0
 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)
コード例 #4
0
    def setUp(self):
        super().setUp()

        self.course = SampleCourseFactory.create(
            other_course_settings=self.OTHER_COURSE_SETTINGS_DEFAULT)
        self.course_key = self.course.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)
コード例 #5
0
    def setUp(self):
        super(TestExtraFieldsTransformer, self).setUp()  # lint-amnesty, pylint: disable=super-with-arguments

        self.course = SampleCourseFactory.create(
            other_course_settings=self.OTHER_COURSE_SETTINGS_DEFAULT)
        self.course_key = self.course.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
0
 def setUp(self):
     super(TestOverrideDataTransformer, self).setUp()
     self.course_key = ToyCourseFactory.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)
     self.course = course = modulestore().get_course(self.course_key)
     section = course.get_children()[0]
     subsection = section.get_children()[0]
     self.block = self.store.create_child(
         self.learner.id, subsection.location, 'html', 'new_component'
     )
     CourseEnrollmentFactory.create(user=self.learner, course_id=self.course_key, is_active=True)
コード例 #7
0
ファイル: test_navigation.py プロジェクト: saadow123/1
    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(six.text_type(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(six.text_type(block_key), course_descendants)
コード例 #8
0
    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)
コード例 #9
0
    def setUp(self):
        super().setUp()

        block_info_tree = [
            BlockInfo('Section', 'chapter', {}, [
                BlockInfo('Subsection', 'sequential', {}, [
                    BlockInfo('Vertical', 'vertical', {}, [
                        BlockInfo(
                            'Clip', 'video', {
                                'edx_video_id': 'edxval1',
                                'start_time': timedelta(seconds=20),
                                'end_time': timedelta(seconds=60)
                            }, []),
                        BlockInfo('Video', 'video',
                                  {'edx_video_id': 'edxval2'}, []),
                        BlockInfo('Web', 'video', {
                            'edx_video_id': 'edxval3',
                            'only_on_web': True
                        }, []),
                        BlockInfo('HTML', 'html', {'data': 'Hello World'}, []),
                        BlockInfo('Problem1', 'problem', {}, []),
                        BlockInfo('Problem2', 'problem', {}, []),
                    ]),
                ]),
            ]),
        ]

        self.course_key = SampleCourseFactory.create(
            block_info_tree=block_info_tree).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)

        self.section_key = self.course_key.make_usage_key('chapter', 'Section')
        self.subsection_key = self.course_key.make_usage_key(
            'sequential', 'Subsection')
        self.vertical_key = self.course_key.make_usage_key(
            'vertical', 'Vertical')
        self.video_clip_key = self.course_key.make_usage_key('video', 'Clip')
        self.video_normal_key = self.course_key.make_usage_key(
            'video', 'Video')
        self.video_web_key = self.course_key.make_usage_key('video', 'Web')
        self.html_key = self.course_key.make_usage_key('html', 'HTML')

        # Set edxval data
        create_video({
            'edx_video_id': 'edxval1',
            'status': 'uploaded',
            'client_video_id': 'Clip Video',
            'duration': 200,
            'encoded_videos': [],
            'courses': [str(self.course_key)],
        })
        create_video({
            'edx_video_id': 'edxval2',
            'status': 'uploaded',
            'client_video_id': 'Normal Video',
            'duration': 30,
            'encoded_videos': [],
            'courses': [str(self.course_key)],
        })
        create_video({
            'edx_video_id': 'edxval3',
            'status': 'uploaded',
            'client_video_id': 'Web Video',
            'duration': 50,
            'encoded_videos': [],
            'courses': [str(self.course_key)],
        })
コード例 #10
0
 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)