How to export the names of Cohorts Moodle29

Re: How to export the names of Cohorts Moodle29

by Colin Fraser -
Number of replies: 0
Picture of Documentation writers Picture of Testers

Export the Cohorts? To do what precisely?  Export as backups? Export as csv files? 

You have a couple of choices, you can use Moodle Adminer, or phpMyAdmin (if using MySQL or Mariadb) or phpPostAdmin (if using PostGraSQL) or other tools if using MSSQL or Oracle.  Goi into the database and extract the data directly, with a SQL SELECT statement. You will need to use the mdl_cohort table, to extract the cohort id and name of the cohort, mdl_cohort_members table to match the cohort id number and the user_id as a member of the cohort, and  act as a foriegn key to link with the mdl_users table, to match the user_id, then extract the name of the student. I would place the whole thing in a FOR loop, to sort through the mdl_cohort table.  The only issue from there would be how you want the data presented. 

Don't take my word for this, my SQL is likely quite rusty, but this is the sort of thing I would probably do.