Ejemplo n.º 1
0
    def test_override_subsection_grade(self, earned_graded):
        api.override_subsection_grade(
            self.user.id,
            self.course.id,
            self.subsection.location,
            overrider=self.overriding_user,
            earned_graded=earned_graded,
            comment='Test Override Comment',
        )
        override_obj = api.get_subsection_grade_override(
            self.user.id,
            self.course.id,
            self.subsection.location
        )
        assert override_obj is not None
        assert override_obj.earned_graded_override == earned_graded
        assert override_obj.override_reason == 'Test Override Comment'

        for i in range(3):
            override_obj.override_reason = 'this field purposefully left blank'
            override_obj.earned_graded_override = i
            override_obj.save()

        api.override_subsection_grade(
            self.user.id,
            self.course.id,
            self.subsection.location,
            overrider=self.overriding_user,
            earned_graded=earned_graded,
            comment='Test Override Comment 2',
        )
        override_obj = api.get_subsection_grade_override(
            self.user.id,
            self.course.id,
            self.subsection.location
        )

        assert override_obj is not None
        assert override_obj.earned_graded_override == earned_graded
        assert override_obj.override_reason == 'Test Override Comment 2'

        assert 5 == len(override_obj.history.all())
        for history_entry in override_obj.history.all():
            if history_entry.override_reason.startswith('Test Override Comment'):
                assert self.overriding_user == history_entry.history_user
                assert self.overriding_user.id == history_entry.history_user_id
            else:
                assert history_entry.history_user is None
                assert history_entry.history_user_id is None
Ejemplo n.º 2
0
    def test_override_subsection_grade(self, earned_graded):
        api.override_subsection_grade(
            self.user.id,
            self.course.id,
            self.subsection.location,
            overrider=self.overriding_user,
            earned_graded=earned_graded,
            comment='Test Override Comment',
        )
        override_obj = api.get_subsection_grade_override(
            self.user.id,
            self.course.id,
            self.subsection.location
        )
        self.assertIsNotNone(override_obj)
        self.assertEqual(override_obj.earned_graded_override, earned_graded)
        self.assertEqual(override_obj.override_reason, 'Test Override Comment')

        for i in range(3):
            override_obj.override_reason = 'this field purposefully left blank'
            override_obj.earned_graded_override = i
            override_obj.save()

        api.override_subsection_grade(
            self.user.id,
            self.course.id,
            self.subsection.location,
            overrider=self.overriding_user,
            earned_graded=earned_graded,
            comment='Test Override Comment 2',
        )
        override_obj = api.get_subsection_grade_override(
            self.user.id,
            self.course.id,
            self.subsection.location
        )

        self.assertIsNotNone(override_obj)
        self.assertEqual(override_obj.earned_graded_override, earned_graded)
        self.assertEqual(override_obj.override_reason, 'Test Override Comment 2')

        self.assertEqual(5, len(override_obj.history.all()))
        for history_entry in override_obj.history.all():
            if history_entry.override_reason.startswith('Test Override Comment'):
                self.assertEqual(self.overriding_user, history_entry.history_user)
                self.assertEqual(self.overriding_user.id, history_entry.history_user_id)
            else:
                self.assertIsNone(history_entry.history_user)
                self.assertIsNone(history_entry.history_user_id)
Ejemplo n.º 3
0
    def process_row(self, row):
        """
        Save a row to the persistent subsection override table.
        """
        for block_id, new_grade in row['new_override_grades']:
            grades_api.override_subsection_grade(
                row['user_id'],
                row['course_id'],
                block_id,
                overrider=self._user,
                earned_graded=new_grade,
                feature='grade-import',
                comment='Bulk Grade Import',
            )

        return True, None