Skip to content

Commit

Permalink
Refactor for MOODLE41 & PHP 7.4
Browse files Browse the repository at this point in the history
  • Loading branch information
luukverhoeven committed Dec 11, 2023
1 parent 9a9cbf4 commit 64e568b
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion classes/github.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,4 @@ public function get(string $endpoint, array $params = [], array $options = []) {
return parent::get($repolink, $params, $options);
}

}
}
2 changes: 1 addition & 1 deletion components/calcs/percent/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ public function definition(): void {
$this->add_action_buttons(true, get_string('add'));
}

}
}
2 changes: 1 addition & 1 deletion components/cohorts/plugin.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function execute($finalelements, $data) {
return [$filtercohorts];
}

// Example https://gist.github.com/luukverhoeven/aac43e35cb7199057d5592c90d5cde4c
// Example https://gist.github.com/luukverhoeven/aac43e35cb7199057d5592c90d5cde4c.
if (preg_match("/%%FILTER_COHORTS:([^%]+)%%/i", $finalelements, $output)) {
$replace = ' AND ' . $output[1] . ' = ' . $filtercohorts;

Expand Down
13 changes: 9 additions & 4 deletions components/plot/bar/plugin.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,19 @@ public function execute($id, $data, $finalreport) {
$value = $r[$idx];

if ($idx == $labelidx) {
error_log("moodle:configurable_reports:bar: refusing to chart label field");
debugging(
"moodle:configurable_reports:bar: refusing to chart label field",
DEBUG_DEVELOPER
);
continue;
}

if (!is_numeric($value)) {
// Can't just skip. That would throw off the indexes if a column has bad values in some but not all rows.
error_log("moodle:configurable_reports:bar: substituting 0 for non-numeric value '$value'");
debugging(
"moodle:configurable_reports:bar: substituting 0 for non-numeric value '$value'",
DEBUG_DEVELOPER
);
$value = 0;
}

Expand All @@ -108,10 +114,9 @@ public function execute($id, $data, $finalreport) {
/**
* Get series
*
* @param $data
* @return array
*/
public function get_series($data): array {
public function get_series(): array {
$graphdataraw = required_param('graphdata', PARAM_RAW);
$graphdata = json_decode(urldecode($graphdataraw), false, 512, JSON_THROW_ON_ERROR);

Expand Down
2 changes: 1 addition & 1 deletion components/plot/pie/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public function definition(): void {
* @return array of "element_name"=>"error_description" if there are errors,
* or an empty array if everything is OK (true allowed for backwards compatibility too).
*/
function validation($data, $files): array {
public function validation($data, $files): array {
$errors = [];

$length = count($data['piechart_label']);
Expand Down
2 changes: 1 addition & 1 deletion db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,4 @@ function xmldb_block_configurable_reports_upgrade($oldversion) {
}

return true;
}
}
2 changes: 1 addition & 1 deletion export/json/export.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ function export_report($report) {
header('Content-type: application/json');
echo json_encode($json);
exit;
}
}
3 changes: 2 additions & 1 deletion reports/sql/report.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die;
defined('BLOCK_CONFIGURABLE_REPORTS_MAX_RECORDS') || define('BLOCK_CONFIGURABLE_REPORTS_MAX_RECORDS', 5000);

/**
Expand Down Expand Up @@ -119,7 +120,7 @@ public function execute_query($sql) {
$sql = preg_replace('/\bprefix_(?=\w+)/i', $CFG->prefix, $sql);

$reportlimit = get_config('block_configurable_reports', 'reportlimit');
if (empty($reportlimit) or $reportlimit == '0') {
if (empty($reportlimit) || $reportlimit == '0') {
$reportlimit = BLOCK_CONFIGURABLE_REPORTS_MAX_RECORDS;
}

Expand Down
2 changes: 1 addition & 1 deletion reports/timeline/report.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function get_all_elements(): array {
$filterstarttime = optional_param('filter_starttime', 0, PARAM_RAW);
$filterendtime = optional_param('filter_endtime', 0, PARAM_RAW);

if ($filterstarttime and $filterendtime) {
if ($filterstarttime && $filterendtime) {
$filterstarttime = make_timestamp($filterstarttime['year'], $filterstarttime['month'], $filterstarttime['day']);
$filterendtime = make_timestamp($filterendtime['year'], $filterendtime['month'], $filterendtime['day']);

Expand Down

0 comments on commit 64e568b

Please sign in to comment.