From 8ddd624c6c6ad6a3f364875d0533ce4759a238ff Mon Sep 17 00:00:00 2001 From: Joseph Baxter Date: Fri, 23 May 2014 15:12:51 +0100 Subject: [PATCH] MOODLE-845 add department and institution --- export.php | 12 ++++++++++++ export_form.php | 11 ++++++++--- locallib.php | 6 +++--- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/export.php b/export.php index 13949e5..ad6bcf0 100644 --- a/export.php +++ b/export.php @@ -90,6 +90,12 @@ if ($mform->is_submitted()) { if (isset($formdata->ident['idnumber'])) { $data->tabhead[] = get_string('idnumber'); } + if (isset($formdata->ident['institution'])) { + $data->tabhead[] = get_string('institution'); + } + if (isset($formdata->ident['department'])) { + $data->tabhead[] = get_string('department'); + } $data->tabhead[] = get_string('lastname'); $data->tabhead[] = get_string('firstname'); @@ -119,6 +125,12 @@ if ($mform->is_submitted()) { if (isset($formdata->ident['idnumber'])) { $data->table[$i][] = $user->idnumber; } + if (isset($formdata->ident['institution'])) { + $data->table[$i][] = $user->institution; + } + if (isset($formdata->ident['department'])) { + $data->table[$i][] = $user->department; + } $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 5ec04f1..351d21f 100644 --- a/export_form.php +++ b/export_form.php @@ -63,12 +63,17 @@ 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')); + + $optional = array('idnumber', 'institution', 'department'); + foreach ($optional as $opt) { + $ident[] =& $mform->createElement('checkbox', $opt, '', get_string($opt)); + $mform->setType($opt, PARAM_NOTAGS); + } + $mform->addGroup($ident, 'ident', get_string('identifyby', 'attendance'), array('
'), true); - $mform->setDefaults(array('ident[id]' => true, 'ident[uname]' => true, 'ident[idnumber]' => false)); + $mform->setDefaults(array('ident[id]' => true, 'ident[uname]' => true)); $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); diff --git a/locallib.php b/locallib.php index 5fa8fd6..c2b257c 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,u.idnumber'; + $userfields = user_picture::fields('u').',u.username,u.idnumber,u.institution,u.department'; if (isset($this->pageparams->sort) and ($this->pageparams->sort == ATT_SORT_FIRSTNAME)) { - $orderby = "u.firstname ASC, u.lastname ASC, u.idnumber ASC"; + $orderby = "u.firstname ASC, u.lastname ASC, u.idnumber ASC, u.institution ASC, u.department ASC"; } else { - $orderby = "u.lastname ASC, u.firstname ASC, u.idnumber ASC"; + $orderby = "u.lastname ASC, u.firstname ASC, u.idnumber ASC, u.institution ASC, u.department ASC"; } $users = get_enrolled_users($this->context, 'mod/attendance:canbelisted', $groupid, $userfields, $orderby);