See Release Notes
Long Term Support Release
Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 400 and 401]
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 * This file contains functions used by the course overview report. 19 * 20 * @package report_courseoverview 21 * @copyright 2016 Simey Lameze <simey@moodle.com> 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 defined('MOODLE_INTERNAL') || die; 25 26 require_once('../../config.php'); 27 require_once($CFG->dirroot . '/lib/statslib.php'); 28 29 /** 30 * Gather course overview data and print the chart. 31 * 32 * @param int $report represents the report type field on the course overview report filter. 33 * @param int $time represents the time period field on the course overview report filter. 34 * @param int $numcourses represents the number of courses field on the course overview report filter. 35 * @return void 36 */ 37 function report_courseoverview_print_chart($report, $time, $numcourses) { 38 global $DB, $OUTPUT, $PAGE; 39 40 $param = stats_get_parameters($time, $report, SITEID, STATS_MODE_RANKED); 41 if (!empty($param->sql)) { 42 $sql = $param->sql; 43 } else { 44 $sql = "SELECT courseid, $param->fields 45 FROM {" . 'stats_' . $param->table . "} 46 WHERE timeend >= $param->timeafter 47 AND stattype = 'activity' 48 AND roleid = 0 49 GROUP BY courseid 50 $param->extras 51 ORDER BY $param->orderby"; 52 } 53 $courses = $DB->get_records_sql($sql, $param->params, 0, $numcourses); 54 55 if (empty($courses)) { 56 $PAGE->set_url('/report/courseoverview/index.php'); 57 throw new \moodle_exception('statsnodata', 'error', $PAGE->url->out()); 58 } 59 60 $data = []; 61 $i = 0; 62 foreach ($courses as $c) { 63 $data['labels'][$i] = $DB->get_field('course', 'shortname', array('id' => $c->courseid)); 64 65 // Line3 represents the third column of the report table except for the most active users report. 66 // It is a float number and can be participation radio or activity per user. 67 if (isset($c->line3)) { 68 $data['series'][$i] = round($c->line3, 2); 69 } else { 70 $data['series'][$i] = $c->{$param->graphline}; 71 } 72 $i++; 73 } 74 75 $chart = new \core\chart_bar(); 76 $series = new \core\chart_series($param->{$param->graphline}, $data['series']); 77 $chart->add_series($series); 78 $chart->set_labels($data['labels']); 79 80 echo $OUTPUT->render($chart); 81 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body