@require_POST
@login_required
def submit_answers(request, survey_name):
 survey = SurveyForm.get(survey_name, throw_if_not_found=False)
 if (not survey):
  return HttpResponseNotFound()
 answers = {}
 for key in request.POST.keys():
  array_val = request.POST.getlist(key)
  answers[key] = (request.POST[key] if (len(array_val) == 0) else ','.join(array_val))
 redirect_url = (answers['_redirect_url'] if ('_redirect_url' in answers) else reverse('dashboard'))
 course_key = (CourseKey.from_string(answers['course_id']) if ('course_id' in answers) else None)
 allowed_field_names = survey.get_field_names()
 filtered_answers = {}
 for answer_key in answers.keys():
  if (answer_key in allowed_field_names):
   filtered_answers[answer_key] = escape(answers[answer_key])
 survey.save_user_answers(request.user, filtered_answers, course_key)
 response_params = json.dumps({'redirect_url': redirect_url})
 return HttpResponse(response_params, content_type='text/json')

@ require_POST @ login_required def submit_answers ( request , survey_name ) : survey = SurveyForm . get ( survey_name , throw_if_not_found = False ) if ( not survey ) : return HttpResponseNotFound ( ) answers = { } for key in request . POST . keys ( ) : array_val = request . POST . getlist ( key ) answers [ key ] = ( request . POST [ key ] if ( len ( array_val ) == 0 ) else ',' . join ( array_val ) ) redirect_url = ( answers [ '_redirect_url' ] if ( '_redirect_url' in answers ) else reverse ( 'dashboard' ) ) course_key = ( CourseKey . from_string ( answers [ 'course_id' ] ) if ( 'course_id' in answers ) else None ) allowed_field_names = survey . get_field_names ( ) filtered_answers = { } for answer_key in answers . keys ( ) : if ( answer_key in allowed_field_names ) : filtered_answers [ answer_key ] = escape ( answers [ answer_key ] ) survey . save_user_answers ( request . user , filtered_answers , course_key ) response_params = json . dumps ( { 'redirect_url' : redirect_url } ) return HttpResponse ( response_params , content_type = 'text/json' )
form submission post-back endpoint .