Ejemplo n.º 1
0
    def test_score_reset_after_resetting_problem(self, input_value,
                                                 correctness,
                                                 score_before_reset,
                                                 score_after_reset):
        """
        Scenario: Test that score resets after the formula problem is resetted.

        Given I am attempting a formula problem type with randomization:always configuration
        When I input the answer
        Then I should be able to see the MathJax generated preview
        When I submit the problem
        Then I should be able to view the score that I received
        And The reset button should be present and is clickable
        When the reset button is clicked
        Then the score resets to zero
        """
        problem_page = ProblemPage(self.browser)
        problem_page.fill_answer_numerical(input_value)
        problem_page.verify_mathjax_rendered_in_preview()
        problem_page.click_submit()
        self.assertEqual(problem_page.get_simpleprob_correctness(),
                         correctness)
        self.assertIn(score_before_reset,
                      problem_page.problem_progress_graded_value)
        self.assertTrue(problem_page.is_reset_button_present())
        problem_page.click_reset()
        self.assertIn(score_after_reset,
                      problem_page.problem_progress_graded_value)
Ejemplo n.º 2
0
    def test_reset_correctness_after_changing_answer(self, input_value,
                                                     correctness, next_input):
        """
        Scenario: Test that formula problem can be resetted after changing the answer.

        Given I am attempting a formula problem type with randomization:always configuration
        When I input an answer
        Then the mathjax generated preview should be visible
        When I submit the problem, I can see the correctness status
        When I only input another answer
        Then the correctness status is no longer visible
        And I am able to see the reset button
        And when I click the reset button
        Then input pane contents are cleared
        """
        problem_page = ProblemPage(self.browser)
        problem_page.fill_answer_numerical(input_value)
        problem_page.verify_mathjax_rendered_in_preview()
        problem_page.click_submit()
        self.assertEqual(problem_page.get_simpleprob_correctness(),
                         correctness)
        problem_page.fill_answer_numerical(next_input)
        self.assertIsNone(problem_page.get_simpleprob_correctness())
        self.assertTrue(problem_page.is_reset_button_present())
        problem_page.click_reset()
        self.assertEqual(problem_page.get_numerical_input_value, '')
Ejemplo n.º 3
0
    def test_reset_problem_after_incorrect_submission(self):
        """
        Scenario: Verify that formula problem can be resetted after an incorrect submission.

        Given I am attempting a formula response problem type
        When I input an incorrect answer
        Then the answer preview is generated using MathJax
        When I submit the problem
        Then I can see incorrect status and a reset button
        When I click reset, the input pane contents get clear
        """
        problem_page = ProblemPage(self.browser)
        problem_page.fill_answer_numerical('R_1*R_2')
        problem_page.verify_mathjax_rendered_in_preview()
        problem_page.click_submit()
        self.assertFalse(problem_page.simpleprob_is_correct())
        self.assertTrue(problem_page.is_reset_button_present())
        problem_page.click_reset()
        self.assertEqual(problem_page.get_numerical_input_value, '')
    def test_reset_problem_after_submission(self, input_value, correctness):
        """
        Scenario: Test that reset button works regardless the submission correctness status.

        Given I am attempting a formula problem type with randomization:always configuration
        When I input the answer
        Then I should be able to see the MathJax generated preview
        When I submit the problem
        Then I should be able to see the reset button
        When reset button is clicked
        Then the input pane contents should be clear
        """
        problem_page = ProblemPage(self.browser)
        problem_page.fill_answer_numerical(input_value)
        problem_page.verify_mathjax_rendered_in_preview()
        problem_page.click_submit()
        self.assertEqual(problem_page.get_simpleprob_correctness(), correctness)
        self.assertTrue(problem_page.is_reset_button_present())
        problem_page.click_reset()
        self.assertEqual(problem_page.get_numerical_input_value, '')
Ejemplo n.º 5
0
    def test_reset_problem_after_submission(self, input_value, correctness):
        """
        Scenario: Test that reset button works regardless the submission correctness status.

        Given I am attempting a formula problem type with randomization:always configuration
        When I input the answer
        Then I should be able to see the MathJax generated preview
        When I submit the problem
        Then I should be able to see the reset button
        When reset button is clicked
        Then the input pane contents should be clear
        """
        problem_page = ProblemPage(self.browser)
        problem_page.fill_answer_numerical(input_value)
        problem_page.verify_mathjax_rendered_in_preview()
        problem_page.click_submit()
        self.assertEqual(problem_page.get_simpleprob_correctness(), correctness)
        self.assertTrue(problem_page.is_reset_button_present())
        problem_page.click_reset()
        self.assertEqual(problem_page.get_numerical_input_value, '')
    def test_score_reset_after_resetting_problem(self, input_value, correctness, score_before_reset, score_after_reset):
        """
        Scenario: Test that score resets after the formula problem is resetted.

        Given I am attempting a formula problem type with randomization:always configuration
        When I input the answer
        Then I should be able to see the MathJax generated preview
        When I submit the problem
        Then I should be able to view the score that I received
        And The reset button should be present and is clickable
        When the reset button is clicked
        Then the score resets to zero
        """
        problem_page = ProblemPage(self.browser)
        problem_page.fill_answer_numerical(input_value)
        problem_page.verify_mathjax_rendered_in_preview()
        problem_page.click_submit()
        self.assertEqual(problem_page.get_simpleprob_correctness(), correctness)
        self.assertIn(score_before_reset, problem_page.problem_progress_graded_value)
        self.assertTrue(problem_page.is_reset_button_present())
        problem_page.click_reset()
        self.assertIn(score_after_reset, problem_page.problem_progress_graded_value)
Ejemplo n.º 7
0
    def test_reset_problem_after_changing_correctness(self):
        """
        Scenario: Verify that formula problem can be resetted after changing the correctness.

        Given I am attempting a formula problem type
        When I answer it correctly
        Then the correctness status should be visible
        And reset button is not rendered
        When I change my submission to incorrect
        Then the reset button appears and is clickable
        """
        problem_page = ProblemPage(self.browser)
        problem_page.fill_answer_numerical('R_1*R_2/R_3')
        problem_page.verify_mathjax_rendered_in_preview()
        problem_page.click_submit()
        self.assertTrue(problem_page.simpleprob_is_correct())
        self.assertFalse(problem_page.is_reset_button_present())
        problem_page.fill_answer_numerical('R_1/R_3')
        problem_page.click_submit()
        self.assertFalse(problem_page.simpleprob_is_correct())
        self.assertTrue(problem_page.is_reset_button_present())
        problem_page.click_reset()
        self.assertEqual(problem_page.get_numerical_input_value, '')
    def test_reset_problem_after_changing_correctness(self):
        """
        Scenario: Verify that formula problem can be resetted after changing the correctness.

        Given I am attempting a formula problem type
        When I answer it correctly
        Then the correctness status should be visible
        And reset button is not rendered
        When I change my submission to incorrect
        Then the reset button appears and is clickable
        """
        problem_page = ProblemPage(self.browser)
        problem_page.fill_answer_numerical('R_1*R_2/R_3')
        problem_page.verify_mathjax_rendered_in_preview()
        problem_page.click_submit()
        self.assertTrue(problem_page.simpleprob_is_correct())
        self.assertFalse(problem_page.is_reset_button_present())
        problem_page.fill_answer_numerical('R_1/R_3')
        problem_page.click_submit()
        self.assertFalse(problem_page.simpleprob_is_correct())
        self.assertTrue(problem_page.is_reset_button_present())
        problem_page.click_reset()
        self.assertEqual(problem_page.get_numerical_input_value, '')
    def test_reset_correctness_after_changing_answer(self, input_value, correctness, next_input):
        """
        Scenario: Test that formula problem can be resetted after changing the answer.

        Given I am attempting a formula problem type with randomization:always configuration
        When I input an answer
        Then the mathjax generated preview should be visible
        When I submit the problem, I can see the correctness status
        When I only input another answer
        Then the correctness status is no longer visible
        And I am able to see the reset button
        And when I click the reset button
        Then input pane contents are cleared
        """
        problem_page = ProblemPage(self.browser)
        problem_page.fill_answer_numerical(input_value)
        problem_page.verify_mathjax_rendered_in_preview()
        problem_page.click_submit()
        self.assertEqual(problem_page.get_simpleprob_correctness(), correctness)
        problem_page.fill_answer_numerical(next_input)
        self.assertIsNone(problem_page.get_simpleprob_correctness())
        self.assertTrue(problem_page.is_reset_button_present())
        problem_page.click_reset()
        self.assertEqual(problem_page.get_numerical_input_value, '')
Ejemplo n.º 10
0
class ProblemStateOnNavigationTest(UniqueCourseTest):
    """
    Test courseware with problems in multiple verticals
    """
    USERNAME = "******"
    EMAIL = "*****@*****.**"

    problem1_name = 'MULTIPLE CHOICE TEST PROBLEM 1'
    problem2_name = 'MULTIPLE CHOICE TEST PROBLEM 2'

    def setUp(self):
        super(ProblemStateOnNavigationTest, self).setUp()

        self.courseware_page = CoursewarePage(self.browser, self.course_id)

        # Install a course with section, tabs and multiple choice problems.
        course_fix = CourseFixture(self.course_info['org'],
                                   self.course_info['number'],
                                   self.course_info['run'],
                                   self.course_info['display_name'])

        course_fix.add_children(
            XBlockFixtureDesc('chapter', 'Test Section 1').add_children(
                XBlockFixtureDesc('sequential',
                                  'Test Subsection 1,1').add_children(
                                      self.create_multiple_choice_problem(
                                          self.problem1_name),
                                      self.create_multiple_choice_problem(
                                          self.problem2_name),
                                  ), ), ).install()

        # Auto-auth register for the course.
        AutoAuthPage(self.browser,
                     username=self.USERNAME,
                     email=self.EMAIL,
                     course_id=self.course_id,
                     staff=False).visit()

        self.courseware_page.visit()
        self.problem_page = ProblemPage(self.browser)

    def create_multiple_choice_problem(self, problem_name):
        """
        Return the Multiple Choice Problem Descriptor, given the name of the problem.
        """
        factory = MultipleChoiceResponseXMLFactory()
        xml_data = factory.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'])

        return XBlockFixtureDesc('problem',
                                 problem_name,
                                 data=xml_data,
                                 metadata={'rerandomize': 'always'})

    def go_to_tab_and_assert_problem(self, position, problem_name):
        """
        Go to sequential tab and assert that we are on problem whose name is given as a parameter.
        Args:
            position: Position of the sequential tab
            problem_name: Name of the problem
        """
        self.courseware_page.go_to_sequential_position(position)
        self.problem_page.wait_for_element_presence(
            self.problem_page.CSS_PROBLEM_HEADER, 'wait for problem header')
        self.assertEqual(self.problem_page.problem_name, problem_name)

    def test_perform_problem_check_and_navigate(self):
        """
        Scenario:
        I go to sequential position 1
        Facing problem1, I select 'choice_1'
        Then I click check button
        Then I go to sequential position 2
        Then I came back to sequential position 1 again
        Facing problem1, I observe the problem1 content is not
        outdated before and after sequence navigation
        """
        # Go to sequential position 1 and assert that we are on problem 1.
        self.go_to_tab_and_assert_problem(1, self.problem1_name)

        # Update problem 1's content state by clicking check button.
        self.problem_page.click_choice('choice_choice_1')
        self.problem_page.click_check()
        self.problem_page.wait_for_expected_status(
            'label.choicegroup_incorrect', 'incorrect')

        # Save problem 1's content state as we're about to switch units in the sequence.
        problem1_content_before_switch = self.problem_page.problem_content

        # Go to sequential position 2 and assert that we are on problem 2.
        self.go_to_tab_and_assert_problem(2, self.problem2_name)

        # Come back to our original unit in the sequence and assert that the content hasn't changed.
        self.go_to_tab_and_assert_problem(1, self.problem1_name)
        problem1_content_after_coming_back = self.problem_page.problem_content
        self.assertEqual(problem1_content_before_switch,
                         problem1_content_after_coming_back)

    def test_perform_problem_save_and_navigate(self):
        """
        Scenario:
        I go to sequential position 1
        Facing problem1, I select 'choice_1'
        Then I click save button
        Then I go to sequential position 2
        Then I came back to sequential position 1 again
        Facing problem1, I observe the problem1 content is not
        outdated before and after sequence navigation
        """
        # Go to sequential position 1 and assert that we are on problem 1.
        self.go_to_tab_and_assert_problem(1, self.problem1_name)

        # Update problem 1's content state by clicking save button.
        self.problem_page.click_choice('choice_choice_1')
        self.problem_page.click_save()
        self.problem_page.wait_for_expected_status('div.capa_alert', 'saved')

        # Save problem 1's content state as we're about to switch units in the sequence.
        problem1_content_before_switch = self.problem_page.problem_content

        # Go to sequential position 2 and assert that we are on problem 2.
        self.go_to_tab_and_assert_problem(2, self.problem2_name)

        # Come back to our original unit in the sequence and assert that the content hasn't changed.
        self.go_to_tab_and_assert_problem(1, self.problem1_name)
        problem1_content_after_coming_back = self.problem_page.problem_content
        self.assertIn(problem1_content_after_coming_back,
                      problem1_content_before_switch)

    def test_perform_problem_reset_and_navigate(self):
        """
        Scenario:
        I go to sequential position 1
        Facing problem1, I select 'choice_1'
        Then perform the action – check and reset
        Then I go to sequential position 2
        Then I came back to sequential position 1 again
        Facing problem1, I observe the problem1 content is not
        outdated before and after sequence navigation
        """
        # Go to sequential position 1 and assert that we are on problem 1.
        self.go_to_tab_and_assert_problem(1, self.problem1_name)

        # Update problem 1's content state – by performing reset operation.
        self.problem_page.click_choice('choice_choice_1')
        self.problem_page.click_check()
        self.problem_page.wait_for_expected_status(
            'label.choicegroup_incorrect', 'incorrect')
        self.problem_page.click_reset()
        self.problem_page.wait_for_expected_status('span.unanswered',
                                                   'unanswered')

        # Save problem 1's content state as we're about to switch units in the sequence.
        problem1_content_before_switch = self.problem_page.problem_content

        # Go to sequential position 2 and assert that we are on problem 2.
        self.go_to_tab_and_assert_problem(2, self.problem2_name)

        # Come back to our original unit in the sequence and assert that the content hasn't changed.
        self.go_to_tab_and_assert_problem(1, self.problem1_name)
        problem1_content_after_coming_back = self.problem_page.problem_content
        self.assertEqual(problem1_content_before_switch,
                         problem1_content_after_coming_back)
class ProblemStateOnNavigationTest(UniqueCourseTest):
    """
    Test courseware with problems in multiple verticals
    """
    USERNAME = "******"
    EMAIL = "*****@*****.**"

    problem1_name = 'MULTIPLE CHOICE TEST PROBLEM 1'
    problem2_name = 'MULTIPLE CHOICE TEST PROBLEM 2'

    def setUp(self):
        super(ProblemStateOnNavigationTest, self).setUp()

        self.courseware_page = CoursewarePage(self.browser, self.course_id)

        # Install a course with section, tabs and multiple choice problems.
        course_fix = CourseFixture(
            self.course_info['org'], self.course_info['number'],
            self.course_info['run'], self.course_info['display_name']
        )

        course_fix.add_children(
            XBlockFixtureDesc('chapter', 'Test Section 1').add_children(
                XBlockFixtureDesc('sequential', 'Test Subsection 1,1').add_children(
                    self.create_multiple_choice_problem(self.problem1_name),
                    self.create_multiple_choice_problem(self.problem2_name),
                ),
            ),
        ).install()

        # Auto-auth register for the course.
        AutoAuthPage(
            self.browser, username=self.USERNAME, email=self.EMAIL,
            course_id=self.course_id, staff=False
        ).visit()

        self.courseware_page.visit()
        self.problem_page = ProblemPage(self.browser)

    def create_multiple_choice_problem(self, problem_name):
        """
        Return the Multiple Choice Problem Descriptor, given the name of the problem.
        """
        factory = MultipleChoiceResponseXMLFactory()
        xml_data = factory.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']
        )

        return XBlockFixtureDesc(
            'problem',
            problem_name,
            data=xml_data,
            metadata={'rerandomize': 'always'}
        )

    def go_to_tab_and_assert_problem(self, position, problem_name):
        """
        Go to sequential tab and assert that we are on problem whose name is given as a parameter.
        Args:
            position: Position of the sequential tab
            problem_name: Name of the problem
        """
        self.courseware_page.go_to_sequential_position(position)
        self.problem_page.wait_for_element_presence(
            self.problem_page.CSS_PROBLEM_HEADER,
            'wait for problem header'
        )
        self.assertEqual(self.problem_page.problem_name, problem_name)

    def test_perform_problem_check_and_navigate(self):
        """
        Scenario:
        I go to sequential position 1
        Facing problem1, I select 'choice_1'
        Then I click check button
        Then I go to sequential position 2
        Then I came back to sequential position 1 again
        Facing problem1, I observe the problem1 content is not
        outdated before and after sequence navigation
        """
        # Go to sequential position 1 and assert that we are on problem 1.
        self.go_to_tab_and_assert_problem(1, self.problem1_name)

        # Update problem 1's content state by clicking check button.
        self.problem_page.click_choice('choice_choice_1')
        self.problem_page.click_check()
        self.problem_page.wait_for_expected_status('label.choicegroup_incorrect', 'incorrect')

        # Save problem 1's content state as we're about to switch units in the sequence.
        problem1_content_before_switch = self.problem_page.problem_content

        # Go to sequential position 2 and assert that we are on problem 2.
        self.go_to_tab_and_assert_problem(2, self.problem2_name)

        # Come back to our original unit in the sequence and assert that the content hasn't changed.
        self.go_to_tab_and_assert_problem(1, self.problem1_name)
        problem1_content_after_coming_back = self.problem_page.problem_content
        self.assertEqual(problem1_content_before_switch, problem1_content_after_coming_back)

    def test_perform_problem_save_and_navigate(self):
        """
        Scenario:
        I go to sequential position 1
        Facing problem1, I select 'choice_1'
        Then I click save button
        Then I go to sequential position 2
        Then I came back to sequential position 1 again
        Facing problem1, I observe the problem1 content is not
        outdated before and after sequence navigation
        """
        # Go to sequential position 1 and assert that we are on problem 1.
        self.go_to_tab_and_assert_problem(1, self.problem1_name)

        # Update problem 1's content state by clicking save button.
        self.problem_page.click_choice('choice_choice_1')
        self.problem_page.click_save()
        self.problem_page.wait_for_expected_status('div.capa_alert', 'saved')

        # Save problem 1's content state as we're about to switch units in the sequence.
        problem1_content_before_switch = self.problem_page.problem_content

        # Go to sequential position 2 and assert that we are on problem 2.
        self.go_to_tab_and_assert_problem(2, self.problem2_name)

        # Come back to our original unit in the sequence and assert that the content hasn't changed.
        self.go_to_tab_and_assert_problem(1, self.problem1_name)
        problem1_content_after_coming_back = self.problem_page.problem_content
        self.assertIn(problem1_content_after_coming_back, problem1_content_before_switch)

    def test_perform_problem_reset_and_navigate(self):
        """
        Scenario:
        I go to sequential position 1
        Facing problem1, I select 'choice_1'
        Then perform the action – check and reset
        Then I go to sequential position 2
        Then I came back to sequential position 1 again
        Facing problem1, I observe the problem1 content is not
        outdated before and after sequence navigation
        """
        # Go to sequential position 1 and assert that we are on problem 1.
        self.go_to_tab_and_assert_problem(1, self.problem1_name)

        # Update problem 1's content state – by performing reset operation.
        self.problem_page.click_choice('choice_choice_1')
        self.problem_page.click_check()
        self.problem_page.wait_for_expected_status('label.choicegroup_incorrect', 'incorrect')
        self.problem_page.click_reset()
        self.problem_page.wait_for_expected_status('span.unanswered', 'unanswered')

        # Save problem 1's content state as we're about to switch units in the sequence.
        problem1_content_before_switch = self.problem_page.problem_content

        # Go to sequential position 2 and assert that we are on problem 2.
        self.go_to_tab_and_assert_problem(2, self.problem2_name)

        # Come back to our original unit in the sequence and assert that the content hasn't changed.
        self.go_to_tab_and_assert_problem(1, self.problem1_name)
        problem1_content_after_coming_back = self.problem_page.problem_content
        self.assertEqual(problem1_content_before_switch, problem1_content_after_coming_back)