diff --git a/enrol/manual/ajax.php b/enrol/manual/ajax.php index 94ccd7b11f0..ad454c47a4c 100644 --- a/enrol/manual/ajax.php +++ b/enrol/manual/ajax.php @@ -120,7 +120,7 @@ switch ($action) { } $roleid = optional_param('role', null, PARAM_INT); - $duration = optional_param('duration', 0, PARAM_INT); + $duration = optional_param('duration', 0, PARAM_FLOAT); $startdate = optional_param('startdate', 0, PARAM_INT); $recovergrades = optional_param('recovergrades', 0, PARAM_INT); @@ -154,7 +154,7 @@ switch ($action) { if ($duration <= 0) { $timeend = 0; } else { - $timeend = $timestart + ($duration*24*60*60); + $timeend = $timestart + intval($duration*24*60*60); } $instances = $manager->get_enrolment_instances(); diff --git a/enrol/manual/lib.php b/enrol/manual/lib.php index b50e3cc1a0d..f4848273411 100644 --- a/enrol/manual/lib.php +++ b/enrol/manual/lib.php @@ -239,7 +239,7 @@ class enrol_manual_plugin extends enrol_plugin { $today = make_timestamp(date('Y', $now), date('m', $now), date('d', $now), 0, 0, 0); $startdateoptions[3] = get_string('today') . ' (' . userdate($today, $dateformat) . ')'; $startdateoptions[4] = get_string('now', 'enrol_manual') . ' (' . userdate($now, get_string('strftimedatetimeshort')) . ')'; - $defaultduration = $instance->enrolperiod > 0 ? $instance->enrolperiod / 86400 : ''; + $defaultduration = $instance->enrolperiod > 0 ? $instance->enrolperiod / DAYSECS : ''; $modules = array('moodle-enrol_manual-quickenrolment', 'moodle-enrol_manual-quickenrolment-skin'); $arguments = array( diff --git a/enrol/manual/manage.php b/enrol/manual/manage.php index 82d7a31870b..17627f8d605 100644 --- a/enrol/manual/manage.php +++ b/enrol/manual/manage.php @@ -89,8 +89,8 @@ if ($extendperiod) { } else { $defaultperiod = $instance->enrolperiod; } -if (!isset($periodmenu[$defaultperiod])) { - $periodmenu[$defaultperiod] = get_string('numdays', '', floor($defaultperiod / DAYSECS)); +if ($instance->enrolperiod > 0 && !isset($periodmenu[$instance->enrolperiod])) { + $periodmenu[$instance->enrolperiod] = format_time($instance->enrolperiod); } if (empty($extendbase)) { if (!$extendbase = get_config('enrol_manual', 'enrolstart')) { diff --git a/enrol/manual/yui/quickenrolment/quickenrolment.js b/enrol/manual/yui/quickenrolment/quickenrolment.js index d3a1468474b..fde75073997 100644 --- a/enrol/manual/yui/quickenrolment/quickenrolment.js +++ b/enrol/manual/yui/quickenrolment/quickenrolment.js @@ -227,6 +227,7 @@ YUI.add('moodle-enrol_manual-quickenrolment', function(Y) { populateDuration : function() { var select = this.get(UEP.BASE).one('.'+CSS.ENROLMENTOPTION+'.'+CSS.DURATION+' select'); var defaultvalue = this.get(UEP.DEFAULTDURATION); + var prefix = Math.round(defaultvalue) != defaultvalue ? '≈' : ''; var index = 0, count = 0; var durationdays = M.util.get_string('durationdays', 'enrol', '{a}'); for (var i = 1; i <= 365; i++) { @@ -237,8 +238,9 @@ YUI.add('moodle-enrol_manual-quickenrolment', function(Y) { } select.append(option); } - if (!index) { - select.append(create('')); + if (!index && defaultvalue > 0) { + select.append(create('')); index = ++count; } select.set('selectedIndex', index);