Selected users for external database enrollment

Selected users for external database enrollment

by Bernie Rey Barsomo -
Number of replies: 5
Hi! I just want to ask if its possible to only enroll into moodle those users who possess specific criteria? For example:

Users
NAME AGE GENDER
Dan 21 Male
Jona 23 Female
 Sam  18 Female 

The criteria is gender and I am only to enroll users that are female. How do I do that?

Big thanks!





Average of ratings: -
In reply to Bernie Rey Barsomo

Re: Selected users for external database enrollment

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

When you say enroll - do you mean into a course?  

https://moodle.org/plugins/enrol_attributes

In reply to Emma Richardson

Re: Selected users for external database enrollment

by Bernie Rey Barsomo -
Hi Emma! Thanks for your response. Sorry for the confusion. I meant External Database Authentication smile
In reply to Bernie Rey Barsomo

Re: Selected users for external database enrollment

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

So to be clear: authentication is providing access to the site using an external source, enrolment is adding users into courses using an external source.

If you only want a subset of the users table to be able to access the site you'll need to create a database view in that only returns the subset and specify that view in the Table field in the External Database authentication plugin settings.

For example if the external database was MySQL the view could be created with:

CREATE VIEW users_female AS SELECT name, ... FROM users WHERE gender = 'Female';
Average of ratings: Useful (2)
In reply to Leon Stringer

Re: Selected users for external database enrollment

by Mathew Gancarz -
Picture of Core developers
Seconding this recommendation, this has worked very well for us for years. Just be careful with tweaking the view parameters since it will unenroll students that are removed from the view.
Average of ratings: Useful (1)
In reply to Leon Stringer

Re: Selected users for external database enrollment

by Bernie Rey Barsomo -
Hi Leon! I will definitely try try that. Thank you all the way from the Philippines!