@transaction.non_atomic_requests
@require_POST
@ensure_csrf_cookie
@cache_control(no_cache=True, no_store=True, must_revalidate=True)
@require_level('staff')
def get_problem_responses(request, course_id):
 course_key = CourseKey.from_string(course_id)
 problem_location = request.POST.get('problem_location', '')
 try:
  problem_key = UsageKey.from_string(problem_location)
  run = problem_key.run
  if (not run):
   problem_key = course_key.make_usage_key_from_deprecated_string(problem_location)
  if (problem_key.course_key != course_key):
   raise InvalidKeyError(type(problem_key), problem_key)
 except InvalidKeyError:
  return JsonResponseBadRequest(_('Could not find problem with this location.'))
 try:
  lms.djangoapps.instructor_task.api.submit_calculate_problem_responses_csv(request, course_key, problem_location)
  success_status = _('The problem responses report is being created. To view the status of the report, see Pending Tasks below.')
  return JsonResponse({'status': success_status})
 except AlreadyRunningError:
  already_running_status = _("A problem responses report generation task is already in progress. Check the 'Pending Tasks' table for the status of the task. When completed, the report will be available for download in the table below.")
  return JsonResponse({'status': already_running_status})

@ transaction . non_atomic_requests @ require_POST @ ensure_csrf_cookie @ cache_control ( no_cache = True , no_store = True , must_revalidate = True ) @ require_level ( 'staff' ) def get_problem_responses ( request , course_id ) : course_key = CourseKey . from_string ( course_id ) problem_location = request . POST . get ( 'problem_location' , '' ) try : problem_key = UsageKey . from_string ( problem_location ) run = problem_key . run if ( not run ) : problem_key = course_key . make_usage_key_from_deprecated_string ( problem_location ) if ( problem_key . course_key != course_key ) : raise InvalidKeyError ( type ( problem_key ) , problem_key ) except InvalidKeyError : return JsonResponseBadRequest ( _ ( 'Could not find problem with this location.' ) ) try : lms . djangoapps . instructor_task . api . submit_calculate_problem_responses_csv ( request , course_key , problem_location ) success_status = _ ( 'The problem responses report is being created. To view the status of the report, see Pending Tasks below.' ) return JsonResponse ( { 'status' : success_status } ) except AlreadyRunningError : already_running_status = _ ( "A problem responses report generation task is already in progress. Check the 'Pending Tasks' table for the status of the task. When completed, the report will be available for download in the table below." ) return JsonResponse ( { 'status' : already_running_status } )
initiate generation of a csv file containing all student answers to a given problem .