Search code examples
moodle

Moodle Student list with Groups and Course


I am using moodle2.4.6. I want a list of user with their groups and their courses.


Solution

  • You will need to do an SQL query to get this information.

    Assuming you are using the default 'mdl_' prefix for tables, you will need to join together the following tables:

    • mdl_user - the details of the users
    • mdl_user_enrolments - (user_enrolments.userid = user.id) which course enrolments the user has
    • mdl_enrol - (enrol.id = user_enrolments.enrolid) details of which enrolment instances these are
    • mdl_course - (course.id = enrol.courseid) details of the courses these users are enroled in
    • mdl_groups_members - (groups_members.userid = user.id) details of the groups these users are in
    • mdl_groups - (groups.id = groups_members.groupid AND groups.courseid = course.id) name and description of the groups the user is in (for each course)

    Please comment if you need help turning that pseudo code into actual SQL, or if you need help with the Moodle database access API ( http://docs.moodle.org/dev/Data_manipulation_API )