[ Index ]

PHP Cross Reference of moodle-2.8

title

Body

[close]

/report/courseoverview/ -> reportsgraph.php (source)

   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   * Graph
  19   *
  20   * @package    report
  21   * @subpackage courseoverview
  22   * @copyright  1999 onwards Martin Dougiamas  {@link http://moodle.com}
  23   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  24   */
  25  
  26  require_once('../../config.php');
  27  require_once($CFG->dirroot.'/lib/statslib.php');
  28  require_once($CFG->dirroot.'/lib/graphlib.php');
  29  
  30  $report     = required_param('report', PARAM_INT);
  31  $time       = required_param('time', PARAM_INT);
  32  $numcourses = required_param('numcourses', PARAM_INT);
  33  
  34  require_login();
  35  
  36  require_capability('report/courseoverview:view', context_system::instance());
  37  
  38  stats_check_uptodate();
  39  
  40  $param = stats_get_parameters($time,$report,SITEID,STATS_MODE_RANKED);
  41  
  42  if (!empty($param->sql)) {
  43      $sql = $param->sql;
  44  } else {
  45      $sql = "SELECT courseid, $param->fields
  46                FROM {".'stats_'.$param->table."}
  47               WHERE timeend >= $param->timeafter AND stattype = 'activity' AND roleid = 0
  48            GROUP BY courseid
  49                     $param->extras
  50            ORDER BY $param->orderby";
  51  }
  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      print_error('statsnodata', 'error', $PAGE->url->out());
  58  }
  59  
  60  
  61  $graph = new graph(750,400);
  62  
  63  $graph->parameter['legend'] = 'outside-right';
  64  $graph->parameter['legend_size'] = 10;
  65  $graph->parameter['x_axis_angle'] = 90;
  66  $graph->parameter['title'] = false; // moodle will do a nicer job.
  67  $graph->y_tick_labels = null;
  68  $graph->offset_relation = null;
  69  if ($report != STATS_REPORT_ACTIVE_COURSES) {
  70      $graph->parameter['y_decimal_left'] = 2;
  71  }
  72  
  73  foreach ($courses as $c) {
  74      $graph->x_data[] = $DB->get_field('course', 'shortname', array('id'=>$c->courseid));
  75      $graph->y_data['bar1'][] = $c->{$param->graphline};
  76  }
  77  $graph->y_order = array('bar1');
  78  $graph->y_format['bar1'] = array('colour' => 'blue','bar' => 'fill','legend' => $param->{$param->graphline});
  79  
  80  $graph->draw_stack();


Generated: Fri Nov 28 20:29:05 2014 Cross-referenced by PHPXref 0.7.1