diff --git a/lms/djangoapps/grades/tasks.py b/lms/djangoapps/grades/tasks.py index ce0c7e6504..4802ee9da2 100644 --- a/lms/djangoapps/grades/tasks.py +++ b/lms/djangoapps/grades/tasks.py @@ -32,8 +32,10 @@ def recalculate_subsection_grade(user_id, course_id, usage_id, only_if_higher): be updated only if the new grade is higher than the previous value. """ - course_key = CourseLocator.from_string(course_id) + if not PersistentGradesEnabledFlag.feature_enabled(course_id): + return + course_key = CourseLocator.from_string(course_id) student = User.objects.get(id=user_id) scored_block_usage_key = UsageKey.from_string(usage_id).replace(course_key=course_key) diff --git a/lms/djangoapps/grades/tests/test_tasks.py b/lms/djangoapps/grades/tests/test_tasks.py index 5379338846..5e7877611d 100644 --- a/lms/djangoapps/grades/tests/test_tasks.py +++ b/lms/djangoapps/grades/tests/test_tasks.py @@ -178,7 +178,7 @@ class RecalculateSubsectionGradeTest(ModuleStoreTestCase): with self.store.default_store(default_store): self.set_up_course(enable_subsection_grades=False) self.assertFalse(PersistentGradesEnabledFlag.feature_enabled(self.course.id)) - with check_mongo_calls(2) and self.assertNumQueries(2): + with check_mongo_calls(2) and self.assertNumQueries(0): recalculate_subsection_grade.apply(args=tuple(self.score_changed_kwargs.values())) @skip("Pending completion of TNL-5089")