|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 // This file is part of Moodle - http://moodle.org/ 00003 // 00004 // Moodle is free software: you can redistribute it and/or modify 00005 // it under the terms of the GNU General Public License as published by 00006 // the Free Software Foundation, either version 3 of the License, or 00007 // (at your option) any later version. 00008 // 00009 // Moodle is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00016 00026 require_once('../../config.php'); 00027 require_once($CFG->dirroot.'/lib/statslib.php'); 00028 require_once($CFG->dirroot.'/lib/graphlib.php'); 00029 00030 $report = required_param('report', PARAM_INT); 00031 $time = required_param('time', PARAM_INT); 00032 $numcourses = required_param('numcourses', PARAM_INT); 00033 00034 require_login(); 00035 00036 require_capability('report/courseoverview:view', get_context_instance(CONTEXT_SYSTEM)); 00037 00038 stats_check_uptodate(); 00039 00040 $param = stats_get_parameters($time,$report,SITEID,STATS_MODE_RANKED); 00041 00042 if (!empty($param->sql)) { 00043 $sql = $param->sql; 00044 } else { 00045 $sql = "SELECT courseid, $param->fields 00046 FROM {".'stats_'.$param->table."} 00047 WHERE timeend >= $param->timeafter AND stattype = 'activity' AND roleid = 0 00048 GROUP BY courseid 00049 $param->extras 00050 ORDER BY $param->orderby"; 00051 } 00052 00053 $courses = $DB->get_records_sql($sql, $param->params, 0, $numcourses); 00054 00055 if (empty($courses)) { 00056 $PAGE->set_url('/report/courseoverview/index.php'); 00057 print_error('statsnodata', 'error', $PAGE->url->out()); 00058 } 00059 00060 00061 $graph = new graph(750,400); 00062 00063 $graph->parameter['legend'] = 'outside-right'; 00064 $graph->parameter['legend_size'] = 10; 00065 $graph->parameter['x_axis_angle'] = 90; 00066 $graph->parameter['title'] = false; // moodle will do a nicer job. 00067 $graph->y_tick_labels = null; 00068 $graph->offset_relation = null; 00069 if ($report != STATS_REPORT_ACTIVE_COURSES) { 00070 $graph->parameter['y_decimal_left'] = 2; 00071 } 00072 00073 foreach ($courses as $c) { 00074 $graph->x_data[] = $DB->get_field('course', 'shortname', array('id'=>$c->courseid)); 00075 $graph->y_data['bar1'][] = $c->{$param->graphline}; 00076 } 00077 $graph->y_order = array('bar1'); 00078 $graph->y_format['bar1'] = array('colour' => 'blue','bar' => 'fill','legend' => $param->{$param->graphline}); 00079 00080 $graph->draw_stack();