diff --git a/classes/structure.php b/classes/structure.php index e80ae3f..4acc3a7 100644 --- a/classes/structure.php +++ b/classes/structure.php @@ -61,10 +61,6 @@ class mod_attendance_structure { // Array by sessionid. private $sessioninfo = array(); - // Arrays by userid. - private $usertakensesscount = array(); - private $userstatusesstat = array(); - /** * Initializes the attendance API instance using the data from DB * diff --git a/classes/summary.php b/classes/summary.php index 9f7279e..b1b388b 100644 --- a/classes/summary.php +++ b/classes/summary.php @@ -100,7 +100,8 @@ class mod_attendance_summary { $usersummary->takensessionspoints = 0; $usersummary->takensessionsmaxpoints = 0; } - $usersummary->takensessionspercentage = attendance_calc_fraction($usersummary->takensessionspoints, $usersummary->takensessionsmaxpoints); + $usersummary->takensessionspercentage = attendance_calc_fraction($usersummary->takensessionspoints, + $usersummary->takensessionsmaxpoints); return $usersummary; } @@ -131,11 +132,13 @@ class mod_attendance_summary { } } } - $usersummary->allsessionspercentage = attendance_calc_fraction($usersummary->takensessionspoints, $usersummary->allsessionsmaxpoints); + $usersummary->allsessionspercentage = attendance_calc_fraction($usersummary->takensessionspoints, + $usersummary->allsessionsmaxpoints); $deltapoints = $usersummary->allsessionsmaxpoints - $usersummary->takensessionsmaxpoints; $usersummary->maxpossiblepoints = $usersummary->takensessionspoints + $deltapoints; - $usersummary->maxpossiblepercentage = attendance_calc_fraction($usersummary->maxpossiblepoints, $usersummary->allsessionsmaxpoints); + $usersummary->maxpossiblepercentage = attendance_calc_fraction($usersummary->maxpossiblepoints, + $usersummary->allsessionsmaxpoints); return $usersummary; } diff --git a/lib.php b/lib.php index eeb9d03..dad7d2f 100644 --- a/lib.php +++ b/lib.php @@ -250,7 +250,7 @@ function attendance_user_complete($course, $user, $mod, $attendance) { require_once($CFG->libdir.'/gradelib.php'); if (has_capability('mod/attendance:canbelisted', $mod->context, $user->id)) { - echo construct_full_user_stat_html_table($attendance, $course, $user, $mod); + echo construct_full_user_stat_html_table($attendance, $user); } } @@ -276,7 +276,7 @@ function attendance_grade_item_update($attendance, $grades=null) { if (!isset($attendance->courseid)) { $attendance->courseid = $attendance->course; } - if (! $course = $DB->get_record('course', array('id' => $attendance->course))) { + if (!$DB->get_record('course', array('id' => $attendance->course))) { error("Course is misconfigured"); } @@ -284,7 +284,6 @@ function attendance_grade_item_update($attendance, $grades=null) { $params = array('itemname' => $attendance->name, 'idnumber' => $attendance->cmidnumber); } else { // MDL-14303. - $cm = get_coursemodule_from_instance('attendance', $attendance->id); $params = array('itemname' => $attendance->name/*, 'idnumber'=>$attendance->id*/); } diff --git a/renderables.php b/renderables.php index e00a0f1..1131573 100644 --- a/renderables.php +++ b/renderables.php @@ -336,8 +336,6 @@ class attendance_user_data implements renderable { public $pageparams; - public $stat; - public $statuses; public $summary; @@ -361,7 +359,8 @@ class attendance_user_data implements renderable { if ($this->pageparams->mode == mod_attendance_view_page_params::MODE_THIS_COURSE) { $this->statuses = $att->get_statuses(true, true); - $this->summary = new mod_attendance_summary($att->id, array($userid), $att->pageparams->startdate, $att->pageparams->enddate); + $this->summary = new mod_attendance_summary($att->id, array($userid), $att->pageparams->startdate, + $att->pageparams->enddate); $this->filtercontrols = new attendance_filter_controls($att); @@ -378,8 +377,7 @@ class attendance_user_data implements renderable { unset($this->courseatts[$atid]); continue; } - $statuses = 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)); } } @@ -443,7 +441,8 @@ class attendance_report_data implements renderable { if ($att->pageparams->view == ATT_VIEW_SUMMARY) { $this->summary = new mod_attendance_summary($att->id); } else { - $this->summary = new mod_attendance_summary($att->id, array_keys($this->users), $att->pageparams->startdate, $att->pageparams->enddate); + $this->summary = new mod_attendance_summary($att->id, array_keys($this->users), + $att->pageparams->startdate, $att->pageparams->enddate); } foreach ($this->users as $key => $user) { diff --git a/renderer.php b/renderer.php index bbeb2ec..25868b3 100644 --- a/renderer.php +++ b/renderer.php @@ -302,8 +302,6 @@ class mod_attendance_renderer extends plugin_renderer_base { } protected function render_sess_manage_control(attendance_manage_data $sessdata) { - global $OUTPUT; - $table = new html_table(); $table->attributes['class'] = ' '; $table->width = '100%'; @@ -738,7 +736,8 @@ class mod_attendance_renderer extends plugin_renderer_base { if ($userdata->pageparams->mode == mod_attendance_view_page_params::MODE_THIS_COURSE) { $o .= html_writer::empty_tag('hr'); - $o .= construct_user_data_stat($userdata->summary->get_all_sessions_summary_for($userdata->user->id), $userdata->pageparams->view); + $o .= construct_user_data_stat($userdata->summary->get_all_sessions_summary_for($userdata->user->id), + $userdata->pageparams->view); $o .= $this->render_attendance_filter_controls($userdata->filtercontrols); diff --git a/renderhelpers.php b/renderhelpers.php index ab1be99..10f95de 100644 --- a/renderhelpers.php +++ b/renderhelpers.php @@ -232,12 +232,6 @@ function construct_session_full_date_time($datetime, $duration) { } function construct_user_data_stat($usersummary, $view) { - global $OUTPUT; - - if (empty($usersummary)) { - return 'no data'; - } - $stattable = new html_table(); $stattable->attributes['class'] = 'attlist'; $row = new html_table_row(); @@ -293,7 +287,7 @@ function construct_user_data_stat($usersummary, $view) { return html_writer::table($stattable); } -function construct_full_user_stat_html_table($attendance, $course, $user, $coursemodule) { +function construct_full_user_stat_html_table($attendance, $user) { $summary = new mod_attendance_summary($attendance->id, $user->id); return construct_user_data_stat($summary->get_all_sessions_summary_for($user->id), ATT_VIEW_ALL); }