def _get_entrance_exam(request, course_key):
 course = modulestore().get_course(course_key)
 if (course is None):
  return HttpResponse(status=400)
 if (not course.entrance_exam_id):
  return HttpResponse(status=404)
 try:
  exam_key = UsageKey.from_string(course.entrance_exam_id)
 except InvalidKeyError:
  return HttpResponse(status=404)
 try:
  exam_descriptor = modulestore().get_item(exam_key)
  return HttpResponse(dump_js_escaped_json({'locator': unicode(exam_descriptor.location)}), status=200, content_type='application/json')
 except ItemNotFoundError:
  return HttpResponse(status=404)

def _get_entrance_exam ( request , course_key ) : course = modulestore ( ) . get_course ( course_key ) if ( course is None ) : return HttpResponse ( status = 400 ) if ( not course . entrance_exam_id ) : return HttpResponse ( status = 404 ) try : exam_key = UsageKey . from_string ( course . entrance_exam_id ) except InvalidKeyError : return HttpResponse ( status = 404 ) try : exam_descriptor = modulestore ( ) . get_item ( exam_key ) return HttpResponse ( dump_js_escaped_json ( { 'locator' : unicode ( exam_descriptor . location ) } ) , status = 200 , content_type = 'application/json' ) except ItemNotFoundError : return HttpResponse ( status = 404 )
internal workflow operation to retrieve an entrance exam .