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_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_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_grade_feedback_with_zero_weight(self):
        self.block.weight = 0
        self.block.save()

        self._submit_solution({0: self.ZONE_1})  # partial solution
        self._do_attempt()

        self._submit_solution({
            0: self.ZONE_1,
            1: self.ZONE_2,
            2: self.ZONE_2
        })  # correct solution
        res = self._do_attempt()

        expected_item_feedback = []
        expected_overall_feedback = [
            self._make_feedback_message(
                FeedbackMessages.correctly_placed(3),
                FeedbackMessages.MessageClasses.CORRECTLY_PLACED),
            self._make_feedback_message(
                self.FINAL_FEEDBACK,
                FeedbackMessages.MessageClasses.CORRECT_SOLUTION)
        ]

        self._assert_item_and_overall_feedback(res, expected_item_feedback,
                                               expected_overall_feedback)
Example #5
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)
 def test_do_attempt_shows_correct_misplaced_feedback_at_last_attempt(self):
     self._set_final_attempt()
     self._submit_solution({0: self.ZONE_2})
     res = self._do_attempt()
     misplaced_message = self._make_feedback_message(
         FeedbackMessages.misplaced(1),
         FeedbackMessages.MessageClasses.MISPLACED)
     self.assertIn(misplaced_message, res[self.OVERALL_FEEDBACK_KEY])
    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_shows_correct_misplaced_feedback_at_last_attempt(self):
     self._set_final_attempt()
     self._submit_solution({0: self.ZONE_2})
     res = self._do_attempt()
     misplaced_message = self._make_feedback_message(
         FeedbackMessages.misplaced(1),
         FeedbackMessages.MessageClasses.MISPLACED
     )
     self.assertIn(misplaced_message, res[self.OVERALL_FEEDBACK_KEY])
Example #9
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_correct(self):
        self._submit_solution({0: self.ZONE_1, 1: self.ZONE_2, 2: self.ZONE_2})  # correct solution
        res = self._do_attempt()

        expected_item_feedback = []
        expected_overall_feedback = [
            self._make_feedback_message(
                FeedbackMessages.correctly_placed(3), FeedbackMessages.MessageClasses.CORRECTLY_PLACED
            ),
            self._make_feedback_message(self.FINAL_FEEDBACK, FeedbackMessages.MessageClasses.CORRECT_SOLUTION),
        ]

        self._assert_item_and_overall_feedback(res, expected_item_feedback, expected_overall_feedback)
Example #11
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)
    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_correct(self):
        self._submit_solution({0: self.ZONE_1, 1: self.ZONE_2, 2: self.ZONE_2})  # correct solution
        res = self._do_attempt()

        expected_item_feedback = []
        expected_overall_feedback = [
            self._make_feedback_message(
                FeedbackMessages.correctly_placed(3), FeedbackMessages.MessageClasses.CORRECTLY_PLACED
            ),
            self._make_feedback_message(self.FINAL_FEEDBACK, FeedbackMessages.MessageClasses.CORRECT_SOLUTION),
            self._make_feedback_message(
                FeedbackMessages.GRADE_FEEDBACK_TPL.format(score=self.block.weighted_grade()),
                FeedbackMessages.MessageClasses.CORRECT_SOLUTION
            ),
        ]

        self._assert_item_and_overall_feedback(res, expected_item_feedback, expected_overall_feedback)
Example #14
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_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)
    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_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)
Example #18
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)