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); }
$visid = optional_param('visid'); /// basic access checks if (isset($DB) && !is_null($DB)) { $course = $DB->get_record('course', array('id' => $courseid)); } else { $course = get_record('course', 'id', $courseid); } if (!$course) { print_error('nocourseid'); } require_login($course); $context = get_context_instance(CONTEXT_COURSE, $course->id); require_capability('gradereport/visual:view', $context); /// get tracking object $gpr = new grade_plugin_return(array('type' => 'report', 'plugin' => 'visual', 'courseid' => $courseid)); $report = new grade_report_visual($courseid, $gpr, $context, $visid); /// Make sure the user is allowed see this visualization require_capability(grade_report_visual::get_visualization($report->visid, $context)->capability, $context); grade_regrade_final_grades($courseid); /// Turn of error reporting as hummans will not be seeing /// this and it will be read by the front end. Notices and /// warnings will break the format and stop the /// front end from working. error_reporting(0); /// Get report object $report->load_users(); $report->harvest_data(); $report->report_data(); $report->adapt_data(); /// Clean up cookie if it was created. if ($cookiewasset) {
/// basic access checks if (isset($DB) && !is_null($DB)) { $course = $DB->get_record('course', array('id' => $courseid)); } else { $course = get_record('course', 'id', $courseid); } if (!$course) { print_error('nocourseid'); } require_login($course); $context = get_context_instance(CONTEXT_COURSE, $course->id); require_capability('gradereport/visual:view', $context); /// get tracking object $gpr = new grade_plugin_return(array('type' => 'report', 'plugin' => 'visual', 'courseid' => $courseid)); /// get the visual report object. $report = new grade_report_visual($courseid, $gpr, $context, $visid); /// make sure the user is allowed to view the selected visualization. require_capability(grade_report_visual::get_visualization($report->visid, $context)->capability, $context); /// last selected report session tracking if (!isset($USER->grade_last_report)) { $USER->grade_last_report = array(); } $USER->grade_last_report[$course->id] = 'visual'; $reportname = get_string('modulename', 'gradereport_stats'); /// Print report echo '<html><title>' . $reportname . ' for ' . $course->shortname . '</title><body>'; echo '<div style="font-size:25px; text-align:center; font-weight:bold">' . $course->fullname . ': ' . $reportname . '</div>'; echo '<div style="text-align:center;">' . userdate(time()) . '</div>'; echo '<br/><br/>'; $report->adapt_html(true); echo '</body></html>';
require_once $CFG->libdir . '/phpxml/xml.php'; $visname = required_param('visid'); $courseid = required_param('id'); /// basic access checks if (isset($DB) && !is_null($DB)) { $course = $DB->get_record('course', array('id' => $courseid)); } else { $course = get_record('course', 'id', $courseid); } if (!$course) { print_error('nocourseid'); } require_login($course); $context = get_context_instance(CONTEXT_COURSE, $course->id); require_capability('gradereport/visual:view', $context); $vis = grade_report_visual::get_visualization($visname, $context); /// Make sure the user is allowed see this visualization require_capability($vis->capability, $context); /// Turn of error reporting as hummans will not be seeing /// this and it will be read by the front end. Notices and /// warnings will break the XML format and stop the /// front end from working. error_reporting(0); /// Define array that repersents the XML output from the /// visualization class selected. $settings = array(); $settings['visualization'] = array(); $settings['visualization']['name'] = $vis->name; $settings['visualization']['classname'] = get_class($vis); $settings['visualization']['layout'] = array(); $settings['visualization']['layout']['type'] = $vis->layout;
/** * Returns the current visualizations being used in the report * or if none are set, it returns the them as whould be loaded * by load_visualizations. * @param object $context the context to use for checking if a user has access to view a visualization. * @returns array array of classes that extend visualization */ public function get_visualizations($context = null) { if (!isset(grade_report_visual::$visualizations) || is_null(grade_report_visual::$visualizations) || empty(grade_report_visual::$visualizations)) { return grade_report_visual::load_visualizations(true, $context); } else { return grade_report_visual::$visualizations; } }