wp2moodle--wordpress- icon indicating copy to clipboard operation
wp2moodle--wordpress- copied to clipboard

Default enrolment period

Open miguelurtado opened this issue 8 years ago • 3 comments

Hello, thanks for great work.

I like configure Default enrolment period. It is possible?

Thanks

miguelurtado avatar Jul 29 '16 04:07 miguelurtado

Hi sorry it's taken a while to get back here - I've been moving house.

When using a courseid or groupid, the user gets enrolled into the course using the first instance of the manual enrolment plugin on the course, so perhaps you could configure that instance to have a default enrol period. Cohort enrolment doesn't have and enrolment period option afaik.

frumbert avatar Aug 10 '16 21:08 frumbert

Hello,

I configure the instance, but not work.

To work I add this custom code in login.php after line 136.

$courseId = 0; // cache

//// Extras Variables ////

$courserow = $DB->get_record('course', array('idnumber'=>$course_idnumbers));
$courseId = $courserow->id;
$enrolid = $DB->get_record('enrol', array('courseid'=>$courseId, 'enrol'=>'manual'));
$extendperiod = $enrolid->enrolperiod;

$now = time();
$today = make_timestamp(date('Y', $now), date('m', $now), date('d', $now), date('H', $now), date('i', $now), date('s', $now));

$timestart = $today;
$timeend = $timestart + $extendperiod;

//// End Custom ////

And change this code:

from if (!enrol_try_internal_enrol($courserow->id, $user->id, $studentrow->id)) {

to

if (!enrol_try_internal_enrol($courserow->id, $user->id, $studentrow->id, $timestart, $timeend)) {

Thanks

miguelurtado avatar Aug 17 '16 00:08 miguelurtado

Oh right - that looks like a good idea. I'll see if I can put the support in, or get it to inherit those values from the enrolment instance (which I thought it did do - evidently not any more).

frumbert avatar Aug 17 '16 01:08 frumbert