List Users that are not in a course

List Users that are not in a course

by Michael B -
Number of replies: 2
Good morning,

is there a way to list all users that are not in a course? I don't think this can be done from the admin gui but rather would be an SQL statement. Am I correct with that?

Would appreciate it someone could maybe write the SQL statement as I'm not realy up2date with the moodle db and what I would have to join to get the correct answer.

Thanks for your time,

Michael
Average of ratings: -
In reply to Michael B

Re: List Users that are not in a course

by Helson C -

$DB->get_records_sql('SELECT * FROM {user} u WHERE u.id NOT IN (SELECT userid FROM {useR_enrolments}))


You can try it.

Remember to remove admin or other user that you don't need, like admin, guest.


Cheers.

In reply to Michael B

Re: List Users that are not in a course

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers

Please visit MDL-19190 and see if it reflects what you want to be able to do.  If so, please vote for it.