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;
defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir.'/externallib.php');
abstract class aggregator {

View File

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

View File

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

View File

@ -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:

View File

@ -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:

View File

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

View File

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

View File

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

View File

@ -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()) {

View File

@ -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');

View File

@ -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');

View File

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

View File

@ -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');

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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.

View File

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

View File

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

View File

@ -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;

View File

@ -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();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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;

View File

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

View File

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