Exemple #1
0
    def test_easy_access_from_experiment(self):
        """
        Scenario: When a Content Experiment uses a Group Configuration,
        ensure that the link to that Group Configuration works correctly.

        Given I have a course with two Group Configurations
        And Content Experiment is assigned to one Group Configuration
        Then I see a link to Group Configuration
        When I click on the Group Configuration link
        Then I see the Group Configurations page
        And I see that appropriate Group Configuration is expanded.
        """
        # Create a new group configurations
        self.course_fixture._update_xblock(self.course_fixture._course_location, {
            "metadata": {
                u"user_partitions": [
                    create_user_partition_json(
                        0,
                        "Name",
                        "Description.",
                        [Group("0", "Group A"), Group("1", "Group B")]
                    ),
                    create_user_partition_json(
                        1,
                        'Name of second Group Configuration',
                        'Second group configuration.',
                        [Group("0", 'Alpha'), Group("1", 'Beta'), Group("2", 'Gamma')]
                    ),
                ],
            },
        })

        # Assign newly created group configuration to unit
        vertical = self.course_fixture.get_nested_xblocks(category="vertical")[0]
        self.course_fixture.create_xblock(
            vertical.locator,
            XBlockFixtureDesc('split_test', 'Test Content Experiment', metadata={'user_partition_id': 1})
        )

        unit = ContainerPage(self.browser, vertical.locator)
        unit.visit()
        experiment = unit.xblocks[0]

        group_configuration_link_name = experiment.group_configuration_link_name

        experiment.go_to_group_configuration_page()
        self.page.wait_for_page()

        # Appropriate Group Configuration is expanded.
        self.assertFalse(self.page.experiment_group_configurations[0].is_expanded)
        self.assertTrue(self.page.experiment_group_configurations[1].is_expanded)

        self.assertEqual(
            group_configuration_link_name,
            self.page.experiment_group_configurations[1].name
        )
Exemple #2
0
 def setUp(self):  # pylint: disable=arguments-differ
     super(TestCourseBadExport, self).setUp()
     self.export_page = ExportCoursePage(
         self.browser,
         self.course_info['org'],
         self.course_info['number'],
         self.course_info['run'],
     )
     self.edit_page = ContainerPage(self.browser, self.unit.locator)
     self.export_page.visit()
 def setUp(self, is_staff=True):
     """
     Create a course with a section, subsection, and unit to which to add the component.
     """
     super(HTMLComponentEditorTests, self).setUp(is_staff=is_staff)
     self.unit = self.go_to_unit_page()
     self.container_page = ContainerPage(self.browser, None)
     self.xblock_wrapper = XBlockWrapper(self.browser, None)
     self.component = None
     self.html_editor = None
     self.iframe = None
Exemple #4
0
 def setUp(self, is_staff=True):
     """
     Create a course with a section, subsection, and unit to which to add the component.
     """
     super(ProblemComponentEditor, self).setUp(is_staff=is_staff)
     self.component = 'Blank Common Problem'
     self.unit = self.go_to_unit_page()
     self.container_page = ContainerPage(self.browser, None)
     # Add a Problem
     add_component(self.container_page, 'problem', self.component)
     self.component = self.unit.xblocks[1]
     self.container_page.edit()
     self.problem_editor = ProblemXBlockEditorView(self.browser, self.component.locator)
Exemple #5
0
 def setUp(self, is_staff=True):
     """
     Create a course with a section, subsection, and unit to which to add the component.
     """
     super(DiscussionComponentTest, self).setUp(is_staff=is_staff)
     self.component = 'discussion'
     self.unit = self.go_to_unit_page()
     self.container_page = ContainerPage(self.browser, None)
     # Add Discussion component
     add_component(self.container_page, 'discussion', self.component)
     self.component = self.unit.xblocks[1]
     self.container_page.edit()
     self.discussion_editor = DiscussionComponentEditor(self.browser, self.component.locator)
    def test_split_test_LMS_staff_view(self):
        """
        Scenario: Ensure that split test is correctly rendered in LMS staff mode as it is
                  and after inactive group removal.

        Given I have a course with group configurations and split test that assigned to first group configuration
        Then I publish split test and view it in LMS in staff view
        And it is rendered correctly
        Then I go to group configuration and delete group
        Then I publish split test and view it in LMS in staff view
        And it is rendered correctly
        Then I go to split test and delete inactive vertical
        Then I publish unit and view unit in LMS in staff view
        And it is rendered correctly
        """

        config, split_test = self.create_group_configuration_experiment([Group("0", "Group A"), Group("1", "Group B"), Group("2", "Group C")], True)
        container = ContainerPage(self.browser, split_test.locator)

        # render in LMS correctly
        courseware_page = CoursewarePage(self.browser, self.course_id)
        self.publish_unit_and_verify_groups_in_lms(courseware_page, [u'Group A', u'Group B', u'Group C'])

        # I go to group configuration and delete group
        self.page.visit()
        self.page.q(css='.group-toggle').first.click()
        config.edit()
        config.groups[2].remove()
        config.save()
        self.page.q(css='.group-toggle').first.click()
        self._assert_fields(config, name="Name", description="Description", groups=["Group A", "Group B"])
        self.browser.close()
        self.browser.switch_to_window(self.browser.window_handles[0])

        # render in LMS to see how inactive vertical is rendered
        self.publish_unit_and_verify_groups_in_lms(
            courseware_page,
            [u'Group A', u'Group B', u'Group ID 2 (inactive)'],
            publish=False
        )

        self.browser.close()
        self.browser.switch_to_window(self.browser.window_handles[0])

        # I go to split test and delete inactive vertical
        container.visit()
        container.delete(0)

        # render in LMS again
        self.publish_unit_and_verify_groups_in_lms(courseware_page, [u'Group A', u'Group B'])
Exemple #7
0
 def setUp(self, is_staff=True):
     """
     Create a course with a section, subsection, and unit to which to add the component.
     """
     super(HTMLComponentEditor, self).setUp(is_staff=is_staff)
     self.component = 'Text'
     self.unit = self.go_to_unit_page()
     self.container_page = ContainerPage(self.browser, None)
     self.xblock_wrapper = XBlockWrapper(self.browser, None)
     # Add HTML component
     add_component(self.container_page, 'html', self.component)
     self.component = self.unit.xblocks[1]
     self.container_page.edit()
     self.html_editor = HtmlXBlockEditorView(self.browser, self.component.locator)
     self.iframe = HTMLEditorIframe(self.browser, self.component.locator)
Exemple #8
0
    def test_group_configuration_non_empty_usage(self):
        """
        Scenario: When group configuration is used, ensure that the links to units using a group configuration work correctly.
        Given I have a course without group configurations
        And I create new group configuration with 2 default groups
        And I create a unit and assign the newly created group configuration
        And open the Group Configuration page
        Then I see a link to the newly created unit
        When I click on the unit link
        Then I see correct unit page
        """
        # Create a new group configurations
        self.course_fixture._update_xblock(self.course_fixture._course_location, {
            "metadata": {
                u"user_partitions": [
                    create_user_partition_json(
                        0,
                        "Name",
                        "Description.",
                        [Group("0", "Group A"), Group("1", "Group B")]
                    ),
                ],
            },
        })

        # Assign newly created group configuration to unit
        vertical = self.course_fixture.get_nested_xblocks(category="vertical")[0]
        self.course_fixture.create_xblock(
            vertical.locator,
            XBlockFixtureDesc('split_test', 'Test Content Experiment', metadata={'user_partition_id': 0})
        )
        unit = CourseOutlineUnit(self.browser, vertical.locator)

        # Go to the Group Configuration Page and click unit anchor
        self.page.visit()
        config = self.page.experiment_group_configurations[0]
        config.toggle()
        usage = config.usages[0]
        config.click_unit_anchor()

        unit = ContainerPage(self.browser, vertical.locator)
        # Waiting for the page load and verify that we've landed on the unit page
        EmptyPromise(
            lambda: unit.is_browser_on_page(), "loaded page {!r}".format(unit),
            timeout=30
        ).fulfill()

        self.assertIn(unit.name, usage)
    def _studio_add_content(self, studio_course_outline, html_content):
        """
        Add content to first section on studio course page.
        """
        # create a unit in course outline
        studio_course_outline.visit()
        subsection = studio_course_outline.section_at(0).subsection_at(0)
        subsection.expand_subsection()
        subsection.add_unit()

        # got to unit and create an HTML component and save (not publish)
        unit_page = ContainerPage(self.browser, None)
        unit_page.wait_for_page()
        add_html_component(unit_page, 0)
        unit_page.wait_for_element_presence('.edit-button', 'Edit button is visible')
        click_css(unit_page, '.edit-button', 0, require_notification=False)
        unit_page.wait_for_element_visibility('.modal-editor', 'Modal editor is visible')
        type_in_codemirror(unit_page, 0, html_content)
        click_css(unit_page, '.action-save', 0)
    def _studio_add_content(self, section_index):
        """
        Add content on studio course page under specified section
        """

        self._auto_auth(self.STAFF_USERNAME, self.STAFF_EMAIL, True)
        # create a unit in course outline
        self.studio_course_outline.visit()
        subsection = self.studio_course_outline.section_at(section_index).subsection_at(0)
        subsection.expand_subsection()
        subsection.add_unit()

        # got to unit and create an HTML component and save (not publish)
        unit_page = ContainerPage(self.browser, None)
        unit_page.wait_for_page()
        add_html_component(unit_page, 0)
        unit_page.wait_for_element_presence('.edit-button', 'Edit button is visible')
        click_css(unit_page, '.edit-button', 0, require_notification=False)
        unit_page.wait_for_element_visibility('.modal-editor', 'Modal editor is visible')
        type_in_codemirror(unit_page, 0, self.HTML_CONTENT)
        click_css(unit_page, '.action-save', 0)
    def test_add_advanced_problem(self, component):
        """
        Scenario Outline: I can add Advanced Problem components
           Given I am in Studio editing a new unit
           When I add a "<Component>" "Advanced Problem" component
           Then I see a "<Component>" Problem component

        Examples:
               | Component                     |
               | Blank Advanced Problem        |
               | Circuit Schematic Builder     |
               | Custom Python-Evaluated Input |
               | Drag and Drop                 |
               | Image Mapped Input            |
               | Math Expression Input         |
               | Problem with Adaptive Hint    |
        """
        self.go_to_unit_page()
        page = ContainerPage(self.browser, None)
        add_component(page, 'problem', component, is_advanced_problem=True)
        problem = page.xblocks[1]
        self.assertEqual(problem.name, component)
 def test_add_latex_html_component(self):
     """
     Scenario: I can add Latex HTML components
     Given I am in Studio editing a new unit
     Given I have enabled latex compiler
     When I add this type of HTML component:
         | Component               |
         | E-text Written in LaTeX |
     Then I see HTML components in this order:
         | Component               |
         | E-text Written in LaTeX |
     """
     # Latex component
     component = 'E-text Written in LaTeX'
     # Visit advanced settings page and enable latex compiler.
     self.advanced_settings.visit()
     self.advanced_settings.set('Enable LaTeX Compiler', 'True')
     self.go_to_unit_page()
     container_page = ContainerPage(self.browser, None)
     # Add latex component
     add_component(container_page, 'html', component, is_advanced_problem=False)
     problem = container_page.xblocks[1]
     # Asset that component has been added.
     self.assertEqual(problem.name, component)
Exemple #13
0
    def test_container_page_active_verticals_names_are_synced(self):
        """
        Scenario: Ensure that the Content Experiment display synced vertical names and correct groups.
        Given I have a course with group configuration
        And I go to the Group Configuration page in Studio
        And I edit the name of the group configuration, add new group and remove old one
        And I change the name for the group "New group" to "Second Group"
        And I go to the Container page in Studio
        And I edit the Content Experiment
        Then I see the group configuration name is changed in `Group Configuration` dropdown
        And the group configuration name is changed on container page
        And I see the module has 2 active groups and one inactive
        And I see "Add missing groups" link exists
        When I click on "Add missing groups" link
        The I see the module has 3 active groups and one inactive
        """
        self.course_fixture._update_xblock(
            self.course_fixture._course_location, {
                "metadata": {
                    u"user_partitions": [
                        create_user_partition_json(
                            0, 'Name of the Group Configuration',
                            'Description of the group configuration.', [
                                Group("0", 'Group A'),
                                Group("1", 'Group B'),
                                Group("2", 'Group C')
                            ]),
                    ],
                },
            })

        # Add split test to vertical and assign newly created group configuration to it
        split_test = self._add_split_test_to_vertical(
            number=0, group_configuration_metadata={'user_partition_id': 0})

        self.page.visit()
        config = self.page.experiment_group_configurations[0]
        config.edit()
        config.name = "Second Group Configuration Name"
        # `Group C` -> `Second Group`
        config.groups[2].name = "Second Group"
        # Add new group
        config.add_group()  # Group D
        # Remove Group A
        config.groups[0].remove()
        # Save the configuration
        config.save()

        container = ContainerPage(self.browser, split_test.locator)
        container.visit()
        container.edit()
        component_editor = XBlockEditorView(self.browser, container.locator)
        self.assertEqual(
            "Second Group Configuration Name",
            component_editor.get_selected_option_text('Group Configuration'))
        component_editor.cancel()
        self.assertIn("Second Group Configuration Name",
                      container.get_xblock_information_message())
        self.verify_groups(container, ['Group B', 'Second Group'],
                           ['Group ID 0'],
                           verify_missing_groups_not_present=False)
        # Click the add button and verify that the groups were added on the page
        container.add_missing_groups()
        self.verify_groups(container, ['Group B', 'Second Group', 'Group D'],
                           ['Group ID 0'])
Exemple #14
0
 def go_to(self):
     """
     Open the container page linked to by this unit link, and return
     an initialized :class:`.ContainerPage` for that unit.
     """
     return ContainerPage(self.browser, self.locator).visit()