예제 #1
0
    def test_do_attempt_feedback_is_updated(self):
        """
        Test updating overall feedback after submitting solution in assessment mode
        """
        # used keyboard mode to avoid bug/feature with selenium "selecting" everything instead of dragging an element
        self.place_item(0, TOP_ZONE_ID, Keys.RETURN)

        self.click_submit()

        # There are five items total (4 items with zones and one decoy item).
        # We place the first item into correct zone and left the decoy item in the bank,
        # which means the current grade is 2/5.
        expected_grade = 2.0 / 5.0

        feedback_lines = [
            "FEEDBACK",
            FeedbackMessages.correctly_placed(1),
            FeedbackMessages.not_placed(3),
            START_FEEDBACK,
            FeedbackMessages.GRADE_FEEDBACK_TPL.format(score=expected_grade)
        ]
        expected_feedback = "\n".join(feedback_lines)
        self.assertEqual(self._get_feedback().text, expected_feedback)

        # Place the item into incorrect zone. The score does not change.
        self.place_item(1, BOTTOM_ZONE_ID, Keys.RETURN)
        self.click_submit()

        feedback_lines = [
            "FEEDBACK",
            FeedbackMessages.correctly_placed(1),
            FeedbackMessages.misplaced_returned(1),
            FeedbackMessages.not_placed(2),
            START_FEEDBACK,
            FeedbackMessages.GRADE_FEEDBACK_TPL.format(score=expected_grade)
        ]
        expected_feedback = "\n".join(feedback_lines)
        self.assertEqual(self._get_feedback().text, expected_feedback)

        # reach final attempt
        for _ in xrange(self.MAX_ATTEMPTS-3):
            self.click_submit()

        self.place_item(1, MIDDLE_ZONE_ID, Keys.RETURN)
        self.place_item(2, BOTTOM_ZONE_ID, Keys.RETURN)
        self.place_item(3, TOP_ZONE_ID, Keys.RETURN)

        self.click_submit()

        # All items are correctly placed, so we get the full score (1.0).
        expected_grade = 1.0

        feedback_lines = [
            "FEEDBACK",
            FeedbackMessages.correctly_placed(4),
            FINISH_FEEDBACK,
            FeedbackMessages.FINAL_ATTEMPT_TPL.format(score=expected_grade)
        ]
        expected_feedback = "\n".join(feedback_lines)
        self.assertEqual(self._get_feedback().text, expected_feedback)
    def test_do_attempt_feedback_is_updated(self):
        """
        Test updating overall feedback after submitting solution in assessment mode
        """
        # used keyboard mode to avoid bug/feature with selenium "selecting" everything instead of dragging an element
        self.place_item(0, TOP_ZONE_ID, Keys.RETURN)

        self.click_submit()

        feedback_lines = [
            "FEEDBACK",
            FeedbackMessages.correctly_placed(1),
            FeedbackMessages.not_placed(3),
            START_FEEDBACK
        ]
        expected_feedback = "\n".join(feedback_lines)
        self.assertEqual(self._get_feedback().text, expected_feedback)

        self.place_item(1, BOTTOM_ZONE_ID, Keys.RETURN)
        self.click_submit()

        feedback_lines = [
            "FEEDBACK",
            FeedbackMessages.correctly_placed(1),
            FeedbackMessages.misplaced_returned(1),
            FeedbackMessages.not_placed(2),
            START_FEEDBACK
        ]
        expected_feedback = "\n".join(feedback_lines)
        self.assertEqual(self._get_feedback().text, expected_feedback)

        # reach final attempt
        for _ in xrange(self.MAX_ATTEMPTS-3):
            self.click_submit()

        self.place_item(1, MIDDLE_ZONE_ID, Keys.RETURN)
        self.place_item(2, BOTTOM_ZONE_ID, Keys.RETURN)
        self.place_item(3, TOP_ZONE_ID, Keys.RETURN)

        self.click_submit()
        feedback_lines = [
            "FEEDBACK",
            FeedbackMessages.correctly_placed(4),
            FINISH_FEEDBACK,
            FeedbackMessages.FINAL_ATTEMPT_TPL.format(score=1.0)
        ]
        expected_feedback = "\n".join(feedback_lines)
        self.assertEqual(self._get_feedback().text, expected_feedback)
    def test_do_attempt_feedback_correct_and_decoy(self):
        self._submit_solution({
            0: self.ZONE_1,
            1: self.ZONE_2,
            3: self.ZONE_2
        })  # incorrect solution - decoy placed
        res = self._do_attempt()

        expected_item_feedback = []
        expected_overall_feedback = [
            self._make_feedback_message(
                FeedbackMessages.correctly_placed(2),
                FeedbackMessages.MessageClasses.CORRECTLY_PLACED),
            self._make_feedback_message(
                FeedbackMessages.misplaced_returned(1),
                FeedbackMessages.MessageClasses.MISPLACED),
            self._make_feedback_message(
                FeedbackMessages.not_placed(1),
                FeedbackMessages.MessageClasses.NOT_PLACED),
            self._make_feedback_message(self.INITIAL_FEEDBACK, None),
            self._make_feedback_message(
                FeedbackMessages.GRADE_FEEDBACK_TPL.format(
                    score=self.block.grade),
                FeedbackMessages.MessageClasses.PARTIAL_SOLUTION),
        ]

        self._assert_item_and_overall_feedback(res, expected_item_feedback,
                                               expected_overall_feedback)
    def test_do_attempt_feedback_correct_and_decoy(self):
        self._submit_solution({0: self.ZONE_1, 1: self.ZONE_2, 3: self.ZONE_2})  # incorrect solution - decoy placed
        res = self._do_attempt()

        expected_item_feedback = []
        expected_overall_feedback = [
            self._make_feedback_message(
                FeedbackMessages.correctly_placed(2),
                FeedbackMessages.MessageClasses.CORRECTLY_PLACED
            ),
            self._make_feedback_message(
                FeedbackMessages.misplaced_returned(1),
                FeedbackMessages.MessageClasses.MISPLACED
            ),
            self._make_feedback_message(
                FeedbackMessages.not_placed(1),
                FeedbackMessages.MessageClasses.NOT_PLACED
            ),
            self._make_feedback_message(
                self.INITIAL_FEEDBACK,
                None
            ),
        ]

        self._assert_item_and_overall_feedback(res, expected_item_feedback, expected_overall_feedback)
    def test_do_attempt_feedback_is_updated(self):
        """
        Test updating overall feedback after submitting solution in assessment mode
        """
        # used keyboard mode to avoid bug/feature with selenium "selecting" everything instead of dragging an element
        self.place_item(0, TOP_ZONE_ID, Keys.RETURN)

        self.click_submit()

        feedback_lines = [
            "FEEDBACK",
            FeedbackMessages.correctly_placed(1),
            FeedbackMessages.not_placed(3), START_FEEDBACK
        ]
        expected_feedback = "\n".join(feedback_lines)
        self.assertEqual(self._get_feedback().text, expected_feedback)

        self.place_item(1, BOTTOM_ZONE_ID, Keys.RETURN)
        self.click_submit()

        feedback_lines = [
            "FEEDBACK",
            FeedbackMessages.correctly_placed(1),
            FeedbackMessages.misplaced_returned(1),
            FeedbackMessages.not_placed(2), START_FEEDBACK
        ]
        expected_feedback = "\n".join(feedback_lines)
        self.assertEqual(self._get_feedback().text, expected_feedback)

        # reach final attempt
        for _ in xrange(self.MAX_ATTEMPTS - 3):
            self.click_submit()

        self.place_item(1, MIDDLE_ZONE_ID, Keys.RETURN)
        self.place_item(2, BOTTOM_ZONE_ID, Keys.RETURN)
        self.place_item(3, TOP_ZONE_ID, Keys.RETURN)

        self.click_submit()
        feedback_lines = [
            "FEEDBACK",
            FeedbackMessages.correctly_placed(4), FINISH_FEEDBACK,
            FeedbackMessages.FINAL_ATTEMPT_TPL.format(score=1.0)
        ]
        expected_feedback = "\n".join(feedback_lines)
        self.assertEqual(self._get_feedback().text, expected_feedback)
    def test_do_attempt_feedback_partial(self):
        self._submit_solution({0: self.ZONE_1})  # partial solution
        res = self._do_attempt()

        expected_item_feedback = []
        expected_overall_feedback = [
            self._make_feedback_message(
                FeedbackMessages.correctly_placed(1), FeedbackMessages.MessageClasses.CORRECTLY_PLACED
            ),
            self._make_feedback_message(FeedbackMessages.not_placed(2), FeedbackMessages.MessageClasses.NOT_PLACED),
            self._make_feedback_message(self.INITIAL_FEEDBACK, None),
        ]

        self._assert_item_and_overall_feedback(res, expected_item_feedback, expected_overall_feedback)
    def test_do_attempt_no_item_state(self):
        """
        Test do_attempt overall feedback when no item state is saved - no items were ever dropped.
        """
        res = self._do_attempt()
        self.assertEqual(res[self.FEEDBACK_KEY], [])

        expected_item_feedback = []
        expected_overall_feedback = [
            self._make_feedback_message(FeedbackMessages.not_placed(3), FeedbackMessages.MessageClasses.NOT_PLACED),
            self._make_feedback_message(self.INITIAL_FEEDBACK, None),
        ]

        self._assert_item_and_overall_feedback(res, expected_item_feedback, expected_overall_feedback)
예제 #8
0
    def test_do_attempt_feedback_partial(self):
        self._submit_solution({0: self.ZONE_1})  # partial solution
        res = self._do_attempt()

        expected_item_feedback = []
        expected_overall_feedback = [
            self._make_feedback_message(
                FeedbackMessages.correctly_placed(1),
                FeedbackMessages.MessageClasses.CORRECTLY_PLACED),
            self._make_feedback_message(
                FeedbackMessages.not_placed(2),
                FeedbackMessages.MessageClasses.NOT_PLACED),
            self._make_feedback_message(self.INITIAL_FEEDBACK, None),
        ]

        self._assert_item_and_overall_feedback(res, expected_item_feedback,
                                               expected_overall_feedback)
예제 #9
0
    def test_do_attempt_no_item_state(self):
        """
        Test do_attempt overall feedback when no item state is saved - no items were ever dropped.
        """
        res = self._do_attempt()
        self.assertEqual(res[self.FEEDBACK_KEY], [])

        expected_item_feedback = []
        expected_overall_feedback = [
            self._make_feedback_message(
                FeedbackMessages.not_placed(3),
                FeedbackMessages.MessageClasses.NOT_PLACED),
            self._make_feedback_message(self.INITIAL_FEEDBACK, None),
        ]

        self._assert_item_and_overall_feedback(res, expected_item_feedback,
                                               expected_overall_feedback)
    def test_do_attempt_feedback_partial(self):
        self._submit_solution({0: self.ZONE_1})  # partial solution
        res = self._do_attempt()

        expected_item_feedback = []
        expected_overall_feedback = [
            self._make_feedback_message(
                FeedbackMessages.correctly_placed(1), FeedbackMessages.MessageClasses.CORRECTLY_PLACED
            ),
            self._make_feedback_message(FeedbackMessages.not_placed(2), FeedbackMessages.MessageClasses.NOT_PLACED),
            self._make_feedback_message(self.INITIAL_FEEDBACK, None),
            self._make_feedback_message(
                FeedbackMessages.GRADE_FEEDBACK_TPL.format(score=self.block.weighted_grade()),
                FeedbackMessages.MessageClasses.PARTIAL_SOLUTION
            ),
        ]

        self._assert_item_and_overall_feedback(res, expected_item_feedback, expected_overall_feedback)
    def test_do_attempt_no_item_state(self):
        """
        Test do_attempt overall feedback when no item state is saved - no items were ever dropped.
        """
        res = self._do_attempt()
        self.assertEqual(res[self.FEEDBACK_KEY], [])

        expected_item_feedback = []
        expected_overall_feedback = [
            self._make_feedback_message(FeedbackMessages.not_placed(3), FeedbackMessages.MessageClasses.NOT_PLACED),
            self._make_feedback_message(self.INITIAL_FEEDBACK, None),
            self._make_feedback_message(
                FeedbackMessages.GRADE_FEEDBACK_TPL.format(score=self.block.weighted_grade()),
                FeedbackMessages.MessageClasses.PARTIAL_SOLUTION
            )
        ]

        self._assert_item_and_overall_feedback(res, expected_item_feedback, expected_overall_feedback)
예제 #12
0
    def test_do_attempt_feedback_incorrect_not_placed(self):
        self._submit_solution({0: self.ZONE_2, 1: self.ZONE_2})
        res = self._do_attempt()

        expected_item_feedback = [
            self._make_feedback_message(self.FEEDBACK[0]['incorrect'])
        ]
        expected_overall_feedback = [
            self._make_feedback_message(
                FeedbackMessages.correctly_placed(1),
                FeedbackMessages.MessageClasses.CORRECTLY_PLACED),
            self._make_feedback_message(
                FeedbackMessages.misplaced_returned(1),
                FeedbackMessages.MessageClasses.MISPLACED),
            self._make_feedback_message(
                FeedbackMessages.not_placed(1),
                FeedbackMessages.MessageClasses.NOT_PLACED),
            self._make_feedback_message(self.INITIAL_FEEDBACK, None),
        ]

        self._assert_item_and_overall_feedback(res, expected_item_feedback,
                                               expected_overall_feedback)
예제 #13
0
    def test_do_attempt_feedback_is_updated(self):
        """
        Test updating overall feedback after submitting solution in assessment mode
        """
        def check_feedback(overall_feedback_lines,
                           per_item_feedback_lines=None):
            # Check that the feedback is correctly displayed in the overall feedback area.
            expected_overall_feedback = "\n".join(["FEEDBACK"] +
                                                  overall_feedback_lines)
            self.assertEqual(self._get_feedback().text,
                             expected_overall_feedback)

            # Check that the SR.readText function was passed correct feedback messages.
            sr_feedback_lines = overall_feedback_lines
            if per_item_feedback_lines:
                sr_feedback_lines += [
                    "Some of your answers were not correct.", "Hints:"
                ]
                sr_feedback_lines += per_item_feedback_lines
            self.assert_reader_feedback_messages(sr_feedback_lines)

        # used keyboard mode to avoid bug/feature with selenium "selecting" everything instead of dragging an element
        self.place_item(0, TOP_ZONE_ID, Keys.RETURN)

        self.click_submit()

        # There are five items total (4 items with zones and one decoy item).
        # We place the first item into correct zone and left the decoy item in the bank,
        # which means the current grade is 2/5.
        expected_grade = 2.0 / 5.0

        feedback_lines = [
            FeedbackMessages.correctly_placed(1),
            FeedbackMessages.not_placed(3), START_FEEDBACK,
            FeedbackMessages.GRADE_FEEDBACK_TPL.format(score=expected_grade)
        ]
        check_feedback(feedback_lines)

        # Place the item into incorrect zone. The score does not change.
        self.place_item(1, BOTTOM_ZONE_ID, Keys.RETURN)
        self.click_submit()

        feedback_lines = [
            FeedbackMessages.correctly_placed(1),
            FeedbackMessages.misplaced_returned(1),
            FeedbackMessages.not_placed(2), START_FEEDBACK,
            FeedbackMessages.GRADE_FEEDBACK_TPL.format(score=expected_grade)
        ]
        check_feedback(feedback_lines,
                       ["No, this item does not belong here. Try again."])

        # reach final attempt
        for _ in xrange(self.MAX_ATTEMPTS - 3):
            self.click_submit()

        self.place_item(1, MIDDLE_ZONE_ID, Keys.RETURN)
        self.place_item(2, BOTTOM_ZONE_ID, Keys.RETURN)
        self.place_item(3, TOP_ZONE_ID, Keys.RETURN)

        self.click_submit()

        # All items are correctly placed, so we get the full score (1.0).
        expected_grade = 1.0

        feedback_lines = [
            FeedbackMessages.correctly_placed(4), FINISH_FEEDBACK,
            FeedbackMessages.FINAL_ATTEMPT_TPL.format(score=expected_grade)
        ]
        check_feedback(feedback_lines)