@ -875,8 +875,16 @@ class mod_attendance_renderer extends plugin_renderer_base {
* @return string
* @return string
*/
*/
protected function render_attendance_user_data(attendance_user_data $userdata) {
protected function render_attendance_user_data(attendance_user_data $userdata) {
global $USER;
$o = $this->render_user_report_tabs($userdata);
$o = $this->render_user_report_tabs($userdata);
if ($USER->id == $userdata->user->id) {
$o .= $this->construct_user_data($userdata);
} else {
$table = new html_table();
$table = new html_table();
$table->attributes['class'] = 'userinfobox';
$table->attributes['class'] = 'userinfobox';
@ -886,6 +894,7 @@ class mod_attendance_renderer extends plugin_renderer_base {
$table->data[0][] = $this->construct_user_data($userdata);
$table->data[0][] = $this->construct_user_data($userdata);
$o .= html_writer::table($table);
$o .= html_writer::table($table);
}
return $o;
return $o;
}
}
@ -920,18 +929,18 @@ class mod_attendance_renderer extends plugin_renderer_base {
* @return string
* @return string
*/
*/
private function construct_user_data(attendance_user_data $userdata) {
private function construct_user_data(attendance_user_data $userdata) {
global $PAGE;
global $USER;
$o = '';
if ($USER->id < > $userdata->user->id) {
$o = html_writer::tag('h2', fullname($userdata->user));
$o = html_writer::tag('h2', fullname($userdata->user));
}
if ($userdata->pageparams->mode == mod_attendance_view_page_params::MODE_THIS_COURSE) {
if ($userdata->pageparams->mode == mod_attendance_view_page_params::MODE_THIS_COURSE) {
$o .= $this->render_attendance_filter_controls($userdata->filtercontrols);
$o .= $this->construct_user_sessions_log($userdata);
$o .= html_writer::empty_tag('hr');
$o .= html_writer::empty_tag('hr');
$o .= construct_user_data_stat($userdata->summary->get_all_sessions_summary_for($userdata->user->id),
$o .= construct_user_data_stat($userdata->summary->get_all_sessions_summary_for($userdata->user->id),
$userdata->pageparams->view);
$userdata->pageparams->view);
$o .= $this->render_attendance_filter_controls($userdata->filtercontrols);
$o .= $this->construct_user_sessions_log($userdata);
} else {
} else {
$prevcid = 0;
$prevcid = 0;
$table = new html_table();
$table = new html_table();
@ -985,25 +994,38 @@ class mod_attendance_renderer extends plugin_renderer_base {
* @return string
* @return string
*/
*/
private function construct_user_sessions_log(attendance_user_data $userdata) {
private function construct_user_sessions_log(attendance_user_data $userdata) {
global $OUTPUT;
global $OUTPUT, $USER ;
$context = context_module::instance($userdata->filtercontrols->cm->id);
$context = context_module::instance($userdata->filtercontrols->cm->id);
$shortform = false;
if ($USER->id == $userdata->user->id) {
// This is a user viewing their own stuff - hide non-relevant columns.
$shortform = true;
}
$table = new html_table();
$table = new html_table();
$table->attributes['class'] = 'generaltable attwidth boxaligncenter';
$table->attributes['class'] = 'generaltable attwidth boxaligncenter';
$table->head = array(
$table->head = array();
'#',
$table->align = array();
get_string('sessiontypeshort', 'attendance'),
$table->size = array();
get_string('date'),
if (!$shortform) {
get_string('time'),
$table->head[] = get_string('sessiontypeshort', 'attendance');
get_string('description', 'attendance'),
$table->align[] = '';
get_string('status', 'attendance'),
$table->size[] = '1px';
get_string('points', 'attendance'),
}
get_string('remarks', 'attendance')
$table->head[] = get_string('date');
);
$table->head[] = get_string('description', 'attendance');
$table->align = array('', '', '', 'left', 'left', 'center', 'center', 'center');
$table->head[] = get_string('status', 'attendance');
$table->size = array('1px', '1px', '1px', '1px', '*', '*', '1px', '*');
$table->head[] = get_string('points', 'attendance');
$table->head[] = get_string('remarks', 'attendance');
$table->align = array_merge($table->align, array('', 'left', 'center', 'center', 'center'));
$table->size = array_merge($table->size, array('1px', '*', '*', '1px', '*'));
if (has_capability('mod/attendance:takeattendances', $context)) {
if (has_capability('mod/attendance:takeattendances', $context)) {
$table->head[] = get_string('action');
$table->head[] = get_string('action');
$table->align[] = '';
$table->size[] = '';
}
}
$statussetmaxpoints = attendance_get_statusset_maxpoints($userdata->statuses);
$statussetmaxpoints = attendance_get_statusset_maxpoints($userdata->statuses);
@ -1013,7 +1035,7 @@ class mod_attendance_renderer extends plugin_renderer_base {
$i++;
$i++;
$row = new html_table_row();
$row = new html_table_row();
$row->cells[] = $i;
if (!$shortform) {
if ($sess->groupid) {
if ($sess->groupid) {
$sessiontypeshort = get_string('group') . ': ' . $userdata->groups[$sess->groupid]->name;
$sessiontypeshort = get_string('group') . ': ' . $userdata->groups[$sess->groupid]->name;
} else {
} else {
@ -1021,8 +1043,9 @@ class mod_attendance_renderer extends plugin_renderer_base {
}
}
$row->cells[] = html_writer::tag('nobr', $sessiontypeshort);
$row->cells[] = html_writer::tag('nobr', $sessiontypeshort);
$row->cells[] = userdate($sess->sessdate, get_string('strftimedmyw', 'attendance'));
}
$row->cells[] = $this->construct_time($sess->sessdate, $sess->duration);
$row->cells[] = userdate($sess->sessdate, get_string('strftimedmyw', 'attendance')) .
" ". $this->construct_time($sess->sessdate, $sess->duration);
$row->cells[] = $sess->description;
$row->cells[] = $sess->description;
if (isset($sess->statusid)) {
if (isset($sess->statusid)) {
$status = $userdata->statuses[$sess->statusid];
$status = $userdata->statuses[$sess->statusid];
@ -1033,12 +1056,12 @@ class mod_attendance_renderer extends plugin_renderer_base {
} else if ($sess->sessdate < $userdata->user->enrolmentstart) {
} else if ($sess->sessdate < $userdata->user->enrolmentstart) {
$cell = new html_table_cell(get_string('enrolmentstart', 'attendance',
$cell = new html_table_cell(get_string('enrolmentstart', 'attendance',
userdate($userdata->user->enrolmentstart, '%d.%m.%Y')));
userdate($userdata->user->enrolmentstart, '%d.%m.%Y')));
$cell->colspan = 2 ;
$cell->colspan = 3 ;
$row->cells[] = $cell;
$row->cells[] = $cell;
} else if ($userdata->user->enrolmentend and $sess->sessdate > $userdata->user->enrolmentend) {
} else if ($userdata->user->enrolmentend and $sess->sessdate > $userdata->user->enrolmentend) {
$cell = new html_table_cell(get_string('enrolmentend', 'attendance',
$cell = new html_table_cell(get_string('enrolmentend', 'attendance',
userdate($userdata->user->enrolmentend, '%d.%m.%Y')));
userdate($userdata->user->enrolmentend, '%d.%m.%Y')));
$cell->colspan = 2 ;
$cell->colspan = 3 ;
$row->cells[] = $cell;
$row->cells[] = $cell;
} else {
} else {
if (attendance_can_student_mark($sess)) {
if (attendance_can_student_mark($sess)) {
@ -1048,7 +1071,7 @@ class mod_attendance_renderer extends plugin_renderer_base {
$url = new moodle_url('/mod/attendance/attendance.php',
$url = new moodle_url('/mod/attendance/attendance.php',
array('sessid' => $sess->id, 'sesskey' => sesskey()));
array('sessid' => $sess->id, 'sesskey' => sesskey()));
$cell = new html_table_cell(html_writer::link($url, get_string('submitattendance', 'attendance')));
$cell = new html_table_cell(html_writer::link($url, get_string('submitattendance', 'attendance')));
$cell->colspan = 2 ;
$cell->colspan = 3 ;
$row->cells[] = $cell;
$row->cells[] = $cell;
} else { // Student cannot mark their own attendace.
} else { // Student cannot mark their own attendace.
$row->cells[] = '?';
$row->cells[] = '?';