コード例 #1
0
ファイル: test_lms_problems.py プロジェクト: fdns/eol-edx
    def test_mathjax_in_hint(self):
        """
        Test that MathJax have successfully rendered in problem hint
        """
        self.courseware_page.visit()
        problem_page = ProblemPage(self.browser)
        self.assertEqual(problem_page.problem_name, "MATHJAX TEST PROBLEM")

        problem_page.verify_mathjax_rendered_in_problem()

        # The hint button rotates through multiple hints
        problem_page.click_hint(hint_index=0)
        self.assertEqual(
            ["<strong>Hint (1 of 2): </strong>mathjax should work1"],
            problem_page.extract_hint_text_from_html)
        problem_page.verify_mathjax_rendered_in_hint()

        # Rotate the hint and check the problem hint
        problem_page.click_hint(hint_index=1)

        self.assertEqual([
            "<strong>Hint (1 of 2): </strong>mathjax should work1",
            "<strong>Hint (2 of 2): </strong>mathjax should work2"
        ], problem_page.extract_hint_text_from_html)

        problem_page.verify_mathjax_rendered_in_hint()
コード例 #2
0
    def test_mathjax_in_hint(self):
        """
        Test that MathJax have successfully rendered in problem hint
        """
        self.courseware_page.visit()
        problem_page = ProblemPage(self.browser)
        self.assertEqual(problem_page.problem_name, "MATHJAX TEST PROBLEM")

        problem_page.verify_mathjax_rendered_in_problem()

        # The hint button rotates through multiple hints
        problem_page.click_hint(hint_index=0)
        self.assertEqual(
            ["<strong>Hint (1 of 2): </strong>mathjax should work1"],
            problem_page.extract_hint_text_from_html
        )
        problem_page.verify_mathjax_rendered_in_hint()

        # Rotate the hint and check the problem hint
        problem_page.click_hint(hint_index=1)

        self.assertEqual(
            [
                "<strong>Hint (1 of 2): </strong>mathjax should work1",
                "<strong>Hint (2 of 2): </strong>mathjax should work2"
            ],
            problem_page.extract_hint_text_from_html
        )

        problem_page.verify_mathjax_rendered_in_hint()
コード例 #3
0
    def verify_demand_hints(self, first_hint, second_hint, expected_events):
        """
        Test clicking through the demand hints and verify the events sent.
        """
        self.courseware_page.visit()
        problem_page = ProblemPage(self.browser)

        # The hint notification should not be visible on load
        self.assertFalse(problem_page.is_hint_notification_visible())

        # The two Hint button should be enabled. One visible, one present, but not visible in the DOM
        self.assertEqual([None, None], problem_page.get_hint_button_disabled_attr())

        # The hint button rotates through multiple hints
        problem_page.click_hint(hint_index=0)
        self.assertTrue(problem_page.is_hint_notification_visible())
        self.assertEqual(problem_page.hint_text, first_hint)
        # Now there are two "hint" buttons, as there is also one in the hint notification.
        self.assertEqual([None, None], problem_page.get_hint_button_disabled_attr())

        problem_page.click_hint(hint_index=1)
        self.assertEqual(problem_page.hint_text, second_hint)
        # Now both "hint" buttons should be disabled, as there are no more hints.
        self.assertEqual(['true', 'true'], problem_page.get_hint_button_disabled_attr())

        # Now click on "Review" and make sure the focus goes to the correct place.
        problem_page.click_review_in_notification(notification_type='hint')
        problem_page.wait_for_focus_on_problem_meta()

        # Check corresponding tracking events
        actual_events = self.wait_for_events(
            event_filter={'event_type': 'edx.problem.hint.demandhint_displayed'},
            number_of_matches=2
        )
        self.assert_events_match(expected_events, actual_events)
コード例 #4
0
    def verify_demand_hints(self, first_hint, second_hint, expected_events):
        """
        Test clicking through the demand hints and verify the events sent.
        """
        self.courseware_page.visit()
        problem_page = ProblemPage(self.browser)

        # The hint notification should not be visible on load
        self.assertFalse(problem_page.is_hint_notification_visible())

        # The two Hint button should be enabled. One visible, one present, but not visible in the DOM
        self.assertEqual([None, None], problem_page.get_hint_button_disabled_attr())

        # The hint button rotates through multiple hints
        problem_page.click_hint(hint_index=0)
        self.assertTrue(problem_page.is_hint_notification_visible())
        self.assertEqual(problem_page.hint_text, first_hint)
        # Now there are two "hint" buttons, as there is also one in the hint notification.
        self.assertEqual([None, None], problem_page.get_hint_button_disabled_attr())

        problem_page.click_hint(hint_index=1)
        self.assertEqual(problem_page.hint_text, second_hint)
        # Now both "hint" buttons should be disabled, as there are no more hints.
        self.assertEqual(['true', 'true'], problem_page.get_hint_button_disabled_attr())

        # Now click on "Review" and make sure the focus goes to the correct place.
        problem_page.click_review_in_notification(notification_type='hint')
        problem_page.wait_for_focus_on_problem_meta()

        # Check corresponding tracking events
        actual_events = self.wait_for_events(
            event_filter={'event_type': 'edx.problem.hint.demandhint_displayed'},
            number_of_matches=2
        )
        self.assert_events_match(expected_events, actual_events)
コード例 #5
0
 def test_demand_hint(self):
     """
     Test clicking hint button shows the demand hint in its div.
     """
     self.courseware_page.visit()
     problem_page = ProblemPage(self.browser)
     # The hint button rotates through multiple hints
     problem_page.click_hint()
     self.assertEqual(problem_page.hint_text, u'Hint (1 of 2): aa bb cc')
     problem_page.click_hint()
     self.assertEqual(problem_page.hint_text, u'Hint (2 of 2): dd ee ff')
     problem_page.click_hint()
     self.assertEqual(problem_page.hint_text, u'Hint (1 of 2): aa bb cc')
     # Check corresponding tracking events
     actual_events = self.wait_for_events(
         event_filter={'event_type': 'edx.problem.hint.demandhint_displayed'},
         number_of_matches=3
     )
     self.assert_events_match(
         [
             {'event': {u'hint_index': 0, u'hint_len': 2, u'hint_text': u'aa <a href="#">bb</a> cc'}},
             {'event': {u'hint_index': 1, u'hint_len': 2, u'hint_text': u'<a href="#">dd  ee</a> ff'}},
             {'event': {u'hint_index': 0, u'hint_len': 2, u'hint_text': u'aa <a href="#">bb</a> cc'}}
         ],
         actual_events)
コード例 #6
0
 def test_demand_hint(self):
     """
     Test clicking hint button shows the demand hint in its div.
     """
     self.courseware_page.visit()
     problem_page = ProblemPage(self.browser)
     # The hint button rotates through multiple hints
     problem_page.click_hint()
     self.assertEqual(problem_page.hint_text,
                      u'Hint (1 of 2): demand-hint1')
     problem_page.click_hint()
     self.assertEqual(problem_page.hint_text,
                      u'Hint (2 of 2): demand-hint2')
     problem_page.click_hint()
     self.assertEqual(problem_page.hint_text,
                      u'Hint (1 of 2): demand-hint1')
     # Check corresponding tracking events
     actual_events = self.wait_for_events(event_filter={
         'event_type':
         'edx.problem.hint.demandhint_displayed'
     },
                                          number_of_matches=3)
     self.assert_events_match([{
         'event': {
             u'hint_index': 0,
             u'hint_len': 2,
             u'hint_text': u'demand-hint1'
         }
     }, {
         'event': {
             u'hint_index': 1,
             u'hint_len': 2,
             u'hint_text': u'demand-hint2'
         }
     }, {
         'event': {
             u'hint_index': 0,
             u'hint_len': 2,
             u'hint_text': u'demand-hint1'
         }
     }], actual_events)