View Courses Your Students are Enrolled in Moodle

How to View Courses Your Students are Enrolled in

So you’ve set up your Moodle site and your courses are running smoothly.

Things couldn’t have been any better!

However, for some reason, you want to view a list of your students, and also view courses these students are enrolled in. You might want to export this data to another system, or it could purely be for backup purposes.

That’s exactly what happened with one of the members in our Facebook Community “Moodle Tips & Tricks“! He wanted to have a look at the names of his students along with the ability to view courses they’ve enrolled in.

So, after a discussion with our development team, we came up with a SQL query string for the same.

Developer Corner

You can use the following SQL query:

SELECT CONCAT(u.firstname, ‘ ‘, u.lastname), GROUP_CONCAT(c.fullname) Course
FROM mdl_user u
JOIN mdl_role_assignments ra ON = ra.userid
JOIN mdl_role r ON ra.roleid =
JOIN mdl_context ctx ON ra.contextid = AND ctx.contextlevel = 50
JOIN mdl_course c ON ctx.instanceid =
WHERE r.archetype = ‘student’

Using this query, you’ll be able to view full-names of your students. This query will also let you view courses these students are enrolled in.

Is there something you need help with? You can let us know at [email protected] 🙂

Moodle Tips & Tricks - Powered by Edwiser

Leave a Comment

Your email address will not be published. Required fields are marked *

Choose your currency:

Converted prices are for reference only - all orders are charged in $ US Dollars ($) USD.
  • USDUS Dollars ($)
  • INRIndian Rupee (₹)

Spin & Win Giveaway!

Spin-the-wheel Giveaway details:

  1. Sign up & spin the wheel to get discounts up to 70%
  2. Lucky winners also get a chance to win 100% OFF
  3. Please provide a valid email id since the coupon will be shared with you only via email
  4. Coupon code can be used at checkout and is valid only for 24Hrs

Sign up to Spin the Wheel

Spin the Wheel
By joining this giveaway, you would give us your consent to occasionally send you emails about products and strategies that would benefit your Moodle LMS.