Implement start and end date to enrolment upon approval

Implement start and end date to enrolment upon approval

על ידי Daniel Rodrigo בתאריך
מספר תגובות: 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
ממוצע דרוגים: -
בתגובה ל: 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...
בתגובה ל: 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.