Get Cohort Sync Courses

Get Cohort Sync Courses

by Clarissa S -
Number of replies: 1

Hi!

Moodle 3.1

I hope this is the right place for this question!

I was looking for a programmatic way to get the courses that a cohort has been synced to.  I can get every individual's courses, but I was needing to be able to get only those specific courses relating to that cohort and not *every* course that the user has taken.  Any ideas?

Thanks so much!


Average of ratings: -
In reply to Clarissa S

Re: Get Cohort Sync Courses

by Clarissa S -

For anyone else looking for this, I found a way to at least see which courses have the cohort enrolled (and then I can just iterate through the courses and look for the cohort):

$context = context_course::instance(<whatever_course_id>);

$cohorts = cohort_get_available_cohorts($context, COHORT_WITH_ENROLLED_MEMBERS_ONLY);


Average of ratings: Useful (1)