Differences Between: [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * Log report renderer. 19 * 20 * @package report_log 21 * @copyright 2014 Rajesh Taneja <rajesh.taneja@gmail.com> 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 defined('MOODLE_INTERNAL') || die; 25 26 /** 27 * Report log renderer's for printing reports. 28 * 29 * @package report_log 30 * @copyright 2014 Rajesh Taneja <rajesh.taneja@gmail.com> 31 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 32 */ 33 class report_log_renderer extends plugin_renderer_base { 34 35 /** 36 * This method should never be manually called, it should only be called by process. 37 * 38 * @deprecated since 2.8, to be removed in 2.9 39 * @param report_log_renderable $reportlog 40 * @return string 41 */ 42 public function render_report_log_renderable(report_log_renderable $reportlog) { 43 debugging('Do not call this method. Please call $renderer->render($reportlog) instead.', DEBUG_DEVELOPER); 44 return $this->render($reportlog); 45 } 46 47 /** 48 * Render log report page. 49 * 50 * @param report_log_renderable $reportlog object of report_log. 51 */ 52 protected function render_report_log(report_log_renderable $reportlog) { 53 if (empty($reportlog->selectedlogreader)) { 54 echo $this->output->notification(get_string('nologreaderenabled', 'report_log'), 'notifyproblem'); 55 return; 56 } 57 if ($reportlog->showselectorform) { 58 $this->report_selector_form($reportlog); 59 } 60 61 if ($reportlog->showreport) { 62 $reportlog->tablelog->out($reportlog->perpage, true); 63 } 64 } 65 66 /** 67 * Prints/return reader selector 68 * 69 * @param report_log_renderable $reportlog log report. 70 */ 71 public function reader_selector(report_log_renderable $reportlog) { 72 $readers = $reportlog->get_readers(true); 73 if (empty($readers)) { 74 $readers = array(get_string('nologreaderenabled', 'report_log')); 75 } 76 $url = fullclone ($reportlog->url); 77 $url->remove_params(array('logreader')); 78 $select = new single_select($url, 'logreader', $readers, $reportlog->selectedlogreader, null); 79 $select->set_label(get_string('selectlogreader', 'report_log')); 80 echo $this->output->render($select); 81 } 82 83 /** 84 * This function is used to generate and display selector form 85 * 86 * @param report_log_renderable $reportlog log report. 87 */ 88 public function report_selector_form(report_log_renderable $reportlog) { 89 echo html_writer::start_tag('form', array('class' => 'logselecform', 'action' => $reportlog->url, 'method' => 'get')); 90 echo html_writer::start_div(); 91 echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'chooselog', 'value' => '1')); 92 echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'showusers', 'value' => $reportlog->showusers)); 93 echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'showcourses', 94 'value' => $reportlog->showcourses)); 95 96 $selectedcourseid = empty($reportlog->course) ? 0 : $reportlog->course->id; 97 98 // Add course selector. 99 $sitecontext = context_system::instance(); 100 $courses = $reportlog->get_course_list(); 101 if (!empty($courses) && $reportlog->showcourses) { 102 echo html_writer::label(get_string('selectacourse'), 'menuid', false, array('class' => 'accesshide')); 103 echo html_writer::select($courses, "id", $selectedcourseid, null); 104 } else { 105 $courses = array(); 106 $courses[$selectedcourseid] = get_course_display_name_for_list($reportlog->course) . (($selectedcourseid == SITEID) ? 107 ' (' . get_string('site') . ') ' : ''); 108 echo html_writer::label(get_string('selectacourse'), 'menuid', false, array('class' => 'accesshide')); 109 echo html_writer::select($courses, "id", $selectedcourseid, false); 110 // Check if user is admin and this came because of limitation on number of courses to show in dropdown. 111 if (has_capability('report/log:view', $sitecontext)) { 112 $a = new stdClass(); 113 $a->url = new moodle_url('/report/log/index.php', array('chooselog' => 0, 114 'group' => $reportlog->get_selected_group(), 'user' => $reportlog->userid, 115 'id' => $selectedcourseid, 'date' => $reportlog->date, 'modid' => $reportlog->modid, 116 'showcourses' => 1, 'showusers' => $reportlog->showusers)); 117 $a->url = $a->url->out(false); 118 print_string('logtoomanycourses', 'moodle', $a); 119 } 120 } 121 122 // Add group selector. 123 $groups = $reportlog->get_group_list(); 124 if (!empty($groups)) { 125 echo html_writer::label(get_string('selectagroup'), 'menugroup', false, array('class' => 'accesshide')); 126 echo html_writer::select($groups, "group", $reportlog->groupid, get_string("allgroups")); 127 } 128 129 // Add user selector. 130 $users = $reportlog->get_user_list(); 131 132 if ($reportlog->showusers) { 133 echo html_writer::label(get_string('selctauser'), 'menuuser', false, array('class' => 'accesshide')); 134 echo html_writer::select($users, "user", $reportlog->userid, get_string("allparticipants")); 135 } else { 136 $users = array(); 137 if (!empty($reportlog->userid)) { 138 $users[$reportlog->userid] = $reportlog->get_selected_user_fullname(); 139 } else { 140 $users[0] = get_string('allparticipants'); 141 } 142 echo html_writer::label(get_string('selctauser'), 'menuuser', false, array('class' => 'accesshide')); 143 echo html_writer::select($users, "user", $reportlog->userid, false); 144 $a = new stdClass(); 145 $a->url = new moodle_url('/report/log/index.php', array('chooselog' => 0, 146 'group' => $reportlog->get_selected_group(), 'user' => $reportlog->userid, 147 'id' => $selectedcourseid, 'date' => $reportlog->date, 'modid' => $reportlog->modid, 148 'showusers' => 1, 'showcourses' => $reportlog->showcourses)); 149 $a->url = $a->url->out(false); 150 echo html_writer::start_span('mx-1'); 151 print_string('logtoomanyusers', 'moodle', $a); 152 echo html_writer::end_span(); 153 } 154 155 // Add date selector. 156 $dates = $reportlog->get_date_options(); 157 echo html_writer::label(get_string('date'), 'menudate', false, array('class' => 'accesshide')); 158 echo html_writer::select($dates, "date", $reportlog->date, get_string("alldays")); 159 160 // Add activity selector. 161 $activities = $reportlog->get_activities_list(); 162 echo html_writer::label(get_string('activities'), 'menumodid', false, array('class' => 'accesshide')); 163 echo html_writer::select($activities, "modid", $reportlog->modid, get_string("allactivities")); 164 165 // Add actions selector. 166 echo html_writer::label(get_string('actions'), 'menumodaction', false, array('class' => 'accesshide')); 167 echo html_writer::select($reportlog->get_actions(), 'modaction', $reportlog->action, get_string("allactions")); 168 169 // Add origin. 170 $origin = $reportlog->get_origin_options(); 171 echo html_writer::label(get_string('origin', 'report_log'), 'menuorigin', false, array('class' => 'accesshide')); 172 echo html_writer::select($origin, 'origin', $reportlog->origin, false); 173 174 // Add edulevel. 175 $edulevel = $reportlog->get_edulevel_options(); 176 echo html_writer::label(get_string('edulevel'), 'menuedulevel', false, array('class' => 'accesshide')); 177 echo html_writer::select($edulevel, 'edulevel', $reportlog->edulevel, false).$this->help_icon('edulevel'); 178 179 // Add reader option. 180 // If there is some reader available then only show submit button. 181 $readers = $reportlog->get_readers(true); 182 if (!empty($readers)) { 183 if (count($readers) == 1) { 184 $attributes = array('type' => 'hidden', 'name' => 'logreader', 'value' => key($readers)); 185 echo html_writer::empty_tag('input', $attributes); 186 } else { 187 echo html_writer::label(get_string('selectlogreader', 'report_log'), 'menureader', false, 188 array('class' => 'accesshide')); 189 echo html_writer::select($readers, 'logreader', $reportlog->selectedlogreader, false); 190 } 191 echo html_writer::empty_tag('input', array('type' => 'submit', 'value' => get_string('gettheselogs'), 192 'class' => 'btn btn-secondary')); 193 } 194 echo html_writer::end_div(); 195 echo html_writer::end_tag('form'); 196 } 197 } 198
title
Description
Body
title
Description
Body
title
Description
Body
title
Body