From 4be6603034be46b004af6e40f9ab1e6cc0e30030 Mon Sep 17 00:00:00 2001 From: Joseph Baxter Date: Fri, 23 May 2014 14:47:22 +0100 Subject: [PATCH 1/7] MOODLE-845 add idnumber to export --- export.php | 7 ++++++- export_form.php | 7 ++++--- locallib.php | 6 +++--- 3 files changed, 13 insertions(+), 7 deletions(-) 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); From 8ddd624c6c6ad6a3f364875d0533ce4759a238ff Mon Sep 17 00:00:00 2001 From: Joseph Baxter Date: Fri, 23 May 2014 15:12:51 +0100 Subject: [PATCH 2/7] 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); From 2de47f26cec0739e50e00675c5e898e0612c98c5 Mon Sep 17 00:00:00 2001 From: Joseph Baxter Date: Fri, 23 May 2014 15:43:18 +0100 Subject: [PATCH 3/7] tidy up --- export.php | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/export.php b/export.php index ad6bcf0..fab396f 100644 --- a/export.php +++ b/export.php @@ -87,15 +87,14 @@ if ($mform->is_submitted()) { if (isset($formdata->ident['uname'])) { $data->tabhead[] = get_string('username'); } - 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'); + + $optional = array('idnumber', 'institution', 'department'); + foreach ($optional as $opt) { + if (isset($formdata->ident[$opt])) { + $data->tabhead[] = get_string($opt); + } } + $data->tabhead[] = get_string('lastname'); $data->tabhead[] = get_string('firstname'); @@ -122,15 +121,14 @@ if ($mform->is_submitted()) { if (isset($formdata->ident['uname'])) { $data->table[$i][] = $user->username; } - 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; + + $optional_row = array('idnumber', 'institution', 'department'); + foreach ($$optional_row as $opt) { + if (isset($formdata->ident[$opt])) { + $data->table[$i][] = $user->$opt; + } } + $data->table[$i][] = $user->lastname; $data->table[$i][] = $user->firstname; $cellsgenerator = new user_sessions_cells_text_generator($reportdata, $user); From aa12bb4f2240c947f8f502f709fca6f33b27cba6 Mon Sep 17 00:00:00 2001 From: Joseph Baxter Date: Fri, 23 May 2014 15:45:20 +0100 Subject: [PATCH 4/7] typo --- export.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/export.php b/export.php index fab396f..995e937 100644 --- a/export.php +++ b/export.php @@ -123,7 +123,7 @@ if ($mform->is_submitted()) { } $optional_row = array('idnumber', 'institution', 'department'); - foreach ($$optional_row as $opt) { + foreach ($optional_row as $opt) { if (isset($formdata->ident[$opt])) { $data->table[$i][] = $user->$opt; } From a1e9d1ff60142be359d8e87e89710aa712d69b08 Mon Sep 17 00:00:00 2001 From: Joseph Baxter Date: Tue, 27 May 2014 08:55:04 +0100 Subject: [PATCH 5/7] code review: removed new line --- export_form.php | 1 - 1 file changed, 1 deletion(-) diff --git a/export_form.php b/export_form.php index 351d21f..0751090 100644 --- a/export_form.php +++ b/export_form.php @@ -74,7 +74,6 @@ class mod_attendance_export_form extends moodleform { $mform->setDefaults(array('ident[id]' => true, 'ident[uname]' => true)); $mform->setType('id', PARAM_INT); $mform->setType('uname', PARAM_INT); - $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')); From cdd1079f667f044ec3325f2d436019387d55f7d4 Mon Sep 17 00:00:00 2001 From: Joseph Baxter Date: Tue, 27 May 2014 08:59:22 +0100 Subject: [PATCH 6/7] code review change new line without whitespace --- export_form.php | 1 + 1 file changed, 1 insertion(+) diff --git a/export_form.php b/export_form.php index 0751090..351d21f 100644 --- a/export_form.php +++ b/export_form.php @@ -74,6 +74,7 @@ class mod_attendance_export_form extends moodleform { $mform->setDefaults(array('ident[id]' => true, 'ident[uname]' => true)); $mform->setType('id', PARAM_INT); $mform->setType('uname', PARAM_INT); + $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')); From 89b1c5cf2a199182c0a40d86282feee30dc6eb4d Mon Sep 17 00:00:00 2001 From: Joseph Baxter Date: Tue, 27 May 2014 09:07:04 +0100 Subject: [PATCH 7/7] fixing whitespce --- export_form.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/export_form.php b/export_form.php index 351d21f..ef33010 100644 --- a/export_form.php +++ b/export_form.php @@ -74,7 +74,7 @@ class mod_attendance_export_form extends moodleform { $mform->setDefaults(array('ident[id]' => true, 'ident[uname]' => true)); $mform->setType('id', PARAM_INT); $mform->setType('uname', PARAM_INT); - + $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'));