Cohorts and Content Groups

Where are Cohorts and Content Groups Stored?

Content Groups

Content Groups are a type of UserPartition, and they are defined in a UserPartitionList that is stored on the course module itself (in mongo) via the InheritanceMixin in

# This is should be scoped to content, but since it's defined in the policy
# file, it is currently scoped to settings.
user_partitions = UserPartitionList(
display_name=_("Group Configurations"),
help=_("Enter the configurations that govern how students are grouped together."),

Each UserPartition has a scheme associated with it; the currently defined schemes are "cohort" (for content groups) and "random" (for A/B tests).

Also defined in the InheritanceMixin is group_access, which specifies which UserPartition/group combinations have visibility to the XBlock. The keys are UserPartition ids, and the values are lists of Group ids.

group_access = Dict(
help=_("Enter the ids for the content groups this problem belongs to."),

In practice, group_access looks like

{ [partition.groups[0].id, partition.groups[2].id]}


There is a legacy cohort_config dict defined in CourseFields (see below), which is used for migration only to the new model representation.

cohort_config = Dict(
display_name=_("Cohort Configuration"),
"Enter policy keys and values to enable the cohort feature, define automated student assignment to "
"groups, or identify any course-wide discussion topics as private to cohort members."

The package openedx/course/djangoapps/course_groups contains the majority of the cohort code. The class contains the following SQL models:


The new class-specific cohort configuration model.


The model representing groups of users in a course. The only defined group type is "cohort".


An internal model used to enforce that a learner can be in only one cohort per course.


The model that maps together the linking between a single CourseUserGroup and a single UserPartition/group_id combination. In other words, this model stores the linking of a cohort to a single content group.


A model that stores information about a specific CourseUserGroup. All it currently stores is the assignment type, which is either "random" or "manual".


This is not a model, but instead the scheme that uses CourseUserGroup/CohortMembership and CourseUserGroupPartitionGroup to map learners into content groups. It implements a single method, get_group_for_user, which does roughly the following:

  1. Checks masquerading to see if the learner is really a staff member masquerading as a member of a content group. If so, returns that value.
  2. Gets the cohort assignment for the user/course key combination (CohortMembership).
  3. Gets the UserPartition/group_id combination associated with that cohort (CourseUserGroupPartitionGroup).
  4. Returns the group associated with the UserPartition/group_id combination.

Automatic Cohorting of Verified Track Learners

The code for this lives in lms/djangoapps/verified_track_content. This includes the admin configuration model, VerifiedTrackCohortedCourse, and the celery task that moves learners into the correct cohort upon enrollment changes. The celery task is kicked off from a post_save signal from the CourseEnrollment model (which is defined in common/djangoapps/student/


Current Documentation and Best Practices

Proposed Features

  1. Automatic track-based cohorting – Project Page /wiki/spaces/EDUCATOR/pages/120881208
  2. Content Differentiation for Enterprise Learners

Older Architecture Diagrams and Proposals

Older Project Pages