Implement start and end date to enrolment upon approval

Implement start and end date to enrolment upon approval

Daniel Rodrigo發表於
Number of replies: 3

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);

附件 image 1.png
評比平均分數: -
In reply to Daniel Rodrigo

Re: Implement start and end date to enrolment upon approval

Emma Richardson發表於
Documentation writers的相片 Particularly helpful Moodlers的相片 Plugin developers的相片
This would probably be better in the developer forum but before I move it over there, I am confused by what you are wanting these dates to do - are you expecting the dates to provide a timeframe when people can use the enrollment method or are you trying to set the dates that student is enrolled in the class? Everything you are referencing would be related to the dates the student is enrolled, not when the plugin allows enrollment - is that what you are trying achieve? If so, you might just search the whole plugin for startdate - I am guessing you are missing the part where the plugin actually puts the enrolment start date in the databse...
In reply to Emma Richardson

Re: Implement start and end date to enrolment upon approval

Daniel Rodrigo發表於

are you expecting the dates to provide a timeframe when people can use the enrollment method

Yes, that is what i mean. I want to implement the same functionality that self enrol has, for example - where i can set a timeframe where the enrolment method "enrolment upon approval" is available. After the end date has passed, all the students that have enrolled with the enrolment upon approval method should stay enrolled.

In reply to Daniel Rodrigo

Re: Implement start and end date to enrolment upon approval

Emma Richardson發表於
Documentation writers的相片 Particularly helpful Moodlers的相片 Plugin developers的相片
Ok, the clarification helps. I am going to move this over to the developers forum as I think you will find more help there.