diff --git a/lms/djangoapps/courseware/user_state_client.py b/lms/djangoapps/courseware/user_state_client.py index b893200c21d1..b85f20175ce8 100644 --- a/lms/djangoapps/courseware/user_state_client.py +++ b/lms/djangoapps/courseware/user_state_client.py @@ -600,7 +600,7 @@ def iter_all_for_block(self, block_key, scope=Scope.user_state): if scope != Scope.user_state: raise ValueError("Only Scope.user_state is supported") - results = StudentModule.objects.order_by('id').filter(module_state_key=block_key) + results = StudentModule.objects.order_by('id').filter(module_state_key=block_key).select_related('student') p = Paginator(results, settings.USER_STATE_BATCH_SIZE) for page_number in p.page_range: diff --git a/lms/djangoapps/instructor_analytics/basic.py b/lms/djangoapps/instructor_analytics/basic.py index afce0620aab0..c7bc6ca6da4c 100644 --- a/lms/djangoapps/instructor_analytics/basic.py +++ b/lms/djangoapps/instructor_analytics/basic.py @@ -349,7 +349,7 @@ def list_problem_responses(course_key, problem_location, limit_responses=None): smdat = StudentModule.objects.filter( course_id=course_key, module_state_key=problem_key - ) + ).select_related('student') smdat = smdat.order_by('student') if limit_responses is not None: smdat = smdat[:limit_responses]