Skip to content

Commit

Permalink
Merge pull request #231 from marcelorhmaia/MOODLE_36_STABLE
Browse files Browse the repository at this point in the history
Fixes #147
  • Loading branch information
jleyva authored Oct 3, 2024
2 parents 9c6ecbc + 97347a6 commit 133a93c
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 6 deletions.
5 changes: 4 additions & 1 deletion components/plot/bar/graph.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion components/plot/bar/plugin.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
5 changes: 4 additions & 1 deletion components/plot/line/graph.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion components/plot/line/plugin.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
5 changes: 4 additions & 1 deletion components/plot/pie/graph.php
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion components/plot/pie/plugin.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down

0 comments on commit 133a93c

Please sign in to comment.