I'm trying to use a single Moodle for different schools and the students to be automatically enrolled to a course in moodle based on custom profile fields selected at the time of registration itself.
The auto enrollment can't be done by LDAP as we don't have the student information beforehand. The teacher,course information are available and upon uploading it we have the courses ready.
I have a DB which has school,teacher_name,course_name,group_name,group_key. The course_name is the same as the courses in moodle.
I have added custom dropdown fields of School, teacher, course_name and group on the registration page. But I want the teacher field to be populated based on the School selected and Course based on the teacher.etc for which I might have to embed Javascript. I have looked at the document for Javascript documentation. But I don't know how to get the data of one profile field from the Moodle's DB upon selection of another profile field in JavaScript. Is there any WebService I could use? And also my idea was to to write a trigger in the DB as soon as a new record is added in the mdl_user to get the courseId based on the custom fields and the UserId and write the SQL to create records to enroll the users in that particular course and group. But I found in some forum posts that its bad programming and its better to do it by using the events API which I've had a look at but found it hard to understand. (I have looked at plugins to enroll users based on custom profile fields. But I have a large number of courses and classes and setting them all up manually would be hard). I'm very new to Moodle and core. Just started working on it 2 weeks ago. So could anyone please guild me regarding the files I should add/change and what is the best way this could be done.
*** This work needs to be done urgently and so open to paid freelancers too ***