Browse Source

Improve display of "all courses" user report - display as table

also include links to specific course reports.
MOODLE_33_STABLE
Dan Marsden 8 years ago
parent
commit
026b2ee06f
  1. 5
      renderables.php
  2. 45
      renderer.php
  3. 4
      styles.css

5
renderables.php

@ -475,9 +475,12 @@ class attendance_user_data implements renderable {
$this->summary = array(); $this->summary = array();
foreach ($this->coursesatts as $atid => $ca) { foreach ($this->coursesatts as $atid => $ca) {
// Check to make sure the user can view this cm. // Check to make sure the user can view this cm.
if (!get_fast_modinfo($ca->courseid)->instances['attendance'][$ca->attid]->uservisible) { $modinfo = get_fast_modinfo($ca->courseid);
if (!$modinfo->instances['attendance'][$ca->attid]->uservisible) {
unset($this->courseatts[$atid]); unset($this->courseatts[$atid]);
continue; continue;
} else {
$this->coursesatts[$atid]->cmid = $modinfo->instances['attendance'][$ca->attid]->get_course_module_record()->id;
} }
$this->statuses[$ca->attid] = attendance_get_statuses($ca->attid); $this->statuses[$ca->attid] = attendance_get_statuses($ca->attid);
$this->summary[$ca->attid] = new mod_attendance_summary($ca->attid, array($userid)); $this->summary[$ca->attid] = new mod_attendance_summary($ca->attid, array($userid));

45
renderer.php

@ -27,6 +27,7 @@ defined('MOODLE_INTERNAL') || die();
require_once(dirname(__FILE__).'/locallib.php'); require_once(dirname(__FILE__).'/locallib.php');
require_once(dirname(__FILE__).'/renderables.php'); require_once(dirname(__FILE__).'/renderables.php');
require_once(dirname(__FILE__).'/renderhelpers.php'); require_once(dirname(__FILE__).'/renderhelpers.php');
require_once($CFG->libdir.'/tablelib.php');
/** /**
* Attendance module renderer class * Attendance module renderer class
@ -910,6 +911,7 @@ 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;
$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) {
@ -923,20 +925,45 @@ class mod_attendance_renderer extends plugin_renderer_base {
$o .= $this->construct_user_sessions_log($userdata); $o .= $this->construct_user_sessions_log($userdata);
} else { } else {
$prevcid = 0; $prevcid = 0;
$table = new html_table();
$table->head = array(get_string('course'),
get_string('pluginname', 'mod_attendance'),
get_string('sessionscompleted', 'attendance'),
get_string('pointssessionscompleted', 'attendance'),
get_string('percentagesessionscompleted', 'attendance'));
$table->align = array('left', 'left', 'center', 'center', 'center');
$totalattendance = 0;
$totalpercentage = 0;
foreach ($userdata->coursesatts as $ca) { foreach ($userdata->coursesatts as $ca) {
if ($prevcid != $ca->courseid) { $row = new html_table_row();
$o .= html_writer::empty_tag('hr'); $courseurl = new moodle_url('/course/view.php', array('id' => $ca->courseid));
$prevcid = $ca->courseid; $row->cells[] = html_writer::link($courseurl, $ca->coursefullname);
$attendanceurl = new moodle_url('/mod/attendance/view.php', array('id' => $ca->cmid,
$o .= html_writer::tag('h3', $ca->coursefullname); 'studentid' => $userdata->user->id,
} 'view' => ATT_VIEW_ALL));
$row->cells[] = html_writer::link($attendanceurl, $ca->attname);
if (isset($userdata->summary[$ca->attid])) { if (isset($userdata->summary[$ca->attid])) {
$o .= html_writer::tag('h4', $ca->attname);
$usersummary = $userdata->summary[$ca->attid]->get_all_sessions_summary_for($userdata->user->id); $usersummary = $userdata->summary[$ca->attid]->get_all_sessions_summary_for($userdata->user->id);
$o .= construct_user_data_stat($usersummary, ATT_VIEW_ALL);
$row->cells[] = $usersummary->numtakensessions;
$row->cells[] = format_float($usersummary->takensessionspoints, 1, true, true) . ' / ' .
format_float($usersummary->takensessionsmaxpoints, 1, true, true);
$row->cells[] = format_float($usersummary->takensessionspercentage * 100) . '%';
}
$table->data[] = $row;
if ($usersummary->numtakensessions > 0) {
$totalattendance++;
$totalpercentage = $totalpercentage + format_float($usersummary->takensessionspercentage * 100);
} }
} }
$row = new html_table_row();
$average = format_float($totalpercentage / $totalattendance).'%';
$col = new html_table_cell(get_string('averageattendance', 'mod_attendance'));
$col->attributes['class'] = 'averageattendance';
$row->cells = array($col, '', '','', $average);
$table->data[] = $row;
$o .= html_writer::table($table);
} }
return $o; return $o;

4
styles.css

@ -192,3 +192,7 @@
#page-mod-attendance-sessions .statusgroup .statusdesc { #page-mod-attendance-sessions .statusgroup .statusdesc {
margin-right: 12px; margin-right: 12px;
} }
#page-mod-attendance-view .averageattendance {
font-weight: bold;
}
Loading…
Cancel
Save