diff --git a/lms/djangoapps/grades/tasks.py b/lms/djangoapps/grades/tasks.py index 3c18d66e9f..f3bd35fe5e 100644 --- a/lms/djangoapps/grades/tasks.py +++ b/lms/djangoapps/grades/tasks.py @@ -140,7 +140,7 @@ def recalculate_course_and_subsection_grades_for_user(self, **kwargs): # pylint course_key = CourseKey.from_string(course_key_str) # Hotfix to address LEARNER-5123, to be removed later - visible_blocks_count = VisibleBlocks.objects.filter(course_id=course_key) + visible_blocks_count = VisibleBlocks.objects.filter(course_id=course_key).count() if visible_blocks_count > MAX_VISIBLE_BLOCKS_ALLOWED: message = '{} has too many VisibleBlocks to recalculate grades for {}' raise Exception(message.format(course_key_str, user_id)) diff --git a/lms/djangoapps/grades/tests/test_tasks.py b/lms/djangoapps/grades/tests/test_tasks.py index b859b14a40..109a119a60 100644 --- a/lms/djangoapps/grades/tests/test_tasks.py +++ b/lms/djangoapps/grades/tests/test_tasks.py @@ -486,7 +486,7 @@ class RecalculateGradesForUserTest(HasCourseWithProblemsMixin, ModuleStoreTestCa self.set_up_course() CourseEnrollment.enroll(self.user, self.course.id) self.original_max_visible_blocks_allowed = tasks.MAX_VISIBLE_BLOCKS_ALLOWED - tasks.MAX_VISIBLE_BLOCKS_ALLOWED = 1 + tasks.MAX_VISIBLE_BLOCKS_ALLOWED = -1 def tearDown(self): super(RecalculateGradesForUserTest, self).tearDown()