Skip to content

Commit

Permalink
Fixes jleyva#147
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelorhmaia authored and michael-milette committed Apr 25, 2024
1 parent 452bff0 commit 9d371d8
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 @@ -29,12 +29,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', array('id' => $reportid))) {
print_error('reportdoesnotexists');
}

$courseid = $report->courseid;
if (!$courseid || !$report->global) {
$courseid = $report->courseid;
}

if (!$course = $DB->get_record('course', array('id' => $courseid))) {
print_error('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 @@ -74,7 +74,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;
return $CFG->wwwroot.'/blocks/configurable_reports/components/plot/bar/graph.php?reportid='.$this->report->id.'&courseid='.$this->report->courseid.'&id='.$id.'&graphdata='.$graphdata;
}

public function get_series($data) {
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 @@ -32,12 +32,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', array('id' => $reportid))) {
print_error('reportdoesnotexists');
}

$courseid = $report->courseid;
if (!$courseid || !$report->global) {
$courseid = $report->courseid;
}

if (!$course = $DB->get_record('course', array('id' => $courseid))) {
print_error('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 @@ -67,7 +67,7 @@ public function execute($id, $data, $finalreport) {
$i++;
}

return $CFG->wwwroot.'/blocks/configurable_reports/components/plot/line/graph.php?reportid='.$this->report->id.'&id='.$id.$params.'&min='.$minvalue.'&max='.$maxvalue;
return $CFG->wwwroot.'/blocks/configurable_reports/components/plot/line/graph.php?reportid='.$this->report->id.'&courseid='.$this->report->courseid.'&id='.$id.$params.'&min='.$minvalue.'&max='.$maxvalue;
}

public function get_series($data) {
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 @@ -32,12 +32,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', array('id' => $reportid))) {
print_error('reportdoesnotexists');
}

$courseid = $report->courseid;
if (!$courseid || !$report->global) {
$courseid = $report->courseid;
}

if (!$course = $DB->get_record('course', array('id' => $courseid))) {
print_error("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 @@ -118,7 +118,7 @@ public function execute($id, $data, $finalreport) {
$serie1 = base64_encode(implode(',', $serie1sorted));
$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;
return $CFG->wwwroot.'/blocks/configurable_reports/components/plot/pie/graph.php?reportid='.$this->report->id.'&courseid='.$this->report->courseid.'&id='.$id.'&serie0='.$serie0.'&serie1='.$serie1.'&colorpalette='.$colorpalette;
}

public function get_series($data) {
Expand Down

0 comments on commit 9d371d8

Please sign in to comment.