Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Cohorts & Audiences audiences are commonly used to enrol users in courses, via the Cohortcohort/Audience audience sync enrolment method. To identify the Cohorts/Audiences that have been used to enrol learners in course you can use the following query to create a derived table. 

...

Code Block
languagesql
titleCohort/Audience Enrolments
selectSELECT c.id as cohortid, cm.userid as userid, e.courseid as courseid, c.name as cohort
FROM mdl_cohort c
INNER JOIN mdl_cohort_members cm ON (cm.cohortid = c.id)
INNER JOIN mdl_enrol e ON (e.customint1 = c.id)


This derived table should be joined to the mdl_course and mdl_user tables to pull in the actual course/user information. This can be done with an INNER JOIN (see below) to only show courses that have users enrolled via cohorts or audiences.

Image Added