def is_last_random_cohort(user_group):
 random_cohorts = CourseUserGroup.objects.filter(course_id=user_group.course_id, group_type=CourseUserGroup.COHORT, cohort__assignment_type=CourseCohort.RANDOM)
 return ((len(random_cohorts) == 1) and (random_cohorts[0].name == user_group.name))

def is_last_random_cohort ( user_group ) : random_cohorts = CourseUserGroup . objects . filter ( course_id = user_group . course_id , group_type = CourseUserGroup . COHORT , cohort__assignment_type = CourseCohort . RANDOM ) return ( ( len ( random_cohorts ) == 1 ) and ( random_cohorts [ 0 ] . name == user_group . name ) )
check if this cohort is the only random cohort in the course .