Browse Source

Merged in drjosephbaxter/moodle-mod_attendance/UoNChanges (pull request #2)

MOODLE-845
MOODLE_26_STABLE
Neill Magill 11 years ago
parent
commit
24683d313d
  1. 17
      export.php
  2. 8
      export_form.php
  3. 6
      locallib.php

17
export.php

@ -87,10 +87,17 @@ if ($mform->is_submitted()) {
if (isset($formdata->ident['uname'])) { if (isset($formdata->ident['uname'])) {
$data->tabhead[] = get_string('username'); $data->tabhead[] = get_string('username');
} }
$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('lastname');
$data->tabhead[] = get_string('firstname'); $data->tabhead[] = get_string('firstname');
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'));
@ -114,6 +121,14 @@ if ($mform->is_submitted()) {
if (isset($formdata->ident['uname'])) { if (isset($formdata->ident['uname'])) {
$data->table[$i][] = $user->username; $data->table[$i][] = $user->username;
} }
$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->lastname;
$data->table[$i][] = $user->firstname; $data->table[$i][] = $user->firstname;
$cellsgenerator = new user_sessions_cells_text_generator($reportdata, $user); $cellsgenerator = new user_sessions_cells_text_generator($reportdata, $user);

8
export_form.php

@ -62,8 +62,14 @@ 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'));
$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('<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));
$mform->setType('id', PARAM_INT); $mform->setType('id', PARAM_INT);

6
locallib.php

@ -962,12 +962,12 @@ class attendance {
global $DB; global $DB;
// Fields we need from the user table. // Fields we need from the user table.
$userfields = user_picture::fields('u').',u.username'; $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)) { 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, u.institution ASC, u.department ASC";
} else { } else {
$orderby = "u.lastname ASC, u.firstname 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); $users = get_enrolled_users($this->context, 'mod/attendance:canbelisted', $groupid, $userfields, $orderby);

Loading…
Cancel
Save