diff --git a/components/plot/bar/graph.php b/components/plot/bar/graph.php index ebd3c20d..98f44ef9 100644 --- a/components/plot/bar/graph.php +++ b/components/plot/bar/graph.php @@ -31,12 +31,15 @@ // TODO check if this is correct should be int only? $id = required_param('id', PARAM_ALPHANUM); $reportid = required_param('reportid', PARAM_INT); +$courseid = optional_param('courseid', null, PARAM_INT); if (!$report = $DB->get_record('block_configurable_reports', ['id' => $reportid])) { throw new moodle_exception('reportdoesnotexists'); } -$courseid = $report->courseid; +if (!$courseid || !$report->global) { + $courseid = $report->courseid; +} if (!$course = $DB->get_record('course', ['id' => $courseid])) { throw new moodle_exception('No such course id'); diff --git a/components/plot/bar/plugin.class.php b/components/plot/bar/plugin.class.php index 6b6ec2d1..90fa7d24 100755 --- a/components/plot/bar/plugin.class.php +++ b/components/plot/bar/plugin.class.php @@ -108,7 +108,7 @@ public function execute($id, $data, $finalreport) { $graphdata = urlencode(json_encode($series)); return $CFG->wwwroot . '/blocks/configurable_reports/components/plot/bar/graph.php?reportid=' . $this->report->id . '&id=' . - $id . '&graphdata=' . $graphdata; + $id . '&graphdata=' . $graphdata . '&courseid='.$this->report->courseid; } /** diff --git a/components/plot/line/graph.php b/components/plot/line/graph.php index 05e76728..e90eaa7d 100755 --- a/components/plot/line/graph.php +++ b/components/plot/line/graph.php @@ -34,12 +34,15 @@ $id = required_param('id', PARAM_ALPHANUM); $reportid = required_param('reportid', PARAM_INT); +$courseid = optional_param('courseid', null, PARAM_INT); if (!$report = $DB->get_record('block_configurable_reports', ['id' => $reportid])) { throw new moodle_exception('reportdoesnotexists'); } -$courseid = $report->courseid; +if (!$courseid || !$report->global) { + $courseid = $report->courseid; +} if (!$course = $DB->get_record('course', ['id' => $courseid])) { throw new moodle_exception('No such course id'); diff --git a/components/plot/line/plugin.class.php b/components/plot/line/plugin.class.php index 17b2c352..da1685c9 100755 --- a/components/plot/line/plugin.class.php +++ b/components/plot/line/plugin.class.php @@ -93,7 +93,7 @@ public function execute($id, $data, $finalreport) { } return $CFG->wwwroot . '/blocks/configurable_reports/components/plot/line/graph.php?reportid=' . $this->report->id . - '&id=' . $id . $params . '&min=' . $minvalue . '&max=' . $maxvalue; + '&id=' . $id . $params . '&min=' . $minvalue . '&max=' . $maxvalue . '&courseid='.$this->report->courseid; } /** diff --git a/components/plot/pie/graph.php b/components/plot/pie/graph.php index dce59173..4be38e7b 100755 --- a/components/plot/pie/graph.php +++ b/components/plot/pie/graph.php @@ -33,12 +33,15 @@ $id = required_param('id', PARAM_ALPHANUM); $reportid = required_param('reportid', PARAM_INT); +$courseid = optional_param('courseid', null, PARAM_INT); if (!$report = $DB->get_record('block_configurable_reports', ['id' => $reportid])) { throw new moodle_exception('reportdoesnotexists'); } -$courseid = $report->courseid; +if (!$courseid || !$report->global) { + $courseid = $report->courseid; +} if (!$course = $DB->get_record('course', ['id' => $courseid])) { throw new moodle_exception("No such course id"); diff --git a/components/plot/pie/plugin.class.php b/components/plot/pie/plugin.class.php index 737343ab..1f13c7ae 100755 --- a/components/plot/pie/plugin.class.php +++ b/components/plot/pie/plugin.class.php @@ -148,7 +148,7 @@ public function execute($id, $data, $finalreport) { $colorpalette = base64_encode(implode(',', $colors)); return $CFG->wwwroot . '/blocks/configurable_reports/components/plot/pie/graph.php?reportid=' . $this->report->id . '&id=' . - $id . '&serie0=' . $serie0 . '&serie1=' . $serie1 . '&colorpalette=' . $colorpalette; + $id . '&serie0=' . $serie0 . '&serie1=' . $serie1 . '&colorpalette=' . $colorpalette . '&courseid='.$this->report->courseid; } /**