@login_required
@ensure_csrf_cookie
@check_feature_enabled(feature_name='ENTRANCE_EXAMS')
def entrance_exam(request, course_key_string):
 course_key = CourseKey.from_string(course_key_string)
 if (not has_course_author_access(request.user, course_key)):
  return HttpResponse(status=403)
 if (request.method == 'GET'):
  return _get_entrance_exam(request, course_key)
 elif (request.method == 'POST'):
  response_format = request.POST.get('format', 'html')
  http_accept = request.META.get('http_accept')
  if ((response_format == 'json') or ('application/json' in http_accept)):
   ee_min_score = request.POST.get('entrance_exam_minimum_score_pct', None)
   entrance_exam_minimum_score_pct = _get_default_entrance_exam_minimum_pct()
   if ((ee_min_score != '') and (ee_min_score is not None)):
    entrance_exam_minimum_score_pct = float(ee_min_score)
   return create_entrance_exam(request, course_key, entrance_exam_minimum_score_pct)
  return HttpResponse(status=400)
 elif (request.method == 'DELETE'):
  return delete_entrance_exam(request, course_key)
 else:
  return HttpResponse(status=405)

@ login_required @ ensure_csrf_cookie @ check_feature_enabled ( feature_name = 'ENTRANCE_EXAMS' ) def entrance_exam ( request , course_key_string ) : course_key = CourseKey . from_string ( course_key_string ) if ( not has_course_author_access ( request . user , course_key ) ) : return HttpResponse ( status = 403 ) if ( request . method == 'GET' ) : return _get_entrance_exam ( request , course_key ) elif ( request . method == 'POST' ) : response_format = request . POST . get ( 'format' , 'html' ) http_accept = request . META . get ( 'http_accept' ) if ( ( response_format == 'json' ) or ( 'application/json' in http_accept ) ) : ee_min_score = request . POST . get ( 'entrance_exam_minimum_score_pct' , None ) entrance_exam_minimum_score_pct = _get_default_entrance_exam_minimum_pct ( ) if ( ( ee_min_score != '' ) and ( ee_min_score is not None ) ) : entrance_exam_minimum_score_pct = float ( ee_min_score ) return create_entrance_exam ( request , course_key , entrance_exam_minimum_score_pct ) return HttpResponse ( status = 400 ) elif ( request . method == 'DELETE' ) : return delete_entrance_exam ( request , course_key ) else : return HttpResponse ( status = 405 )
the restful handler for entrance exams .