Moodle code style fixes part 7

This commit is contained in:
PMKuipers 2023-08-25 12:04:27 +02:00
parent edf45f2c50
commit 0911db7ed4
37 changed files with 67 additions and 77 deletions

View file

@ -21,6 +21,8 @@
*/ */
namespace local_treestudyplan; namespace local_treestudyplan;
defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir.'/externallib.php'); require_once($CFG->libdir.'/externallib.php');
abstract class aggregator { abstract class aggregator {

View file

@ -21,6 +21,7 @@
*/ */
namespace local_treestudyplan; namespace local_treestudyplan;
defined('MOODLE_INTERNAL') || die();
use local_treestudyplan\local\helpers\webservicehelper; use local_treestudyplan\local\helpers\webservicehelper;

View file

@ -21,6 +21,8 @@
*/ */
namespace local_treestudyplan; namespace local_treestudyplan;
defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir.'/externallib.php'); require_once($CFG->libdir.'/externallib.php');
class badgeinfo { class badgeinfo {

View file

@ -21,6 +21,8 @@
*/ */
namespace local_treestudyplan; namespace local_treestudyplan;
defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir.'/externallib.php'); require_once($CFG->libdir.'/externallib.php');
use \local_treestudyplan\studyplan; use \local_treestudyplan\studyplan;
@ -30,7 +32,7 @@ class cascadecohortsync {
private $studyplan; private $studyplan;
private $studyplanid; private $studyplanid;
function __construct(studyplan $studyplan) { public function __construct(studyplan $studyplan) {
$this->studyplan = $studyplan; $this->studyplan = $studyplan;
$this->studyplanid = $studyplan->id(); $this->studyplanid = $studyplan->id();
} }
@ -65,7 +67,7 @@ class cascadecohortsync {
return $groupid; return $groupid;
} }
function sync() { public function sync() {
global $DB; global $DB;
/* Explainer: /* Explainer:

View file

@ -21,6 +21,8 @@
*/ */
namespace local_treestudyplan; namespace local_treestudyplan;
defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir.'/externallib.php'); require_once($CFG->libdir.'/externallib.php');
use \local_treestudyplan\studyplan; use \local_treestudyplan\studyplan;
@ -29,11 +31,11 @@ class cascadeusersync {
private const METHOD = "manual"; private const METHOD = "manual";
private $studyplan; private $studyplan;
function __construct(studyplan $studyplan) { public function __construct(studyplan $studyplan) {
$this->studyplan = $studyplan; $this->studyplan = $studyplan;
} }
function sync() { public function sync() {
global $DB; global $DB;
/* Explainer: /* Explainer:

View file

@ -21,6 +21,8 @@
*/ */
namespace local_treestudyplan; namespace local_treestudyplan;
defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir.'/externallib.php'); require_once($CFG->libdir.'/externallib.php');
class completion { class completion {

View file

@ -21,6 +21,8 @@
*/ */
namespace local_treestudyplan; namespace local_treestudyplan;
defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir.'/externallib.php'); require_once($CFG->libdir.'/externallib.php');
use \grade_item; use \grade_item;

View file

@ -21,6 +21,7 @@
*/ */
namespace local_treestudyplan; namespace local_treestudyplan;
defined('MOODLE_INTERNAL') || die();
class contextinfo { class contextinfo {
public $context; public $context;

View file

@ -21,6 +21,8 @@
*/ */
namespace local_treestudyplan; namespace local_treestudyplan;
defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir.'/externallib.php'); require_once($CFG->libdir.'/externallib.php');
require_once($CFG->libdir.'/gradelib.php'); require_once($CFG->libdir.'/gradelib.php');
require_once($CFG->dirroot.'/course/lib.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, * @return null|float The percentage, or null if completion is not supported in the course,
* or there are no activities that support completion. * 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. // First, let's make sure completion is enabled.
if (!$this->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, * @return null|\stdClass The percentage, or null if completion is not supported in the course,
* or there are no activities that support completion. * 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. // First, let's make sure completion is enabled.
if (!$this->completion->is_enabled()) { if (!$this->completion->is_enabled()) {

View file

@ -21,6 +21,8 @@
*/ */
namespace local_treestudyplan; namespace local_treestudyplan;
defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir.'/externallib.php'); require_once($CFG->libdir.'/externallib.php');
require_once($CFG->libdir.'/gradelib.php'); require_once($CFG->libdir.'/gradelib.php');
require_once($CFG->dirroot.'/course/lib.php'); require_once($CFG->dirroot.'/course/lib.php');

View file

@ -21,6 +21,8 @@
*/ */
namespace local_treestudyplan; namespace local_treestudyplan;
defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir.'/externallib.php'); require_once($CFG->libdir.'/externallib.php');
require_once($CFG->libdir.'/modinfolib.php'); require_once($CFG->libdir.'/modinfolib.php');
require_once($CFG->dirroot.'/course/lib.php'); require_once($CFG->dirroot.'/course/lib.php');

View file

@ -21,6 +21,8 @@
*/ */
namespace local_treestudyplan; namespace local_treestudyplan;
defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir.'/externallib.php'); require_once($CFG->libdir.'/externallib.php');
use \local_treestudyplan\courseinfo; use \local_treestudyplan\courseinfo;

View file

@ -21,6 +21,8 @@
*/ */
namespace local_treestudyplan; namespace local_treestudyplan;
defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir.'/externallib.php'); require_once($CFG->libdir.'/externallib.php');
require_once($CFG->libdir.'/gradelib.php'); require_once($CFG->libdir.'/gradelib.php');
require_once($CFG->dirroot.'/course/lib.php'); require_once($CFG->dirroot.'/course/lib.php');

View file

@ -21,6 +21,8 @@
*/ */
namespace local_treestudyplan; namespace local_treestudyplan;
defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir.'/externallib.php'); require_once($CFG->libdir.'/externallib.php');
use \grade_item; use \grade_item;

View file

@ -21,6 +21,7 @@
*/ */
namespace local_treestudyplan\local\aggregators; namespace local_treestudyplan\local\aggregators;
defined('MOODLE_INTERNAL') || die();
use \local_treestudyplan\courseinfo; use \local_treestudyplan\courseinfo;
use \local_treestudyplan\gradeinfo; use \local_treestudyplan\gradeinfo;

View file

@ -21,6 +21,7 @@
*/ */
namespace local_treestudyplan\local\aggregators; namespace local_treestudyplan\local\aggregators;
defined('MOODLE_INTERNAL') || die();
use \local_treestudyplan\courseinfo; use \local_treestudyplan\courseinfo;
use \local_treestudyplan\corecompletioninfo; use \local_treestudyplan\corecompletioninfo;

View file

@ -21,6 +21,7 @@
*/ */
namespace local_treestudyplan\local\aggregators; namespace local_treestudyplan\local\aggregators;
defined('MOODLE_INTERNAL') || die();
use \local_treestudyplan\courseinfo; use \local_treestudyplan\courseinfo;
use \local_treestudyplan\gradeinfo; use \local_treestudyplan\gradeinfo;

View file

@ -21,6 +21,7 @@
*/ */
namespace local_treestudyplan\local; namespace local_treestudyplan\local;
defined('MOODLE_INTERNAL') || die();
use Exception; use Exception;

View file

@ -1,68 +0,0 @@
<?php
// This file is part of the Studyplan plugin for Moodle
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <https://www.gnu.org/licenses/>.
/**
*
* @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);
}
}
}

View file

@ -21,6 +21,7 @@
*/ */
namespace local_treestudyplan\local\helpers; namespace local_treestudyplan\local\helpers;
defined('MOODLE_INTERNAL') || die();
require_once($CFG->dirroot.'/webservice/lib.php'); require_once($CFG->dirroot.'/webservice/lib.php');
class webservicehelper { class webservicehelper {

View file

@ -21,6 +21,7 @@
*/ */
namespace local_treestudyplan\local\ungradedscanners; namespace local_treestudyplan\local\ungradedscanners;
defined('MOODLE_INTERNAL') || die();
class assign_scanner extends scanner_base { class assign_scanner extends scanner_base {

View file

@ -21,6 +21,7 @@
*/ */
namespace local_treestudyplan\local\ungradedscanners; namespace local_treestudyplan\local\ungradedscanners;
defined('MOODLE_INTERNAL') || die();
require_once($CFG->dirroot.'/question/engine/states.php'); // For reading question state. require_once($CFG->dirroot.'/question/engine/states.php'); // For reading question state.

View file

@ -21,6 +21,8 @@
*/ */
namespace local_treestudyplan\local\ungradedscanners; namespace local_treestudyplan\local\ungradedscanners;
defined('MOODLE_INTERNAL') || die();
use \grade_item; use \grade_item;
abstract class scanner_base { abstract class scanner_base {

View file

@ -21,6 +21,7 @@
*/ */
namespace local_treestudyplan; namespace local_treestudyplan;
defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir.'/externallib.php'); require_once($CFG->libdir.'/externallib.php');

View file

@ -21,6 +21,8 @@
*/ */
namespace local_treestudyplan\privacy; namespace local_treestudyplan\privacy;
defined('MOODLE_INTERNAL') || die();
use core_privacy\local\metadata\collection; use core_privacy\local\metadata\collection;
use \core_privacy\local\request\userlist; use \core_privacy\local\request\userlist;
use core_privacy\local\request\contextlist; use core_privacy\local\request\contextlist;

View file

@ -20,6 +20,8 @@
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @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->libdir/formslib.php");
require_once("$CFG->dirroot/local/treestudyplan/lib.php"); require_once("$CFG->dirroot/local/treestudyplan/lib.php");
@ -55,16 +57,16 @@ class reportinvite_form extends moodleform {
$this->add_action_buttons(); $this->add_action_buttons();
} }
//Custom validation should be added here. //Custom validation should be added here.
function validation($data, $files) { public function validation($data, $files) {
return array(); return array();
} }
function set_data($data) { public function set_data($data) {
parent::set_data($data); parent::set_data($data);
} }
function get_data() { public function get_data() {
global $DB, $USER; global $DB, $USER;
$data = parent::get_data(); $data = parent::get_data();

View file

@ -21,6 +21,8 @@
*/ */
namespace local_treestudyplan; namespace local_treestudyplan;
defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir.'/externallib.php'); require_once($CFG->libdir.'/externallib.php');
use \local_treestudyplan\local\helpers\webservicehelper; use \local_treestudyplan\local\helpers\webservicehelper;

View file

@ -21,6 +21,8 @@
*/ */
namespace local_treestudyplan; namespace local_treestudyplan;
defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir.'/externallib.php'); require_once($CFG->libdir.'/externallib.php');
class studyitem { class studyitem {

View file

@ -21,6 +21,8 @@
*/ */
namespace local_treestudyplan; namespace local_treestudyplan;
defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir.'/externallib.php'); require_once($CFG->libdir.'/externallib.php');
class studyitemconnection { class studyitemconnection {

View file

@ -21,6 +21,8 @@
*/ */
namespace local_treestudyplan; namespace local_treestudyplan;
defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir.'/externallib.php'); require_once($CFG->libdir.'/externallib.php');
class studyline { class studyline {

View file

@ -21,6 +21,7 @@
*/ */
namespace local_treestudyplan; namespace local_treestudyplan;
defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir.'/externallib.php'); require_once($CFG->libdir.'/externallib.php');

View file

@ -21,6 +21,7 @@
*/ */
namespace local_treestudyplan; namespace local_treestudyplan;
defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir.'/externallib.php'); require_once($CFG->libdir.'/externallib.php');

View file

@ -21,6 +21,8 @@
*/ */
namespace local_treestudyplan; namespace local_treestudyplan;
defined('MOODLE_INTERNAL') || die();
use local_treestudyplan\local\helpers\webservicehelper; use local_treestudyplan\local\helpers\webservicehelper;
require_once($CFG->libdir.'/externallib.php'); require_once($CFG->libdir.'/externallib.php');

View file

@ -21,6 +21,7 @@
*/ */
namespace local_treestudyplan; namespace local_treestudyplan;
defined('MOODLE_INTERNAL') || die();
class success { class success {
private $success; private $success;

View file

@ -21,6 +21,8 @@
*/ */
namespace local_treestudyplan\task; namespace local_treestudyplan\task;
defined('MOODLE_INTERNAL') || die();
require_once($CFG->dirroot.'/course/externallib.php'); require_once($CFG->dirroot.'/course/externallib.php');
use local_treestudyplan\studyplan; use local_treestudyplan\studyplan;
use local_treestudyplan\cascadecohortsync; use local_treestudyplan\cascadecohortsync;

View file

@ -21,6 +21,8 @@
*/ */
namespace local_treestudyplan\task; namespace local_treestudyplan\task;
defined('MOODLE_INTERNAL') || die();
require_once($CFG->dirroot.'/course/externallib.php'); require_once($CFG->dirroot.'/course/externallib.php');
use local_treestudyplan\teachingfinder; use local_treestudyplan\teachingfinder;

View file

@ -21,6 +21,7 @@
*/ */
namespace local_treestudyplan; namespace local_treestudyplan;
defined('MOODLE_INTERNAL') || die();
class teachingfinder { class teachingfinder {
const TABLE = "local_treestudyplan_teachers"; const TABLE = "local_treestudyplan_teachers";