Hi folks!
I am trying to implement a custom start and end date configuration to the "Enrolment upon approval" plugin, but i don't have experience with coding Moodle plugins, so i would like some guidance as how i could implement this feature.
I have been able to make the start and end date selector appear in the "Edit" section (see image) in the enrolment options of the course, but the date does not work as intented, that is, even if the current day is after the end date, the student can apply to the course using the enrolment upon approval option.
Here's how i did it:
In the file /enrol/apply/edit_form.php i inserted the lines
$mform->addElement('date_time_selector', 'enrolstartdate', get_string('enrolstartdate', 'enrol_self'), array('optional' => true));
$mform->setDefault('enrolstartdate', 0);
$mform->addElement('date_time_selector', 'enrolenddate', get_string('enrolenddate', 'enrol_self'), array('optional' => true));
$mform->setDefault('enrolenddate', 0);
to make the date selector appear in the edit options, then in /enrol/apply/edit.php , under the else if($date = $mform->get_data()) block, i've added:
$instance->enrolstartdate = $data->enrolstartdate;
$instance->enrolenddate = $data->enrolenddate;
and then, in the same file, a little later:
'enrolstartdate' => $data->enrolstartdate,
'enrolenddate' => $data->enrolenddate);