def get_random_cohort(course_key):
 course = courses.get_course(course_key)
 cohorts = get_course_cohorts(course, assignment_type=CourseCohort.RANDOM)
 if cohorts:
  cohort = local_random().choice(cohorts)
 else:
  cohort = CourseCohort.create(cohort_name=DEFAULT_COHORT_NAME, course_id=course_key, assignment_type=CourseCohort.RANDOM).course_user_group
 return cohort

def get_random_cohort ( course_key ) : course = courses . get_course ( course_key ) cohorts = get_course_cohorts ( course , assignment_type = CourseCohort . RANDOM ) if cohorts : cohort = local_random ( ) . choice ( cohorts ) else : cohort = CourseCohort . create ( cohort_name = DEFAULT_COHORT_NAME , course_id = course_key , assignment_type = CourseCohort . RANDOM ) . course_user_group return cohort
helper method to get a cohort for random assignment .