public function __construct()
 {
     global $DB;
     parent::__construct(get_string('gradedistributionbar', 'gradereport_visual'));
     $this->layout = visualization::LAYOUT_AXIS;
     $this->layoutsettings = null;
     //array('false', 'true');
     $this->nodeshape = visualization::SHAPE_VERTICAL_BAR;
     $this->xaxis = 'grade';
     $this->yaxis = 'students';
     $this->xaxislabelformat = '0\\%';
     //$this->xaxismax = 100 + grade_distribution::RANGE;
     //$this->xaxismin = grade_distribution::RANGE;
     $this->xaxisxoffset = -27;
     $this->xaxislabel = get_string('grade', 'gradereport_visual');
     if ($this->percent) {
         $this->yaxislabelformat = '0\\%';
         $this->yaxislabel = get_string('percentstudents', 'gradereport_visual');
     } else {
         $this->yaxislabel = get_string('numberstudents', 'gradereport_visual');
     }
     $this->title = get_string('gradedistribution:title', 'gradereport_visual');
     $this->capability = 'gradereport/visual:vis:grade_distribution_bar';
     $this->usegroups = true;
     $options = array();
     foreach (groups_get_all_groups(required_param('id')) as $groupkey => $group) {
         $options[$groupkey] = grade_report_visual::truncate($group->name);
     }
     $options[0] = 'All Groups';
     if (isset($DB) && !is_null($DB)) {
         $course = $DB->get_record('course', array('id' => required_param('id')));
     } else {
         $course = get_record('course', 'id', required_param('id'));
     }
     if (!$course) {
         print_error('nocourseid');
     }
     $active = groups_get_course_group($course, true);
     if (!$active) {
         $active = 0;
     }
     $this->selector = new selector('group', $options, $active);
     $this->selectors = array($this->selector);
     $this->colorencoder = new encoder(encoder::ENCODER_COLOR, 'item');
     $this->encoders = array($this->colorencoder);
     $this->itemlegend = new legend($this->colorencoder, array(get_string('coursetotal', 'grades')));
     $this->legends = array($this->itemlegend);
 }
 public function __construct()
 {
     global $DB;
     parent::__construct(get_string('gradedistributiongroupbar', 'gradereport_visual'));
     $this->layout = visualization::LAYOUT_AXIS;
     $this->layoutsettings = array('false', 'true');
     $this->nodeshape = visualization::SHAPE_VERTICAL_BAR;
     $this->xaxis = 'grade';
     $this->yaxis = 'students';
     $this->xaxislabelformat = '0\\%';
     $this->xaxisxoffset = -27;
     $this->xaxislabel = get_string('grade', 'gradereport_visual');
     if ($this->percent) {
         $this->yaxislabelformat = '0\\%';
         $this->yaxislabel = get_string('percentstudents', 'gradereport_visual');
     } else {
         $this->yaxislabel = get_string('numberstudents', 'gradereport_visual');
     }
     $this->title = get_string('gradedistribution:title', 'gradereport_visual');
     $this->capability = 'gradereport/visual:vis:grade_distribution_group_bar';
     $courseid = required_param('id');
     $options = array();
     $items = grade_item::fetch_all(array('courseid' => $courseid));
     foreach ($items as $item) {
         if (count($item->get_final()) > 0) {
             $options[$item->id] = grade_report_visual::truncate($item->get_name());
         }
     }
     $options['ai'] = 'All Items';
     $this->selector = new selector('item', $options, 'ai');
     $this->selectors = array($this->selector);
     $this->colorencoder = new encoder(encoder::ENCODER_COLOR, 'group');
     $this->encoders = array($this->colorencoder);
     $this->grouplegend = new legend($this->colorencoder);
     $this->legends = array($this->grouplegend);
 }