From eb85b45dea3cb8a21aca58aaa31194f016ee384a Mon Sep 17 00:00:00 2001 From: Nick Phillips Date: Wed, 10 Jul 2019 11:15:24 +1200 Subject: [PATCH] Fixes for bugs, and other tweaks to keep travis quiet. --- locallib.php | 8 -------- renderer.php | 25 ++++++++++--------------- 2 files changed, 10 insertions(+), 23 deletions(-) diff --git a/locallib.php b/locallib.php index 3c44506..a14c58b 100644 --- a/locallib.php +++ b/locallib.php @@ -121,14 +121,6 @@ function get_user_sessions_log_full($userid, $pageparams) { $usercourses = enrol_get_users_courses($userid); list($usql, $uparams) = $DB->get_in_or_equal(array_keys($usercourses), SQL_PARAMS_NAMED, 'cid0'); - // If we base on structure->get_user_filtered_sessions_log_extended: - /* if ($this->pageparams->startdate && $this->pageparams->enddate) { */ - /* $where = "ats.sessdate >= :csdate AND */ - /* ats.sessdate >= :sdate AND ats.sessdate < :edate"; */ - /* } else { */ - /* $where = "ats.attendanceid = :aid AND ats.sessdate >= :csdate"; */ - /* } */ - $coursesql = "(1 = 1)"; $courseparams = array(); $now = time(); diff --git a/renderer.php b/renderer.php index 926b2c3..4f3fda7 100644 --- a/renderer.php +++ b/renderer.php @@ -62,7 +62,8 @@ class mod_attendance_renderer extends plugin_renderer_base { $filtertable->width = '100%'; $filtertable->align = array('left', 'center', 'right', 'right'); - if ($fcontrols->pageparams->mode === mod_attendance_view_page_params::MODE_ALL_SESSIONS) { + if (property_exists($fcontrols->pageparams, 'mode') && + $fcontrols->pageparams->mode === mod_attendance_view_page_params::MODE_ALL_SESSIONS) { $classes .= ' float-right'; $row = array(); @@ -1338,10 +1339,8 @@ class mod_attendance_renderer extends plugin_renderer_base { $context = context_module::instance($userdata->filtercontrols->cm->id); + // 'course', 'activity', 'date' $groupby = $userdata->pageparams->groupby; - //$groupby = 'course'; - //$groupby = 'activity'; - //$groupby = 'date'; $table = new html_table(); $table->attributes['class'] = 'generaltable attwidth boxaligncenter allsessions'; @@ -1402,8 +1401,7 @@ class mod_attendance_renderer extends plugin_renderer_base { $colcount++; } - // use "session" instead - //$table->head[] = get_string('description', 'attendance'); + // use "session" instead of "description" $table->head[] = get_string('session', 'attendance'); $table->align[] = 'left'; $table->colclasses[] = 'desccol'; @@ -1512,9 +1510,6 @@ class mod_attendance_renderer extends plugin_renderer_base { // // A bit yucky because we can't tell whether we've seen statusset before, and // we usually will have, so much wasted spinning. - if ($sess->id == 163) { - error_log("STATUSSET: ".print_r($sess->statusset, true)); - } foreach ($userdata->statuses[$sess->attendanceid] as $attstatus) { if ($attstatus->setnumber === $sess->statusset) { if (!array_key_exists($attstatus->acronym, $stats['date'][$weekformat]['statuses'])) { @@ -1680,7 +1675,7 @@ class mod_attendance_renderer extends plugin_renderer_base { $row = new html_table_row(); $row->attributes['class'] = 'grouper'; $cell = new html_table_cell(); - $cell->rowspan = sizeof($group) + 2; + $cell->rowspan = count($group) + 2; $row->cells[] = $cell; $week = date("W", $sess->sessdate); $year = date("Y", $sess->sessdate); @@ -1724,7 +1719,7 @@ class mod_attendance_renderer extends plugin_renderer_base { $row = new html_table_row(); $row->attributes['class'] = 'grouper'; $cell = new html_table_cell(); - $cell->rowspan = sizeof($group) + 2; + $cell->rowspan = count($group) + 2; if ($groupby === 'activity') { $headcell = $cell; // keep ref to be able to adjust rowspan later $cell->rowspan += 2; @@ -1766,12 +1761,12 @@ class mod_attendance_renderer extends plugin_renderer_base { } if ($groupby === 'activity') { if ($sess->courseid === $lastgroup[0]) { - $headcell->rowspan += sizeof($group) + 2; + $headcell->rowspan += count($group) + 2; } $row = new html_table_row(); $row->attributes['class'] = 'grouper'; $cell = new html_table_cell(); - $cell->rowspan = sizeof($group) + 2; + $cell->rowspan = count($group) + 2; $row->cells[] = $cell; $attendanceurl = new moodle_url('/mod/attendance/view.php', array('id' => $sess->cmid, 'studentid' => $userdata->user->id, @@ -1812,7 +1807,7 @@ class mod_attendance_renderer extends plugin_renderer_base { // Now iterate over sessions in group... - foreach($group as $sess) { + foreach ($group as $sess) { $row = new html_table_row(); // partialdate? / course? / activity? / date? / session / type / status / points / remarks / action @@ -1868,7 +1863,7 @@ class mod_attendance_renderer extends plugin_renderer_base { } if (!empty($USER->editing)) { - // TODO! + // TODO: add ability to edit attendance here } else { if (!empty($sess->statusid)) { $status = $userdata->statuses[$sess->attendanceid][$sess->statusid];