From 0911db7ed421340b1799fef9ca26a7a3bf24dd44 Mon Sep 17 00:00:00 2001 From: PMKuipers Date: Fri, 25 Aug 2023 12:04:27 +0200 Subject: [PATCH] Moodle code style fixes part 7 --- classes/aggregator.php | 2 + classes/associationservice.php | 1 + classes/badgeinfo.php | 2 + classes/cascadecohortsync.php | 6 +- classes/cascadeusersync.php | 6 +- classes/completion.php | 2 + classes/completionscanner.php | 2 + classes/contextinfo.php | 1 + classes/corecompletioninfo.php | 6 +- classes/courseinfo.php | 2 + classes/coursemoduleinfo.php | 2 + classes/courseservice.php | 2 + classes/gradeinfo.php | 2 + classes/gradingscanner.php | 2 + .../local/aggregators/bistate_aggregator.php | 1 + classes/local/aggregators/core_aggregator.php | 1 + .../local/aggregators/tristate_aggregator.php | 1 + classes/local/gradegenerator.php | 1 + classes/local/helpers/debugger.php | 68 ------------------- classes/local/helpers/webservicehelper.php | 1 + .../local/ungradedscanners/assign_scanner.php | 1 + .../local/ungradedscanners/quiz_scanner.php | 1 + .../local/ungradedscanners/scanner_base.php | 2 + classes/period.php | 1 + classes/privacy/provider.php | 2 + classes/reportinvite_form.php | 8 ++- classes/studentstudyplanservice.php | 2 + classes/studyitem.php | 2 + classes/studyitemconnection.php | 2 + classes/studyline.php | 2 + classes/studyplan.php | 1 + classes/studyplanpage.php | 1 + classes/studyplanservice.php | 2 + classes/success.php | 1 + classes/task/autocohortsync.php | 2 + classes/task/refreshteacherlist.php | 2 + classes/teachingfinder.php | 1 + 37 files changed, 67 insertions(+), 77 deletions(-) delete mode 100644 classes/local/helpers/debugger.php diff --git a/classes/aggregator.php b/classes/aggregator.php index 94d39b7..ed74121 100644 --- a/classes/aggregator.php +++ b/classes/aggregator.php @@ -21,6 +21,8 @@ */ namespace local_treestudyplan; +defined('MOODLE_INTERNAL') || die(); + require_once($CFG->libdir.'/externallib.php'); abstract class aggregator { diff --git a/classes/associationservice.php b/classes/associationservice.php index b185014..e4f2378 100644 --- a/classes/associationservice.php +++ b/classes/associationservice.php @@ -21,6 +21,7 @@ */ namespace local_treestudyplan; +defined('MOODLE_INTERNAL') || die(); use local_treestudyplan\local\helpers\webservicehelper; diff --git a/classes/badgeinfo.php b/classes/badgeinfo.php index 3bbcd16..182fc39 100644 --- a/classes/badgeinfo.php +++ b/classes/badgeinfo.php @@ -21,6 +21,8 @@ */ namespace local_treestudyplan; +defined('MOODLE_INTERNAL') || die(); + require_once($CFG->libdir.'/externallib.php'); class badgeinfo { diff --git a/classes/cascadecohortsync.php b/classes/cascadecohortsync.php index cea7782..7c8440f 100644 --- a/classes/cascadecohortsync.php +++ b/classes/cascadecohortsync.php @@ -21,6 +21,8 @@ */ namespace local_treestudyplan; +defined('MOODLE_INTERNAL') || die(); + require_once($CFG->libdir.'/externallib.php'); use \local_treestudyplan\studyplan; @@ -30,7 +32,7 @@ class cascadecohortsync { private $studyplan; private $studyplanid; - function __construct(studyplan $studyplan) { + public function __construct(studyplan $studyplan) { $this->studyplan = $studyplan; $this->studyplanid = $studyplan->id(); } @@ -65,7 +67,7 @@ class cascadecohortsync { return $groupid; } - function sync() { + public function sync() { global $DB; /* Explainer: diff --git a/classes/cascadeusersync.php b/classes/cascadeusersync.php index f663da4..fcb6e9f 100644 --- a/classes/cascadeusersync.php +++ b/classes/cascadeusersync.php @@ -21,6 +21,8 @@ */ namespace local_treestudyplan; +defined('MOODLE_INTERNAL') || die(); + require_once($CFG->libdir.'/externallib.php'); use \local_treestudyplan\studyplan; @@ -29,11 +31,11 @@ class cascadeusersync { private const METHOD = "manual"; private $studyplan; - function __construct(studyplan $studyplan) { + public function __construct(studyplan $studyplan) { $this->studyplan = $studyplan; } - function sync() { + public function sync() { global $DB; /* Explainer: diff --git a/classes/completion.php b/classes/completion.php index 89cdb8b..db21ff4 100644 --- a/classes/completion.php +++ b/classes/completion.php @@ -21,6 +21,8 @@ */ namespace local_treestudyplan; +defined('MOODLE_INTERNAL') || die(); + require_once($CFG->libdir.'/externallib.php'); class completion { diff --git a/classes/completionscanner.php b/classes/completionscanner.php index fd51db7..5981ab5 100644 --- a/classes/completionscanner.php +++ b/classes/completionscanner.php @@ -21,6 +21,8 @@ */ namespace local_treestudyplan; +defined('MOODLE_INTERNAL') || die(); + require_once($CFG->libdir.'/externallib.php'); use \grade_item; diff --git a/classes/contextinfo.php b/classes/contextinfo.php index dafd00c..7819767 100644 --- a/classes/contextinfo.php +++ b/classes/contextinfo.php @@ -21,6 +21,7 @@ */ namespace local_treestudyplan; +defined('MOODLE_INTERNAL') || die(); class contextinfo { public $context; diff --git a/classes/corecompletioninfo.php b/classes/corecompletioninfo.php index 98e9869..d359c2d 100644 --- a/classes/corecompletioninfo.php +++ b/classes/corecompletioninfo.php @@ -21,6 +21,8 @@ */ namespace local_treestudyplan; +defined('MOODLE_INTERNAL') || die(); + require_once($CFG->libdir.'/externallib.php'); require_once($CFG->libdir.'/gradelib.php'); require_once($CFG->dirroot.'/course/lib.php'); @@ -523,7 +525,7 @@ class corecompletioninfo { * @return null|float The percentage, or null if completion is not supported in the course, * or there are no activities that support completion. */ - function get_progress_percentage($userid) { + public function get_progress_percentage($userid) { // First, let's make sure completion is enabled. if (!$this->completion->is_enabled()) { @@ -578,7 +580,7 @@ class corecompletioninfo { * @return null|\stdClass The percentage, or null if completion is not supported in the course, * or there are no activities that support completion. */ - function get_advanced_progress_percentage($userid):\stdClass { + public function get_advanced_progress_percentage($userid):\stdClass { // First, let's make sure completion is enabled. if (!$this->completion->is_enabled()) { diff --git a/classes/courseinfo.php b/classes/courseinfo.php index c24b30e..ce22535 100644 --- a/classes/courseinfo.php +++ b/classes/courseinfo.php @@ -21,6 +21,8 @@ */ namespace local_treestudyplan; +defined('MOODLE_INTERNAL') || die(); + require_once($CFG->libdir.'/externallib.php'); require_once($CFG->libdir.'/gradelib.php'); require_once($CFG->dirroot.'/course/lib.php'); diff --git a/classes/coursemoduleinfo.php b/classes/coursemoduleinfo.php index 193c23c..dda0983 100644 --- a/classes/coursemoduleinfo.php +++ b/classes/coursemoduleinfo.php @@ -21,6 +21,8 @@ */ namespace local_treestudyplan; +defined('MOODLE_INTERNAL') || die(); + require_once($CFG->libdir.'/externallib.php'); require_once($CFG->libdir.'/modinfolib.php'); require_once($CFG->dirroot.'/course/lib.php'); diff --git a/classes/courseservice.php b/classes/courseservice.php index f64122d..eb52922 100644 --- a/classes/courseservice.php +++ b/classes/courseservice.php @@ -21,6 +21,8 @@ */ namespace local_treestudyplan; +defined('MOODLE_INTERNAL') || die(); + require_once($CFG->libdir.'/externallib.php'); use \local_treestudyplan\courseinfo; diff --git a/classes/gradeinfo.php b/classes/gradeinfo.php index 008b97e..bfbe9f9 100644 --- a/classes/gradeinfo.php +++ b/classes/gradeinfo.php @@ -21,6 +21,8 @@ */ namespace local_treestudyplan; +defined('MOODLE_INTERNAL') || die(); + require_once($CFG->libdir.'/externallib.php'); require_once($CFG->libdir.'/gradelib.php'); require_once($CFG->dirroot.'/course/lib.php'); diff --git a/classes/gradingscanner.php b/classes/gradingscanner.php index 2584d29..8036474 100644 --- a/classes/gradingscanner.php +++ b/classes/gradingscanner.php @@ -21,6 +21,8 @@ */ namespace local_treestudyplan; +defined('MOODLE_INTERNAL') || die(); + require_once($CFG->libdir.'/externallib.php'); use \grade_item; diff --git a/classes/local/aggregators/bistate_aggregator.php b/classes/local/aggregators/bistate_aggregator.php index 0e54f7b..cc172cf 100644 --- a/classes/local/aggregators/bistate_aggregator.php +++ b/classes/local/aggregators/bistate_aggregator.php @@ -21,6 +21,7 @@ */ namespace local_treestudyplan\local\aggregators; +defined('MOODLE_INTERNAL') || die(); use \local_treestudyplan\courseinfo; use \local_treestudyplan\gradeinfo; diff --git a/classes/local/aggregators/core_aggregator.php b/classes/local/aggregators/core_aggregator.php index c9e86ac..8460d8f 100644 --- a/classes/local/aggregators/core_aggregator.php +++ b/classes/local/aggregators/core_aggregator.php @@ -21,6 +21,7 @@ */ namespace local_treestudyplan\local\aggregators; +defined('MOODLE_INTERNAL') || die(); use \local_treestudyplan\courseinfo; use \local_treestudyplan\corecompletioninfo; diff --git a/classes/local/aggregators/tristate_aggregator.php b/classes/local/aggregators/tristate_aggregator.php index 133709a..fa0523a 100644 --- a/classes/local/aggregators/tristate_aggregator.php +++ b/classes/local/aggregators/tristate_aggregator.php @@ -21,6 +21,7 @@ */ namespace local_treestudyplan\local\aggregators; +defined('MOODLE_INTERNAL') || die(); use \local_treestudyplan\courseinfo; use \local_treestudyplan\gradeinfo; diff --git a/classes/local/gradegenerator.php b/classes/local/gradegenerator.php index c8586eb..fb33f44 100644 --- a/classes/local/gradegenerator.php +++ b/classes/local/gradegenerator.php @@ -21,6 +21,7 @@ */ namespace local_treestudyplan\local; +defined('MOODLE_INTERNAL') || die(); use Exception; diff --git a/classes/local/helpers/debugger.php b/classes/local/helpers/debugger.php deleted file mode 100644 index 5adcdc7..0000000 --- a/classes/local/helpers/debugger.php +++ /dev/null @@ -1,68 +0,0 @@ -. -/** - * - * @package local_treestudyplan - * @copyright 2023 P.M. Kuipers - * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -namespace local_treestudyplan\local\helpers; - -use DateTime; - -class debugger { - - private $fname; - private $tag; - private $enabled = false; - - public function __construct($filename, $tag) { - global $CFG; - - $this->fname = $filename; - $this->tag = $tag; - - // Assume debug environment if cachejs is false. - $this->enabled = (isset($CFG->cachejs) && $CFG->cachejs == false); - - } - - public function dump($object, string $tag="") { - if (strlen($tag) > 0) { - $tag .= ":\n"; - } - $o = json_encode($object); - $this->writeblock($tag.": ".$o); - - } - - public function write($str) { - $this->writeblock($str); - } - - private function writeblock($str) { - if ($this->enabled) { - $now = new DateTime(); - - $tagline = "[ {$this->tag} - ".$now->format("c")." ]"; - - $fp = fopen($this->fname, "a"); - fwrite($fp, $tagline . ":\n".$str."\n"); - fclose($fp); - } - } -} diff --git a/classes/local/helpers/webservicehelper.php b/classes/local/helpers/webservicehelper.php index ff8de3b..cc23130 100644 --- a/classes/local/helpers/webservicehelper.php +++ b/classes/local/helpers/webservicehelper.php @@ -21,6 +21,7 @@ */ namespace local_treestudyplan\local\helpers; +defined('MOODLE_INTERNAL') || die(); require_once($CFG->dirroot.'/webservice/lib.php'); class webservicehelper { diff --git a/classes/local/ungradedscanners/assign_scanner.php b/classes/local/ungradedscanners/assign_scanner.php index dfb8c9a..bc0f2ee 100644 --- a/classes/local/ungradedscanners/assign_scanner.php +++ b/classes/local/ungradedscanners/assign_scanner.php @@ -21,6 +21,7 @@ */ namespace local_treestudyplan\local\ungradedscanners; +defined('MOODLE_INTERNAL') || die(); class assign_scanner extends scanner_base { diff --git a/classes/local/ungradedscanners/quiz_scanner.php b/classes/local/ungradedscanners/quiz_scanner.php index d54997b..3513ab4 100644 --- a/classes/local/ungradedscanners/quiz_scanner.php +++ b/classes/local/ungradedscanners/quiz_scanner.php @@ -21,6 +21,7 @@ */ namespace local_treestudyplan\local\ungradedscanners; +defined('MOODLE_INTERNAL') || die(); require_once($CFG->dirroot.'/question/engine/states.php'); // For reading question state. diff --git a/classes/local/ungradedscanners/scanner_base.php b/classes/local/ungradedscanners/scanner_base.php index 15b39ed..c1018c9 100644 --- a/classes/local/ungradedscanners/scanner_base.php +++ b/classes/local/ungradedscanners/scanner_base.php @@ -21,6 +21,8 @@ */ namespace local_treestudyplan\local\ungradedscanners; +defined('MOODLE_INTERNAL') || die(); + use \grade_item; abstract class scanner_base { diff --git a/classes/period.php b/classes/period.php index 26633a4..c4eb105 100644 --- a/classes/period.php +++ b/classes/period.php @@ -21,6 +21,7 @@ */ namespace local_treestudyplan; +defined('MOODLE_INTERNAL') || die(); require_once($CFG->libdir.'/externallib.php'); diff --git a/classes/privacy/provider.php b/classes/privacy/provider.php index 255f420..fff316c 100644 --- a/classes/privacy/provider.php +++ b/classes/privacy/provider.php @@ -21,6 +21,8 @@ */ namespace local_treestudyplan\privacy; +defined('MOODLE_INTERNAL') || die(); + use core_privacy\local\metadata\collection; use \core_privacy\local\request\userlist; use core_privacy\local\request\contextlist; diff --git a/classes/reportinvite_form.php b/classes/reportinvite_form.php index b9bdfb1..91b52c1 100644 --- a/classes/reportinvite_form.php +++ b/classes/reportinvite_form.php @@ -20,6 +20,8 @@ * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ +defined('MOODLE_INTERNAL') || die(); + require_once("$CFG->libdir/formslib.php"); require_once("$CFG->dirroot/local/treestudyplan/lib.php"); @@ -55,16 +57,16 @@ class reportinvite_form extends moodleform { $this->add_action_buttons(); } //Custom validation should be added here. - function validation($data, $files) { + public function validation($data, $files) { return array(); } - function set_data($data) { + public function set_data($data) { parent::set_data($data); } - function get_data() { + public function get_data() { global $DB, $USER; $data = parent::get_data(); diff --git a/classes/studentstudyplanservice.php b/classes/studentstudyplanservice.php index 66644e0..be33202 100644 --- a/classes/studentstudyplanservice.php +++ b/classes/studentstudyplanservice.php @@ -21,6 +21,8 @@ */ namespace local_treestudyplan; +defined('MOODLE_INTERNAL') || die(); + require_once($CFG->libdir.'/externallib.php'); use \local_treestudyplan\local\helpers\webservicehelper; diff --git a/classes/studyitem.php b/classes/studyitem.php index 093aef8..58f5986 100644 --- a/classes/studyitem.php +++ b/classes/studyitem.php @@ -21,6 +21,8 @@ */ namespace local_treestudyplan; +defined('MOODLE_INTERNAL') || die(); + require_once($CFG->libdir.'/externallib.php'); class studyitem { diff --git a/classes/studyitemconnection.php b/classes/studyitemconnection.php index fe04029..ae68483 100644 --- a/classes/studyitemconnection.php +++ b/classes/studyitemconnection.php @@ -21,6 +21,8 @@ */ namespace local_treestudyplan; +defined('MOODLE_INTERNAL') || die(); + require_once($CFG->libdir.'/externallib.php'); class studyitemconnection { diff --git a/classes/studyline.php b/classes/studyline.php index ab065eb..5cf35fb 100644 --- a/classes/studyline.php +++ b/classes/studyline.php @@ -21,6 +21,8 @@ */ namespace local_treestudyplan; +defined('MOODLE_INTERNAL') || die(); + require_once($CFG->libdir.'/externallib.php'); class studyline { diff --git a/classes/studyplan.php b/classes/studyplan.php index fae6a50..af58476 100644 --- a/classes/studyplan.php +++ b/classes/studyplan.php @@ -21,6 +21,7 @@ */ namespace local_treestudyplan; +defined('MOODLE_INTERNAL') || die(); require_once($CFG->libdir.'/externallib.php'); diff --git a/classes/studyplanpage.php b/classes/studyplanpage.php index 238d726..d124e9b 100644 --- a/classes/studyplanpage.php +++ b/classes/studyplanpage.php @@ -21,6 +21,7 @@ */ namespace local_treestudyplan; +defined('MOODLE_INTERNAL') || die(); require_once($CFG->libdir.'/externallib.php'); diff --git a/classes/studyplanservice.php b/classes/studyplanservice.php index 88561f7..f239332 100644 --- a/classes/studyplanservice.php +++ b/classes/studyplanservice.php @@ -21,6 +21,8 @@ */ namespace local_treestudyplan; +defined('MOODLE_INTERNAL') || die(); + use local_treestudyplan\local\helpers\webservicehelper; require_once($CFG->libdir.'/externallib.php'); diff --git a/classes/success.php b/classes/success.php index 1da31aa..002f893 100644 --- a/classes/success.php +++ b/classes/success.php @@ -21,6 +21,7 @@ */ namespace local_treestudyplan; +defined('MOODLE_INTERNAL') || die(); class success { private $success; diff --git a/classes/task/autocohortsync.php b/classes/task/autocohortsync.php index 6fb9406..b5ade95 100644 --- a/classes/task/autocohortsync.php +++ b/classes/task/autocohortsync.php @@ -21,6 +21,8 @@ */ namespace local_treestudyplan\task; +defined('MOODLE_INTERNAL') || die(); + require_once($CFG->dirroot.'/course/externallib.php'); use local_treestudyplan\studyplan; use local_treestudyplan\cascadecohortsync; diff --git a/classes/task/refreshteacherlist.php b/classes/task/refreshteacherlist.php index bff524b..2ed8aec 100644 --- a/classes/task/refreshteacherlist.php +++ b/classes/task/refreshteacherlist.php @@ -21,6 +21,8 @@ */ namespace local_treestudyplan\task; +defined('MOODLE_INTERNAL') || die(); + require_once($CFG->dirroot.'/course/externallib.php'); use local_treestudyplan\teachingfinder; diff --git a/classes/teachingfinder.php b/classes/teachingfinder.php index bd3db01..22f1946 100644 --- a/classes/teachingfinder.php +++ b/classes/teachingfinder.php @@ -21,6 +21,7 @@ */ namespace local_treestudyplan; +defined('MOODLE_INTERNAL') || die(); class teachingfinder { const TABLE = "local_treestudyplan_teachers";