Ejemplo n.º 1
0
    def test_logout_after_click_redirect(self):
        """
        1) User goes to a problem page.
        2) User fills out an answer to the problem.
        3) User is logged out because their session id is invalidated or removed.
        4) User clicks "check", and sees a confirmation modal asking them to
           re-authenticate, since they've just been logged out.
        5) User clicks "ok".
        6) User is redirected to the login page.
        7) User logs in.
        8) User is redirected back to the problem page they started out on.
        9) User is able to submit an answer
        """
        self.courseware_page.visit()
        problem_page = ProblemPage(self.browser)
        self.assertEqual(problem_page.problem_name, 'TEST PROBLEM')
        problem_page.fill_answer_numerical('1')

        self.log_user_out()
        with problem_page.handle_alert(confirm=True):
            problem_page.click_check()

        login_page = CombinedLoginAndRegisterPage(self.browser)
        login_page.wait_for_page()

        login_page.login(self.email, self.password)

        problem_page.wait_for_page()
        self.assertEqual(problem_page.problem_name, 'TEST PROBLEM')

        problem_page.fill_answer_numerical('1')
        problem_page.click_check()
        self.assertTrue(problem_page.simpleprob_is_correct())
Ejemplo n.º 2
0
 def test_check_hint(self):
     """
     Test clicking Check shows the extended hint in the problem message.
     """
     self.courseware_page.visit()
     problem_page = ProblemPage(self.browser)
     self.assertEqual(problem_page.problem_text[0], u'question text')
     problem_page.fill_answer('C')
     problem_page.click_check()
     self.assertEqual(problem_page.message_text, u'Incorrect: aa bb cc')
     # Check for corresponding tracking event
     actual_events = self.wait_for_events(
         event_filter={'event_type': 'edx.problem.hint.feedback_displayed'},
         number_of_matches=1)
     self.assert_events_match([{
         'event': {
             'hint_label': u'Incorrect',
             'trigger_type': 'single',
             'student_answer': [u'C'],
             'correctness': False,
             'question_type': 'stringresponse',
             'hints': [{
                 'text': '<a href="#">aa bb</a> cc'
             }]
         }
     }], actual_events)
Ejemplo n.º 3
0
    def test_logout_after_click_redirect(self):
        """
        1) User goes to a problem page.
        2) User fills out an answer to the problem.
        3) User is logged out because their session id is invalidated or removed.
        4) User clicks "check", and sees a confirmation modal asking them to
           re-authenticate, since they've just been logged out.
        5) User clicks "ok".
        6) User is redirected to the login page.
        7) User logs in.
        8) User is redirected back to the problem page they started out on.
        9) User is able to submit an answer
        """
        self.courseware_page.visit()
        problem_page = ProblemPage(self.browser)
        self.assertEqual(problem_page.problem_name, 'TEST PROBLEM')
        problem_page.fill_answer_numerical('1')

        self.log_user_out()
        with problem_page.handle_alert(confirm=True):
            problem_page.click_check()

        login_page = CombinedLoginAndRegisterPage(self.browser)
        login_page.wait_for_page()

        login_page.login(self.email, self.password)

        problem_page.wait_for_page()
        self.assertEqual(problem_page.problem_name, 'TEST PROBLEM')

        problem_page.fill_answer_numerical('1')
        problem_page.click_check()
        self.assertTrue(problem_page.simpleprob_is_correct())
Ejemplo n.º 4
0
 def _fulfill_prerequisite(self):
     """
     Fulfill the prerequisite needed to see gated content
     """
     problem_page = ProblemPage(self.browser)
     self.assertEqual(problem_page.wait_for_page().problem_name, 'HEIGHT OF EIFFEL TOWER')
     problem_page.click_choice('choice_1')
     problem_page.click_check()
Ejemplo n.º 5
0
 def _fulfill_prerequisite(self):
     """
     Fulfill the prerequisite needed to see gated content
     """
     problem_page = ProblemPage(self.browser)
     self.assertEqual(problem_page.wait_for_page().problem_name,
                      'HEIGHT OF EIFFEL TOWER')
     problem_page.click_choice('choice_1')
     problem_page.click_check()
Ejemplo n.º 6
0
 def test_partial_credit(self):
     """
     Test that we can see the partial credit value and feedback.
     """
     self.courseware_page.visit()
     problem_page = ProblemPage(self.browser)
     problem_page.wait_for_element_visibility(problem_page.CSS_PROBLEM_HEADER, 'wait for problem header')
     self.assertEqual(problem_page.problem_name, 'PARTIAL CREDIT TEST PROBLEM')
     problem_page.fill_answer_numerical('-1')
     problem_page.click_check()
     problem_page.wait_for_status_icon()
     self.assertTrue(problem_page.simpleprob_is_partially_correct())
 def test_conditional_displays_content(self):
     self.install_course_fixture()
     self.courseware_page.visit()
     # Answer the problem
     problem_page = ProblemPage(self.browser)
     problem_page.fill_answer('correct string')
     problem_page.click_check()
     # The conditional does not update on its own, so we need to reload the page.
     self.courseware_page.visit()
     # Verify that we can see the content.
     conditional_page = ConditionalPage(self.browser)
     self.assertTrue(conditional_page.is_content_visible())
Ejemplo n.º 8
0
 def test_partial_credit(self):
     """
     Test that we can see the partial credit value and feedback.
     """
     self.courseware_page.visit()
     problem_page = ProblemPage(self.browser)
     problem_page.wait_for_element_visibility(
         problem_page.CSS_PROBLEM_HEADER, 'wait for problem header')
     self.assertEqual(problem_page.problem_name,
                      'PARTIAL CREDIT TEST PROBLEM')
     problem_page.fill_answer_numerical('-1')
     problem_page.click_check()
     problem_page.wait_for_status_icon()
     self.assertTrue(problem_page.simpleprob_is_partially_correct())
Ejemplo n.º 9
0
 def test_course_is_unblocked_as_soon_as_student_passes_entrance_exam(self):
     """
     Scenario: Ensure that entrance exam status message is updated and courseware is unblocked as soon as
     student passes entrance exam.
     Given I have a course with entrance exam as pre-requisite
     When I pass entrance exam
     Then I can see complete TOC of course
     And I can see message indicating my pass status
     """
     self.courseware_page.visit()
     problem_page = ProblemPage(self.browser)
     self.assertEqual(problem_page.wait_for_page().problem_name, 'HEIGHT OF EIFFEL TOWER')
     self.assertTrue(self.courseware_page.has_entrance_exam_message())
     self.assertFalse(self.courseware_page.has_passed_message())
     problem_page.click_choice('choice_1')
     problem_page.click_check()
     self.courseware_page.wait_for_page()
     self.assertTrue(self.courseware_page.has_passed_message())
     self.assertEqual(self.courseware_page.chapter_count_in_navigation, 2)
Ejemplo n.º 10
0
    def test_logout_cancel_no_redirect(self):
        """
        1) User goes to a problem page.
        2) User fills out an answer to the problem.
        3) User is logged out because their session id is invalidated or removed.
        4) User clicks "check", and sees a confirmation modal asking them to
           re-authenticate, since they've just been logged out.
        5) User clicks "cancel".
        6) User is not redirected to the login page.
        """
        self.courseware_page.visit()
        problem_page = ProblemPage(self.browser)
        self.assertEqual(problem_page.problem_name, 'TEST PROBLEM')
        problem_page.fill_answer_numerical('1')
        self.log_user_out()
        with problem_page.handle_alert(confirm=False):
            problem_page.click_check()

        self.assertTrue(problem_page.is_browser_on_page())
        self.assertEqual(problem_page.problem_name, 'TEST PROBLEM')
Ejemplo n.º 11
0
    def test_logout_cancel_no_redirect(self):
        """
        1) User goes to a problem page.
        2) User fills out an answer to the problem.
        3) User is logged out because their session id is invalidated or removed.
        4) User clicks "check", and sees a confirmation modal asking them to
           re-authenticate, since they've just been logged out.
        5) User clicks "cancel".
        6) User is not redirected to the login page.
        """
        self.courseware_page.visit()
        problem_page = ProblemPage(self.browser)
        self.assertEqual(problem_page.problem_name, 'TEST PROBLEM')
        problem_page.fill_answer_numerical('1')
        self.log_user_out()
        with problem_page.handle_alert(confirm=False):
            problem_page.click_check()

        self.assertTrue(problem_page.is_browser_on_page())
        self.assertEqual(problem_page.problem_name, 'TEST PROBLEM')
Ejemplo n.º 12
0
 def test_check_hint(self):
     """
     Test clicking Check shows the extended hint in the problem message.
     """
     self.courseware_page.visit()
     problem_page = ProblemPage(self.browser)
     self.assertEqual(problem_page.problem_text[0], u'question text')
     problem_page.fill_answer('C')
     problem_page.click_check()
     self.assertEqual(problem_page.message_text, u'Incorrect: aa bb cc')
     # Check for corresponding tracking event
     actual_events = self.wait_for_events(
         event_filter={'event_type': 'edx.problem.hint.feedback_displayed'},
         number_of_matches=1
     )
     self.assert_events_match(
         [{'event': {'hint_label': u'Incorrect',
                     'trigger_type': 'single',
                     'student_answer': [u'C'],
                     'correctness': False,
                     'question_type': 'stringresponse',
                     'hints': [{'text': '<a href="#">aa bb</a> cc'}]}}],
         actual_events)
Ejemplo n.º 13
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)