i'm designing a moodle for company to provide courses for their employees and they ask me to make course that allow the users to ask for enrollment and the teacher will accept or no and they also have to see the number of seats available.
so what i did is installed the "selfenrol_seats" plugin in order to allow the users to see how many seats available and then installed "Enrolment upon Approval" plugin to allow the users to ask for enrollment.
But the "selfenrol_seats" plugin wont be shown until i activate the "self-enrolment", and that will allow the users to enroll without approval from the teacher.
so i came to the only scenario to sort this issue out..... activate the both plugin and add enrolment key for the "self-enrolment", and the the user will apply for the course through the "Enrolment upon Approval" and when the teacher confirm the request an email will be sent to the user with the conformation and the the enrolment key.
so i modified the lib.php to be like this :
and also :
return $DB->get_record_sql('select u.*,c.fullname as coursename,e.password as enrolkey from '.$CFG->prefix.'user_enrolments as ue left join '.$CFG->prefix.'user as u on ue.userid=u.id left join '.$CFG->prefix.'enrol as e on ue.enrolid=e.id left
join '.$CFG->prefix.'course as c on e.courseid=c.id where ue.id='.$enrolid);
everything as should to be but the enrolment key is being taken from the apply row in enrol table (which is null) and the enrolment key in the self row with the same course id
is there any idea or query that will retrieve the information needed as above plus the enrolment key from that row ??? i would really appropriated