Browse Source

MOODLE-845 add idnumber to export

MOODLE_26_STABLE
Joseph Baxter 11 years ago
parent
commit
127a72ed39
  1. 7
      export.php
  2. 5
      export_form.php
  3. 6
      locallib.php

7
export.php

@ -88,6 +88,9 @@ if ($mform->is_submitted()) {
if (isset($formdata->ident['uname'])) { if (isset($formdata->ident['uname'])) {
$data->tabhead[] = get_string('username'); $data->tabhead[] = get_string('username');
} }
if (isset($formdata->ident['idnumber'])) {
$data->tabhead[] = get_string('idnumber');
}
$data->tabhead[] = get_string('lastname'); $data->tabhead[] = get_string('lastname');
$data->tabhead[] = get_string('firstname'); $data->tabhead[] = get_string('firstname');
$groupmode = groups_get_activity_groupmode($cm, $course); $groupmode = groups_get_activity_groupmode($cm, $course);
@ -95,7 +98,6 @@ if ($mform->is_submitted()) {
$data->tabhead[] = get_string('groups'); $data->tabhead[] = get_string('groups');
} }
if (count($reportdata->sessions) > 0) { if (count($reportdata->sessions) > 0) {
foreach ($reportdata->sessions as $sess) { foreach ($reportdata->sessions as $sess) {
$text = userdate($sess->sessdate, get_string('strftimedmyhm', 'attendance')); $text = userdate($sess->sessdate, get_string('strftimedmyhm', 'attendance'));
@ -122,6 +124,9 @@ if ($mform->is_submitted()) {
if (isset($formdata->ident['uname'])) { if (isset($formdata->ident['uname'])) {
$data->table[$i][] = $user->username; $data->table[$i][] = $user->username;
} }
if (isset($formdata->ident['idnumber'])) {
$data->table[$i][] = $user->idnumber;
}
$data->table[$i][] = $user->lastname; $data->table[$i][] = $user->lastname;
$data->table[$i][] = $user->firstname; $data->table[$i][] = $user->firstname;
if (!empty($groupmode)) { if (!empty($groupmode)) {

5
export_form.php

@ -62,12 +62,13 @@ class mod_attendance_export_form extends moodleform {
$ident = array(); $ident = array();
$ident[] =& $mform->createElement('checkbox', 'id', '', get_string('studentid', 'attendance')); $ident[] =& $mform->createElement('checkbox', 'id', '', get_string('studentid', 'attendance'));
$ident[] =& $mform->createElement('checkbox', 'uname', '', get_string('username')); $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('<br />'), true); $mform->addGroup($ident, 'ident', get_string('identifyby', 'attendance'), array('<br />'), 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('id', PARAM_INT);
$mform->setType('uname', PARAM_INT); $mform->setType('uname', PARAM_INT);
$mform->setType('idnumber', PARAM_NOTAGS);
$mform->addElement('checkbox', 'includeallsessions', get_string('includeall', 'attendance'), get_string('yes')); $mform->addElement('checkbox', 'includeallsessions', get_string('includeall', 'attendance'), get_string('yes'));
$mform->setDefault('includeallsessions', true); $mform->setDefault('includeallsessions', true);

6
locallib.php

@ -981,12 +981,12 @@ class attendance {
global $DB, $CFG; global $DB, $CFG;
// Fields we need from the user table. // Fields we need from the user table.
$userfields = user_picture::fields('u', array('username')); $userfields = user_picture::fields('u').',u.username,u.idnumber';
if (isset($this->pageparams->sort) and ($this->pageparams->sort == ATT_SORT_FIRSTNAME)) { 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 { } else {
$orderby = "u.lastname ASC, u.firstname ASC"; $orderby = "u.lastname ASC, u.firstname ASC, u.idnumber ASC";
} }
if ($page) { if ($page) {

Loading…
Cancel
Save