diff --git a/classes/structure.php b/classes/structure.php index 4f671fc..1cc95cb 100644 --- a/classes/structure.php +++ b/classes/structure.php @@ -586,8 +586,12 @@ class mod_attendance_structure { public function get_users($groupid = 0, $page = 1) { global $DB, $CFG; - // Fields we need from the user table. - $userfields = user_picture::fields('u', array('username' , 'idnumber' , 'institution' , 'department')); + $fields = array('username' , 'idnumber' , 'institution' , 'department'); + // Get user identity fields if required - doesn't return original $fields array. + $extrafields = get_extra_user_fields($this->context, $fields); + $fields = array_merge($fields, $extrafields); + + $userfields = user_picture::fields('u',$fields); if (empty($this->pageparams->sort)) { $this->pageparams->sort = ATT_SORT_DEFAULT; diff --git a/renderables.php b/renderables.php index 14cc7b6..773ff8d 100644 --- a/renderables.php +++ b/renderables.php @@ -275,7 +275,7 @@ class attendance_take_data implements renderable { private $urlpath; private $urlparams; - private $att; + public $att; public function __construct(mod_attendance_structure $att) { if ($att->pageparams->grouptype) { diff --git a/renderer.php b/renderer.php index e6a6b51..e62ea88 100644 --- a/renderer.php +++ b/renderer.php @@ -499,7 +499,7 @@ class mod_attendance_renderer extends plugin_renderer_base { } protected function render_attendance_take_list(attendance_take_data $takedata) { - global $PAGE; + global $PAGE, $CFG; $table = new html_table(); $table->width = '0%'; $table->head = array( @@ -509,6 +509,15 @@ class mod_attendance_renderer extends plugin_renderer_base { $table->align = array('left', 'left'); $table->size = array('20px', ''); $table->wrap[1] = 'nowrap'; + // Check if extra useridentity fields need to be added. + $extrasearchfields = array(); + if (!empty($CFG->showuseridentity) && has_capability('moodle/site:viewuseridentity', $takedata->att->context)) { + $extrasearchfields = explode(',', $CFG->showuseridentity); + } + foreach ($extrasearchfields as $field) { + $table->head[] = get_string($field); + $table->align[] = 'left'; + } foreach ($takedata->statuses as $st) { $table->head[] = html_writer::link("#", $st->acronym, array('id' => 'checkstatus'.$st->id, 'title' => get_string('setallstatusesto', 'attendance', $st->description))); @@ -533,6 +542,9 @@ class mod_attendance_renderer extends plugin_renderer_base { // Show a 'select all' row of radio buttons. $row = new html_table_row(); $row->cells[] = ''; + foreach ($extrasearchfields as $field) { + $row->cells[] = ''; + } $row->cells[] = html_writer::div(get_string('setallstatuses', 'attendance'), 'setallstatuses'); foreach ($takedata->statuses as $st) { $attribs = array( @@ -568,6 +580,9 @@ class mod_attendance_renderer extends plugin_renderer_base { $fullname .= $ucdata['warning']; } $row->cells[] = $fullname; + foreach ($extrasearchfields as $field) { + $row->cells[] = $user->$field; + } if (array_key_exists('colspan', $ucdata)) { $cell = new html_table_cell($ucdata['text']); @@ -887,6 +902,7 @@ class mod_attendance_renderer extends plugin_renderer_base { $table->attributes['class'] = 'generaltable attwidth attreport'; $userrows = $this->get_user_rows($reportdata); + if ($reportdata->pageparams->view == ATT_VIEW_SUMMARY) { $sessionrows = array(); } else { @@ -962,13 +978,23 @@ class mod_attendance_renderer extends plugin_renderer_base { $row = new html_table_row(); $row->cells[] = $this->build_header_cell(''); $row->cells[] = $this->build_header_cell($this->construct_fullname_head($reportdata), false, false); + + $extrafields = get_extra_user_fields($reportdata->att->context); + foreach ($extrafields as $field) { + $row->cells[] = $this->build_header_cell(get_string($field), false, false); + } + $rows[] = $row; + foreach ($reportdata->users as $user) { $row = new html_table_row(); $row->cells[] = $this->build_data_cell($this->user_picture($user)); $text = html_writer::link($reportdata->url_view(array('studentid' => $user->id)), fullname($user)); $row->cells[] = $this->build_data_cell($text, false, false, null, null, false); + foreach ($extrafields as $field) { + $row->cells[] = $this->build_data_cell($user->$field, false, false); + } $rows[] = $row; }