diff --git a/export.php b/export.php index 57d7ebc..13949e5 100644 --- a/export.php +++ b/export.php @@ -87,10 +87,12 @@ if ($mform->is_submitted()) { if (isset($formdata->ident['uname'])) { $data->tabhead[] = get_string('username'); } + if (isset($formdata->ident['idnumber'])) { + $data->tabhead[] = get_string('idnumber'); + } $data->tabhead[] = get_string('lastname'); $data->tabhead[] = get_string('firstname'); - if (count($reportdata->sessions) > 0) { foreach ($reportdata->sessions as $sess) { $text = userdate($sess->sessdate, get_string('strftimedmyhm', 'attendance')); @@ -114,6 +116,9 @@ if ($mform->is_submitted()) { if (isset($formdata->ident['uname'])) { $data->table[$i][] = $user->username; } + if (isset($formdata->ident['idnumber'])) { + $data->table[$i][] = $user->idnumber; + } $data->table[$i][] = $user->lastname; $data->table[$i][] = $user->firstname; $cellsgenerator = new user_sessions_cells_text_generator($reportdata, $user); diff --git a/export_form.php b/export_form.php index e43e1c6..5ec04f1 100644 --- a/export_form.php +++ b/export_form.php @@ -62,13 +62,14 @@ class mod_attendance_export_form extends moodleform { $ident = array(); $ident[] =& $mform->createElement('checkbox', 'id', '', get_string('studentid', 'attendance')); - $ident[] =& $mform->createElement('checkbox', 'uname', '', get_string('username')); + $ident[] =& $mform->createElement('checkbox', 'idnumber', '', get_string('idnumber')); $mform->addGroup($ident, 'ident', get_string('identifyby', 'attendance'), array('
'), true); - $mform->setDefaults(array('ident[id]' => true, 'ident[uname]' => true)); + $mform->setDefaults(array('ident[id]' => true, 'ident[uname]' => true, 'ident[idnumber]' => false)); $mform->setType('id', PARAM_INT); $mform->setType('uname', PARAM_INT); - + $mform->setType('idnumber', PARAM_NOTAGS); + $mform->addElement('checkbox', 'includeallsessions', get_string('includeall', 'attendance'), get_string('yes')); $mform->setDefault('includeallsessions', true); $mform->addElement('checkbox', 'includenottaken', get_string('includenottaken', 'attendance'), get_string('yes')); diff --git a/locallib.php b/locallib.php index cda5fc5..5fa8fd6 100644 --- a/locallib.php +++ b/locallib.php @@ -962,12 +962,12 @@ class attendance { global $DB; // Fields we need from the user table. - $userfields = user_picture::fields('u').',u.username'; + $userfields = user_picture::fields('u').',u.username,u.idnumber'; if (isset($this->pageparams->sort) and ($this->pageparams->sort == ATT_SORT_FIRSTNAME)) { - $orderby = "u.firstname ASC, u.lastname ASC"; + $orderby = "u.firstname ASC, u.lastname ASC, u.idnumber ASC"; } else { - $orderby = "u.lastname ASC, u.firstname ASC"; + $orderby = "u.lastname ASC, u.firstname ASC, u.idnumber ASC"; } $users = get_enrolled_users($this->context, 'mod/attendance:canbelisted', $groupid, $userfields, $orderby);