Skip to content

Commit

Permalink
Only delete latest grade override if it came from proctoring
Browse files Browse the repository at this point in the history
... on proctored exam attempt deletion

JIRA:EDUCATOR-4642
  • Loading branch information
Matt Hughes authored and matthugs committed Sep 13, 2019
1 parent e80b76c commit 4957b98
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
9 changes: 7 additions & 2 deletions lms/djangoapps/grades/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down Expand Up @@ -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)
Expand All @@ -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.
Expand Down
1 change: 1 addition & 0 deletions lms/djangoapps/grades/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ class ScoreDatabaseTableEnum(object):
class GradeOverrideFeatureEnum(object):
proctoring = 'PROCTORING'
gradebook = 'GRADEBOOK'
grade_import = 'grade-import'
25 changes: 24 additions & 1 deletion lms/djangoapps/grades/tests/test_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,10 @@ def test_override_subsection_grade_no_psg(self):

@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,
Expand All @@ -286,6 +289,26 @@ def test_undo_override_subsection_grade(self):
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):
"""
Expand Down

0 comments on commit 4957b98

Please sign in to comment.