MDL-48248 enrol_manual: Handle durations more precise than int days
This commit is contained in:
committed by
David Monllao
parent
c2d39f88e3
commit
809309af4f
@@ -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();
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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')) {
|
||||
|
||||
+4
-2
@@ -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('<option value="'+defaultvalue+'">'+durationdays.replace('{a}', defaultvalue)+'</option>'));
|
||||
if (!index && defaultvalue > 0) {
|
||||
select.append(create('<option value="'+defaultvalue+'">'+durationdays.replace('{a}',
|
||||
prefix + (Math.round(defaultvalue * 100) / 100))+'</option>'));
|
||||
index = ++count;
|
||||
}
|
||||
select.set('selectedIndex', index);
|
||||
|
||||
Reference in New Issue
Block a user