Browse Source

move date_selector into function to prevent copypaste detector error

MOODLE_29_STABLE
Dan Marsden 9 years ago
parent
commit
48ea9e38a2
  1. 18
      add_form.php
  2. 21
      locallib.php
  3. 18
      update_form.php

18
add_form.php

@ -102,23 +102,7 @@ class mod_attendance_add_form extends moodleform {
}
}
$mform->addElement('date_selector', 'sessiondate', get_string('sessiondate', 'attendance'));
for ($i = 0; $i <= 23; $i++) {
$hours[$i] = sprintf("%02d", $i);
}
for ($i = 0; $i < 60; $i += 5) {
$minutes[$i] = sprintf("%02d", $i);
}
$sesendtime = array();
$sesendtime[] =& $mform->createElement('static', 'from', '', get_string('from', 'attendance'));
$sesendtime[] =& $mform->createElement('select', 'starthour', get_string('hour', 'form'), $hours, false, true);
$sesendtime[] =& $mform->createElement('select', 'startminute', get_string('minute', 'form'), $minutes, false, true);
$sesendtime[] =& $mform->createElement('static', 'to', '', get_string('to', 'attendance'));
$sesendtime[] =& $mform->createElement('select', 'endhour', get_string('hour', 'form'), $hours, false, true);
$sesendtime[] =& $mform->createElement('select', 'endminute', get_string('minute', 'form'), $minutes, false, true);
$mform->addGroup($sesendtime, 'sestime', get_string('time', 'attendance'), array(' '), true);
attendance_form_sessiondate_selector($mform);
// Select which status set to use.
$maxstatusset = attendance_get_max_statusset($this->_customdata['att']->id);

21
locallib.php

@ -1760,3 +1760,24 @@ function att_log_convert_url(moodle_url $fullurl) {
return substr($fullurl->out(), strlen($baseurl));
}
// Helper function to add sessiondate_selector to form.
function attendance_form_sessiondate_selector (MoodleQuickForm $mform) {
$mform->addElement('date_selector', 'sessiondate', get_string('sessiondate', 'attendance'));
for ($i = 0; $i <= 23; $i++) {
$hours[$i] = sprintf("%02d", $i);
}
for ($i = 0; $i < 60; $i += 5) {
$minutes[$i] = sprintf("%02d", $i);
}
$sesendtime = array();
$sesendtime[] =& $mform->createElement('static', 'from', '', get_string('from', 'attendance'));
$sesendtime[] =& $mform->createElement('select', 'starthour', get_string('hour', 'form'), $hours, false, true);
$sesendtime[] =& $mform->createElement('select', 'startminute', get_string('minute', 'form'), $minutes, false, true);
$sesendtime[] =& $mform->createElement('static', 'to', '', get_string('to', 'attendance'));
$sesendtime[] =& $mform->createElement('select', 'endhour', get_string('hour', 'form'), $hours, false, true);
$sesendtime[] =& $mform->createElement('select', 'endminute', get_string('minute', 'form'), $minutes, false, true);
$mform->addGroup($sesendtime, 'sestime', get_string('time', 'attendance'), array(' '), true);
}

18
update_form.php

@ -80,23 +80,7 @@ class mod_attendance_update_form extends moodleform {
$olddate = construct_session_full_date_time($sess->sessdate, $sess->duration);
$mform->addElement('static', 'olddate', get_string('olddate', 'attendance'), $olddate);
$mform->addElement('date_selector', 'sessiondate', get_string('sessiondate', 'attendance'));
for ($i = 0; $i <= 23; $i++) {
$hours[$i] = sprintf("%02d", $i);
}
for ($i = 0; $i < 60; $i += 5) {
$minutes[$i] = sprintf("%02d", $i);
}
$sesendtime = array();
$sesendtime[] =& $mform->createElement('static', 'from', '', get_string('from', 'attendance'));
$sesendtime[] =& $mform->createElement('select', 'starthour', get_string('hour', 'form'), $hours, false, true);
$sesendtime[] =& $mform->createElement('select', 'startminute', get_string('minute', 'form'), $minutes, false, true);
$sesendtime[] =& $mform->createElement('static', 'to', '', get_string('to', 'attendance'));
$sesendtime[] =& $mform->createElement('select', 'endhour', get_string('hour', 'form'), $hours, false, true);
$sesendtime[] =& $mform->createElement('select', 'endminute', get_string('minute', 'form'), $minutes, false, true);
$mform->addGroup($sesendtime, 'sestime', get_string('time', 'attendance'), array(' '), true);
attendance_form_sessiondate_selector($mform);
// Show which status set is in use.
$maxstatusset = attendance_get_max_statusset($this->_customdata['att']->id);

Loading…
Cancel
Save