From caeac6921a4f5c6ff2eaa4cb07278e5cbba45f63 Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Tue, 1 Nov 2016 12:43:50 -0400 Subject: [PATCH] Fast-fail grades tasks if feature flag disabled --- lms/djangoapps/grades/tasks.py | 3 +++ lms/djangoapps/grades/tests/test_tasks.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lms/djangoapps/grades/tasks.py b/lms/djangoapps/grades/tasks.py index f65815389f..66a223a97b 100644 --- a/lms/djangoapps/grades/tasks.py +++ b/lms/djangoapps/grades/tasks.py @@ -13,6 +13,7 @@ from opaque_keys.edx.locator import CourseLocator from openedx.core.djangoapps.content.block_structure.api import get_course_in_cache from xmodule.modulestore.django import modulestore +from .config.models import PersistentGradesEnabledFlag from .new.course_grade import CourseGradeFactory from .new.subsection_grade import SubsectionGradeFactory from .signals.signals import SUBSECTION_SCORE_CHANGED @@ -76,6 +77,8 @@ def recalculate_course_grade(user_id, course_id): - user_id: serialized id of applicable User object - course_id: Unicode string representing the course """ + if not PersistentGradesEnabledFlag.feature_enabled(course_id): + return student = User.objects.get(id=user_id) course_key = CourseLocator.from_string(course_id) course = modulestore().get_course(course_key, depth=0) diff --git a/lms/djangoapps/grades/tests/test_tasks.py b/lms/djangoapps/grades/tests/test_tasks.py index 959d1c1ff5..74d0a34097 100644 --- a/lms/djangoapps/grades/tests/test_tasks.py +++ b/lms/djangoapps/grades/tests/test_tasks.py @@ -179,7 +179,7 @@ class RecalculateSubsectionGradeTest(ModuleStoreTestCase): self.set_up_course(enable_subsection_grades=False) self.assertFalse(PersistentGradesEnabledFlag.feature_enabled(self.course.id)) additional_queries = 1 if default_store == ModuleStoreEnum.Type.mongo else 0 - with check_mongo_calls(2) and self.assertNumQueries(16 + additional_queries): + with check_mongo_calls(2) and self.assertNumQueries(5): recalculate_subsection_grade.apply(args=tuple(self.score_changed_kwargs.values())) @skip("Pending completion of TNL-5089")