Only delete latest grade override if it came from proctoring

... on proctored exam attempt deletion

JIRA:EDUCATOR-4642
This commit is contained in:
Matt Hughes
2019-09-13 10:24:07 -04:00
committed by Matt Hughes
parent e80b76c3db
commit 4957b981a4
3 changed files with 32 additions and 3 deletions

View File

@@ -65,6 +65,7 @@ def override_subsection_grade(
requesting_user=overrider,
subsection_grade_model=grade,
feature=feature,
system=feature,
earned_all_override=earned_all,
earned_graded_override=earned_graded,
)
@@ -93,6 +94,10 @@ def undo_override_subsection_grade(user_id, course_key_or_id, usage_key_or_id, f
Fires off a recalculate_subsection_grade async task to update the PersistentSubsectionGrade table. If the
override does not exist, no error is raised, it just triggers the recalculation.
feature: if specified, the deletion will only occur if the
override to be deleted was created by the corresponding
subsystem
"""
course_key = _get_key(course_key_or_id, CourseKey)
usage_key = _get_key(usage_key_or_id, UsageKey)
@@ -102,8 +107,8 @@ def undo_override_subsection_grade(user_id, course_key_or_id, usage_key_or_id, f
except ObjectDoesNotExist:
return
# Older rejected exam attempts that transition to verified might not have an override created
if override is not None:
if override is not None and (
not feature or feature == override.system):
override.delete(feature=feature)
# Cache a new event id and event type which the signal handler will use to emit a tracking log event.

View File

@@ -15,3 +15,4 @@ class ScoreDatabaseTableEnum(object):
class GradeOverrideFeatureEnum(object):
proctoring = 'PROCTORING'
gradebook = 'GRADEBOOK'
grade_import = 'grade-import'

View File

@@ -259,7 +259,10 @@ class GradesServiceTests(ModuleStoreTestCase):
@freeze_time('2017-01-01')
def test_undo_override_subsection_grade(self):
override, _ = PersistentSubsectionGradeOverride.objects.update_or_create(grade=self.grade)
override, _ = PersistentSubsectionGradeOverride.objects.update_or_create(
grade=self.grade,
system=GradeOverrideFeatureEnum.proctoring
)
override_id = override.id
self.service.undo_override_subsection_grade(
user_id=self.user.id,
@@ -286,6 +289,26 @@ class GradesServiceTests(ModuleStoreTestCase):
override_history = PersistentSubsectionGradeOverrideHistory.objects.filter(override_id=override_id).first()
self._verify_override_history(override_history, PersistentSubsectionGradeOverrideHistory.DELETE)
def test_undo_override_subsection_grade_across_features(self):
"""
Test that deletion of subsection grade overrides requested by
one feature doesn't delete overrides created by another
feature.
"""
override, _ = PersistentSubsectionGradeOverride.objects.update_or_create(
grade=self.grade,
system=GradeOverrideFeatureEnum.gradebook
)
self.service.undo_override_subsection_grade(
user_id=self.user.id,
course_key_or_id=self.course.id,
usage_key_or_id=self.subsection.location,
feature=GradeOverrideFeatureEnum.proctoring,
)
override = self.service.get_subsection_grade_override(self.user.id, self.course.id, self.subsection.location)
self.assertIsNotNone(override)
@freeze_time('2018-01-01')
def test_undo_override_subsection_grade_without_grade(self):
"""