diff --git a/lms/djangoapps/instructor_task/api.py b/lms/djangoapps/instructor_task/api.py index 99f2b7b4b9fb8702c5840fdcd8bb33c6b8fb3145..da8c284b9797b58f251d619d9741291aa7d3bdc7 100644 --- a/lms/djangoapps/instructor_task/api.py +++ b/lms/djangoapps/instructor_task/api.py @@ -330,7 +330,7 @@ def submit_calculate_problem_responses_csv(request, course_key, problem_location """ task_type = 'problem_responses_csv' task_class = calculate_problem_responses_csv - task_input = {'problem_location': problem_location} + task_input = {'problem_location': problem_location, 'user_id': request.user.pk} task_key = "" return submit_task(request, task_type, task_class, course_key, task_input, task_key) diff --git a/lms/djangoapps/instructor_task/tasks_helper/grades.py b/lms/djangoapps/instructor_task/tasks_helper/grades.py index 42e9e47e22d4849488889262cbcbb065d90152d1..e3979c6cde39fc43fbf0210fe539b534db35d099 100644 --- a/lms/djangoapps/instructor_task/tasks_helper/grades.py +++ b/lms/djangoapps/instructor_task/tasks_helper/grades.py @@ -8,10 +8,14 @@ from datetime import datetime from itertools import chain, izip, izip_longest from time import time +from django.contrib.auth import get_user_model +from django.conf import settings from lazy import lazy +from opaque_keys.edx.keys import UsageKey from pytz import UTC from six import text_type +from course_blocks.api import get_course_blocks from courseware.courses import get_course_by_id from instructor_analytics.basic import list_problem_responses from instructor_analytics.csvs import format_dictlist @@ -563,7 +567,23 @@ class ProblemResponses(object): # Compute result table and format it problem_location = task_input.get('problem_location') - student_data = list_problem_responses(course_id, problem_location) + problem_key = UsageKey.from_string(problem_location) + + user_id = task_input.get('user_id') + user = get_user_model().objects.get(pk=user_id) + course_blocks = get_course_blocks(user, problem_key) + + student_data = [] + max_count = settings.FEATURES.get('MAX_PROBLEM_RESPONSES_COUNT') + + for block in course_blocks: + if block.block_type == 'problem': + problem_responses = list_problem_responses(course_id, block, max_count) + student_data += problem_responses + max_count -= len(problem_responses) + if max_count <= 0: + break + features = ['username', 'state'] header, rows = format_dictlist(student_data, features) diff --git a/lms/envs/common.py b/lms/envs/common.py index 7dd42d762c5d4b22a5f46394ff8a0f88c59e93aa..f456bb7ca8ed49ae666b32970d6de77f047c2bd6 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -206,6 +206,9 @@ FEATURES = { # Automatically approve student identity verification attempts 'AUTOMATIC_VERIFY_STUDENT_IDENTITY_FOR_TESTING': False, + # Maximum number of rows to include in the csv file for downloading problem responses. + 'MAX_PROBLEM_RESPONSES_COUNT': 5000, + # whether to use password policy enforcement or not 'ENFORCE_PASSWORD_POLICY': True,