@ensure_csrf_cookie
def users_in_cohort(request, course_key_string, cohort_id):
 course_key = SlashSeparatedCourseKey.from_deprecated_string(course_key_string)
 get_course_with_access(request.user, 'staff', course_key)
 cohort = cohorts.get_cohort_by_id(course_key, int(cohort_id))
 paginator = Paginator(cohort.users.all(), 100)
 try:
  page = int(request.GET.get('page'))
 except (TypeError, ValueError):
  return HttpResponseBadRequest('Requested page must be numeric')
 else:
  if (page < 0):
   return HttpResponseBadRequest('Requested page must be greater than zero')
 try:
  users = paginator.page(page)
 except EmptyPage:
  users = []
 user_info = [{'username': u.username, 'email': u.email, 'name': '{0} {1}'.format(u.first_name, u.last_name)} for u in users]
 return json_http_response({'success': True, 'page': page, 'num_pages': paginator.num_pages, 'users': user_info})

@ ensure_csrf_cookie def users_in_cohort ( request , course_key_string , cohort_id ) : course_key = SlashSeparatedCourseKey . from_deprecated_string ( course_key_string ) get_course_with_access ( request . user , 'staff' , course_key ) cohort = cohorts . get_cohort_by_id ( course_key , int ( cohort_id ) ) paginator = Paginator ( cohort . users . all ( ) , 100 ) try : page = int ( request . GET . get ( 'page' ) ) except ( TypeError , ValueError ) : return HttpResponseBadRequest ( 'Requested page must be numeric' ) else : if ( page < 0 ) : return HttpResponseBadRequest ( 'Requested page must be greater than zero' ) try : users = paginator . page ( page ) except EmptyPage : users = [ ] user_info = [ { 'username' : u . username , 'email' : u . email , 'name' : '{0} {1}' . format ( u . first_name , u . last_name ) } for u in users ] return json_http_response ( { 'success' : True , 'page' : page , 'num_pages' : paginator . num_pages , 'users' : user_info } )
return users in the cohort .