diff --git a/classes/aggregator.php b/classes/aggregator.php index ed74121..7d7bb6a 100644 --- a/classes/aggregator.php +++ b/classes/aggregator.php @@ -98,7 +98,7 @@ abstract class aggregator { return ""; } - public static function basic_structure($value=VALUE_REQUIRED) { + public static function basic_structure($value = VALUE_REQUIRED) { return new \external_single_structure([ "useRequiredGrades" => new \external_value(PARAM_BOOL, 'id of studyplan'), "useItemConditions" => new \external_value(PARAM_BOOL, 'name of studyplan'), @@ -112,7 +112,7 @@ abstract class aggregator { ]; } - public static function list_structure($value=VALUE_REQUIRED) { + public static function list_structure($value = VALUE_REQUIRED) { return new \external_multiple_structure(new \external_single_structure([ "id" => new \external_value(PARAM_TEXT, 'id of aggregator'), "name" => new \external_value(PARAM_TEXT, 'name of agregator'), diff --git a/classes/associationservice.php b/classes/associationservice.php index e4f2378..57d8510 100644 --- a/classes/associationservice.php +++ b/classes/associationservice.php @@ -113,7 +113,7 @@ class associationservice extends \external_api { } // Actual functions. - public static function list_cohort($like='', $excludeid=null, $contextid=1) { + public static function list_cohort($like = '', $excludeid = null, $contextid = 1) { global $CFG, $DB; // Only allow this if the user has the right to edit in this context. @@ -159,7 +159,7 @@ class associationservice extends \external_api { } // Actual functions. - public static function find_user($like, $excludeid=null, $contextid=1) { + public static function find_user($like, $excludeid = null, $contextid = 1) { global $CFG, $DB; // Only allow this if the user has the right to edit in this context. @@ -427,7 +427,7 @@ class associationservice extends \external_api { public static function sortusermodels(&$list) { return usort($list, function($a, $b) { - $m= []; + $m = []; if (preg_match("/.*?([A-Z].*)/", $a['lastname'], $m)) { $sortln_a = $m[1]; } else { @@ -438,7 +438,7 @@ class associationservice extends \external_api { } else { $sortln_b = $b['lastname']; } - $cmp= $sortln_a <=> $sortln_b; + $cmp = $sortln_a <=> $sortln_b; return ($cmp != 0) ? $cmp : $a['firstname'] <=> $b['firstname']; }); } diff --git a/classes/badgeinfo.php b/classes/badgeinfo.php index 3b6ac62..97a041e 100644 --- a/classes/badgeinfo.php +++ b/classes/badgeinfo.php @@ -63,7 +63,7 @@ class badgeinfo { return is_numeric($id) && $DB->record_exists('badge', array('id' => $id)); } - public static function editor_structure($value=VALUE_REQUIRED) { + public static function editor_structure($value = VALUE_REQUIRED) { return new \external_single_structure([ "id" => new \external_value(PARAM_INT, 'id of badge'), "infolink" => new \external_value(PARAM_TEXT, 'badge issue information link', VALUE_OPTIONAL), @@ -81,7 +81,7 @@ class badgeinfo { ], "Badge info", $value); } - public function editor_model(array $studentlist=null) { + public function editor_model(array $studentlist = null) { if ($this->badge->type == BADGE_TYPE_SITE) { $context = \context_system::instance(); } else { @@ -114,7 +114,7 @@ class badgeinfo { return $model; } - public static function user_structure($value=VALUE_REQUIRED) { + public static function user_structure($value = VALUE_REQUIRED) { return new \external_single_structure([ "id" => new \external_value(PARAM_INT, 'id of badge'), "infolink" => new \external_value(PARAM_TEXT, 'badge issue information link', VALUE_OPTIONAL), diff --git a/classes/completion.php b/classes/completion.php index db21ff4..8d6497a 100644 --- a/classes/completion.php +++ b/classes/completion.php @@ -52,7 +52,7 @@ class completion { } } - public static function structure($value=VALUE_REQUIRED) { + public static function structure($value = VALUE_REQUIRED) { return new \external_value( PARAM_TEXT, 'completion state (failed|incomplete|pending|progress|completed|good|excellent)', $value); diff --git a/classes/completionscanner.php b/classes/completionscanner.php index 5981ab5..364426d 100644 --- a/classes/completionscanner.php +++ b/classes/completionscanner.php @@ -102,7 +102,7 @@ class completionscanner { return $this->pending_cache[$userid]; } - public static function structure($value=VALUE_OPTIONAL) { + public static function structure($value = VALUE_OPTIONAL) { return new \external_single_structure([ "ungraded" => new \external_value(PARAM_INT, 'number of ungraded submissions'), "completed" => new \external_value(PARAM_INT, 'number of completed students'), diff --git a/classes/contextinfo.php b/classes/contextinfo.php index 7819767..2043954 100644 --- a/classes/contextinfo.php +++ b/classes/contextinfo.php @@ -21,7 +21,6 @@ */ namespace local_treestudyplan; -defined('MOODLE_INTERNAL') || die(); class contextinfo { public $context; @@ -29,7 +28,7 @@ class contextinfo { $this->context = $context; } - public static function structure($value=VALUE_REQUIRED) { + public static function structure($value = VALUE_REQUIRED) { return new \external_single_structure([ "name" => new \external_value(PARAM_TEXT, 'context name'), "shortname" => new \external_value(PARAM_TEXT, 'context short name'), diff --git a/classes/corecompletioninfo.php b/classes/corecompletioninfo.php index a96c484..df70000 100644 --- a/classes/corecompletioninfo.php +++ b/classes/corecompletioninfo.php @@ -73,7 +73,7 @@ class corecompletioninfo { return self::$COMPLETIONHANDLES[$completion] ?? "undefined"; } - public static function completion_item_editor_structure($value=VALUE_REQUIRED) { + public static function completion_item_editor_structure($value = VALUE_REQUIRED) { return new \external_single_structure([ "id" => new \external_value(PARAM_INT, 'criteria id', VALUE_OPTIONAL), "title" => new \external_value(PARAM_TEXT, 'name of subitem', VALUE_OPTIONAL), @@ -88,7 +88,7 @@ class corecompletioninfo { ], 'completion type', $value); } - public static function completion_type_editor_structure($value=VALUE_REQUIRED) { + public static function completion_type_editor_structure($value = VALUE_REQUIRED) { return new \external_single_structure([ "items" => new \external_multiple_structure(self::completion_item_editor_structure(), 'subitems', VALUE_OPTIONAL), "title" => new \external_value(PARAM_TEXT, 'optional title', VALUE_OPTIONAL), @@ -98,7 +98,7 @@ class corecompletioninfo { ], 'completion type', $value); } - public static function editor_structure($value=VALUE_REQUIRED) { + public static function editor_structure($value = VALUE_REQUIRED) { return new \external_single_structure([ "conditions" => new \external_multiple_structure(self::completion_type_editor_structure(), 'completion conditions'), "aggregation" => new \external_value(PARAM_TEXT, 'completion aggregation ["all", "any"]'), @@ -106,7 +106,7 @@ class corecompletioninfo { ], 'course completion info', $value); } - public static function completion_item_user_structure($value=VALUE_REQUIRED) { + public static function completion_item_user_structure($value = VALUE_REQUIRED) { return new \external_single_structure([ "id" => new \external_value(PARAM_INT, 'id of completion', VALUE_OPTIONAL), "title" => new \external_value(PARAM_TEXT, 'name of subitem', VALUE_OPTIONAL), @@ -127,7 +127,7 @@ class corecompletioninfo { ], 'completion type', $value); } - public static function completion_type_user_structure($value=VALUE_REQUIRED) { + public static function completion_type_user_structure($value = VALUE_REQUIRED) { return new \external_single_structure([ "items" => new \external_multiple_structure(self::completion_item_user_structure(), 'subitems', VALUE_OPTIONAL), "title" => new \external_value(PARAM_TEXT, 'optional title', VALUE_OPTIONAL), @@ -142,7 +142,7 @@ class corecompletioninfo { ], 'completion type', $value); } - public static function user_structure($value=VALUE_REQUIRED) { + public static function user_structure($value = VALUE_REQUIRED) { return new \external_single_structure([ "progress" => new \external_value(PARAM_INT, 'completed sub-conditions'), "enabled" => new \external_value(PARAM_BOOL, "whether completion is enabled here"), @@ -156,7 +156,7 @@ class corecompletioninfo { } private static function aggregation_handle($method) { - return ($method==COMPLETION_AGGREGATION_ALL) ? "all" : "any"; + return ($method ==COMPLETION_AGGREGATION_ALL) ? "all" : "any"; } public function editor_model() { @@ -447,7 +447,7 @@ class corecompletioninfo { private function get_grade($cm, $userid) { // TODO: Display grade in the way described in the course setup (with letters if needed). - $gi= grade_item::fetch(['itemtype' => 'mod', + $gi = grade_item::fetch(['itemtype' => 'mod', 'itemmodule' => $cm->modname, 'iteminstance' => $cm->instance, 'courseid' => $this->course->id]); // Make sure we only get results relevant to this course. @@ -490,7 +490,7 @@ class corecompletioninfo { */ private function get_course_grade($userid) { // TODO: Display grade in the way described in the course setup (with letters if needed). - $gi= grade_item::fetch(['itemtype' => 'course', + $gi = grade_item::fetch(['itemtype' => 'course', 'iteminstance' => $this->course->id, 'courseid' => $this->course->id]); diff --git a/classes/courseinfo.php b/classes/courseinfo.php index ce22535..09c4c19 100644 --- a/classes/courseinfo.php +++ b/classes/courseinfo.php @@ -76,7 +76,7 @@ class courseinfo { return is_enrolled($this->coursecontext, $USER, 'mod/assign:grade'); } - protected function iCanSelectGradables($userid=-1) { + protected function iCanSelectGradables($userid = -1) { global $USER, $DB; if ($userid <= 0) { $usr = $USER; @@ -157,7 +157,7 @@ class courseinfo { return $this->course->shortname; } - public static function simple_structure($value=VALUE_REQUIRED) { + public static function simple_structure($value = VALUE_REQUIRED) { return new \external_single_structure([ "id" => new \external_value(PARAM_INT, 'linked course id'), "fullname" => new \external_value(PARAM_TEXT, 'linked course name'), @@ -180,7 +180,7 @@ class courseinfo { return $info; } - public static function editor_structure($value=VALUE_REQUIRED) { + public static function editor_structure($value = VALUE_REQUIRED) { return new \external_single_structure([ "id" => new \external_value(PARAM_INT, 'linked course id'), "fullname" => new \external_value(PARAM_TEXT, 'linked course name'), @@ -201,7 +201,7 @@ class courseinfo { ], 'referenced course information', $value); } - public function editor_model(studyitem $studyitem=null, $usecorecompletioninfo=false) { + public function editor_model(studyitem $studyitem = null, $usecorecompletioninfo = false) { global $DB; $contextinfo = new contextinfo($this->context); @@ -238,7 +238,7 @@ class courseinfo { return $info; } - public static function user_structure($value=VALUE_REQUIRED) { + public static function user_structure($value = VALUE_REQUIRED) { return new \external_single_structure([ "id" => new \external_value(PARAM_INT, 'linked course id'), "fullname" => new \external_value(PARAM_TEXT, 'linked course name'), @@ -254,7 +254,7 @@ class courseinfo { ], 'course information', $value); } - public function user_model($userid, $usecorecompletioninfo=false) { + public function user_model($userid, $usecorecompletioninfo = false) { global $DB; $contextinfo = new contextinfo($this->context); diff --git a/classes/courseservice.php b/classes/courseservice.php index d6915e2..449598e 100644 --- a/classes/courseservice.php +++ b/classes/courseservice.php @@ -51,7 +51,7 @@ class courseservice extends \external_api { return new \external_multiple_structure(static::map_category_structure(false)); } - protected static function map_category_structure($lazy=false, $value=VALUE_REQUIRED) { + protected static function map_category_structure($lazy = false, $value = VALUE_REQUIRED) { $s = [ "id" => new \external_value(PARAM_INT, 'course category id'), "context_id" => new \external_value(PARAM_INT, 'course category context id'), @@ -112,7 +112,7 @@ class courseservice extends \external_api { return static::map_category($cat); } - protected static function map_category(\core_course_category $cat, $lazy=false) { + protected static function map_category(\core_course_category $cat, $lazy = false) { global $DB; $catcontext = $cat->get_context(); $ctxinfo = new contextinfo($catcontext); @@ -152,7 +152,7 @@ class courseservice extends \external_api { return new \external_multiple_structure(static::map_category_structure(true)); } - public static function list_accessible_categories($operation="edit") { + public static function list_accessible_categories($operation = "edit") { if ($operation == "edit") { $capability = self::CAP_EDIT; } else { // Operation == "view" || default. @@ -162,7 +162,7 @@ class courseservice extends \external_api { $cats = static::categories_by_capability($capability); $list = []; - /* @var $cat \core_course_category */ + foreach ($cats as $cat) { $list[] = static::map_category($cat, true); } @@ -170,7 +170,7 @@ class courseservice extends \external_api { } - public static function categories_by_capability($capability, \core_course_category $parent=null) { + public static function categories_by_capability($capability, \core_course_category $parent = null) { // List the categories in which the user has a specific capability. $list = []; // Initialize parent if needed. @@ -221,7 +221,7 @@ class courseservice extends \external_api { return new \external_multiple_structure(static::map_category_structure(true)); } - public static function list_used_categories($operation='edit') { + public static function list_used_categories($operation = 'edit') { global $DB; if ($operation == "edit") { $capability = self::CAP_EDIT; @@ -255,7 +255,7 @@ class courseservice extends \external_api { return $list; } - public static function list_accessible_categories_with_usage($operation='edit') { + public static function list_accessible_categories_with_usage($operation = 'edit') { global $DB; if ($operation == "edit") { $capability = self::CAP_EDIT; @@ -306,7 +306,7 @@ class courseservice extends \external_api { } public static function scan_grade_progress_returns() { - return gradingscanner::structure(VALUE_REQUIRED); + return gradingscanner::structure(VALUE_REQUIRED); } public static function scan_grade_progress($gradeitemid, $studyplanid) { @@ -390,7 +390,9 @@ class courseservice extends \external_api { // Get the connected users. $students = associationservice::all_associated($studyplanid); // Just get the user ids. - $studentids = array_map(function ($a) { return $a["id"];}, $students); + $studentids = array_map(function ($a) { + return $a["id"]; + }, $students); return [ "total" => count($studentids), diff --git a/classes/gradeinfo.php b/classes/gradeinfo.php index 4405307..fc12d40 100644 --- a/classes/gradeinfo.php +++ b/classes/gradeinfo.php @@ -183,7 +183,7 @@ class gradeinfo { return(false); } - public static function editor_structure($value=VALUE_REQUIRED) { + public static function editor_structure($value = VALUE_REQUIRED) { return new \external_single_structure([ "id" => new \external_value(PARAM_INT, 'grade_item id'), "cmid" => new \external_value(PARAM_INT, 'course module id'), @@ -222,7 +222,7 @@ class gradeinfo { return $model; } - public static function user_structure($value=VALUE_REQUIRED) { + public static function user_structure($value = VALUE_REQUIRED) { return new \external_single_structure([ "id" => new \external_value(PARAM_INT, 'grade_item id'), "cmid" => new \external_value(PARAM_INT, 'course module id'), @@ -293,7 +293,7 @@ class gradeinfo { public static function import(studyitem $item, array $model) { if ($item->type() == studyitem::COURSE) { $courseid = $item->courseid(); - $gradeitems= grade_item::fetch_all(['itemtype' => 'mod', 'courseid' => $courseid]); + $gradeitems = grade_item::fetch_all(['itemtype' => 'mod', 'courseid' => $courseid]); foreach ($gradeitems as $gi) { $giname = empty($outcome) ? $gi->itemname : $outcome->name; $gitype = $gi->itemmodule; @@ -314,7 +314,7 @@ class gradeinfo { } } - public static function list_course_gradables($course, studyitem $studyitem=null) { + public static function list_course_gradables($course, studyitem $studyitem = null) { $list = []; if (method_exists("\course_modinfo", "get_array_of_activities")) { @@ -325,7 +325,7 @@ class gradeinfo { } foreach ($activities as $act) { if ($act->visible) { - $gradeitems= grade_item::fetch_all(['itemtype' => 'mod', + $gradeitems = grade_item::fetch_all(['itemtype' => 'mod', 'itemmodule' => $act->mod, 'iteminstance' => $act->id, 'courseid' => $course->id]); @@ -376,7 +376,7 @@ class gradeinfo { return $list; } - public static function include_grade(int $gradeid, int $itemid, bool $include, bool $required=false) { + public static function include_grade(int $gradeid, int $itemid, bool $include, bool $required = false) { global $DB; $table = 'local_treestudyplan_gradeinc'; if ($include) { diff --git a/classes/gradingscanner.php b/classes/gradingscanner.php index 34c8139..cdf6f22 100644 --- a/classes/gradingscanner.php +++ b/classes/gradingscanner.php @@ -79,7 +79,7 @@ class gradingscanner { return $this->pending_cache[$userid]; } - public static function structure($value=VALUE_OPTIONAL) { + public static function structure($value = VALUE_OPTIONAL) { return new \external_single_structure([ "ungraded" => new \external_value(PARAM_INT, 'number of ungraded submissions'), "completed" => new \external_value(PARAM_INT, 'number of completed students'), diff --git a/classes/local/aggregators/bistate_aggregator.php b/classes/local/aggregators/bistate_aggregator.php index 925f793..f49fd94 100644 --- a/classes/local/aggregators/bistate_aggregator.php +++ b/classes/local/aggregators/bistate_aggregator.php @@ -21,7 +21,6 @@ */ 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 ca13b84..c07a039 100644 --- a/classes/local/aggregators/core_aggregator.php +++ b/classes/local/aggregators/core_aggregator.php @@ -21,7 +21,6 @@ */ 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 5ed3bd9..4bfbf58 100644 --- a/classes/local/aggregators/tristate_aggregator.php +++ b/classes/local/aggregators/tristate_aggregator.php @@ -21,7 +21,6 @@ */ namespace local_treestudyplan\local\aggregators; -defined('MOODLE_INTERNAL') || die(); use \local_treestudyplan\courseinfo; use \local_treestudyplan\gradeinfo; @@ -91,7 +90,7 @@ class tristate_aggregator extends \local_treestudyplan\aggregator { return completion::INCOMPLETE; } } else { - // Indeterminable, return null. + // Indeterminable. return null; } } diff --git a/classes/local/gradegenerator.php b/classes/local/gradegenerator.php index d8d5edd..ea43e48 100644 --- a/classes/local/gradegenerator.php +++ b/classes/local/gradegenerator.php @@ -21,7 +21,6 @@ */ namespace local_treestudyplan\local; -defined('MOODLE_INTERNAL') || die(); use Exception; @@ -136,7 +135,7 @@ class gradegenerator { $results = []; $gaveup = false; - for ($i=0; $i < $count; $i++) { + for ($i = 0; $i < $count; $i++) { $r = new \stdClass; if ($gaveup) { $r->done = !$gaveup; @@ -169,12 +168,12 @@ class gradegenerator { public function generate($student, $skill, array $gradeinfos ) { global $DB; - $table ="local_treestudyplan_gradecfg"; + $table = "local_treestudyplan_gradecfg"; $rlist = []; $gen = $this->generateraw($student, $skill, count($gradeinfos)); - for ($i=0; $i < count($gradeinfos); $i++) { + for ($i = 0; $i < count($gradeinfos); $i++) { $g = $gradeinfos[$i]; $gi = $g->getGradeitem(); $gr = $gen[$i]; diff --git a/classes/local/helpers/webservicehelper.php b/classes/local/helpers/webservicehelper.php index e7f9e47..4670e8a 100644 --- a/classes/local/helpers/webservicehelper.php +++ b/classes/local/helpers/webservicehelper.php @@ -61,7 +61,7 @@ class webservicehelper { * @param \core_course_category $parent The parent category to use as a scanning base. Used internally. * @return boolean */ - public static function has_capability_in_any_category($capability, \core_course_category $parent=null) { + public static function has_capability_in_any_category($capability, \core_course_category $parent = null) { // List the categories in which the user has a specific capability. $list = []; @@ -101,7 +101,7 @@ class webservicehelper { * @param bool $validate Validate the context before checking capabilities * @throws \webservice_access_exception If none of the capabilities provided are given to the current user */ - public static function require_capabilities($capability, $context=null, $validate=true) { + public static function require_capabilities($capability, $context = null, $validate = true) { if ($validate) { \external_api::validate_context($context); } diff --git a/classes/local/ungradedscanners/assign_scanner.php b/classes/local/ungradedscanners/assign_scanner.php index bc0f2ee..c1b929f 100644 --- a/classes/local/ungradedscanners/assign_scanner.php +++ b/classes/local/ungradedscanners/assign_scanner.php @@ -21,7 +21,6 @@ */ namespace local_treestudyplan\local\ungradedscanners; -defined('MOODLE_INTERNAL') || die(); class assign_scanner extends scanner_base { @@ -51,7 +50,7 @@ class assign_scanner extends scanner_base { return $DB->get_fieldset_sql($sql); } - public function count_ungraded($courseuserids=[]) { + public function count_ungraded($courseuserids = []) { $ungraded = $this->get_ungraded_submissions(); if (count($courseuserids) > 0) { @@ -60,7 +59,7 @@ class assign_scanner extends scanner_base { return count($ungraded); } - public function count_graded($courseuserids=[]) { + public function count_graded($courseuserids = []) { $ungraded = $this->get_ungraded_submissions(); $graded = $this->get_graded_users(); diff --git a/classes/local/ungradedscanners/quiz_scanner.php b/classes/local/ungradedscanners/quiz_scanner.php index 3513ab4..3ed04a7 100644 --- a/classes/local/ungradedscanners/quiz_scanner.php +++ b/classes/local/ungradedscanners/quiz_scanner.php @@ -21,7 +21,6 @@ */ namespace local_treestudyplan\local\ungradedscanners; -defined('MOODLE_INTERNAL') || die(); require_once($CFG->dirroot.'/question/engine/states.php'); // For reading question state. @@ -55,7 +54,7 @@ class quiz_scanner extends scanner_base { return array_keys($submissions); } - public function count_ungraded($courseuserids=[]) { + public function count_ungraded($courseuserids = []) { $ungraded = $this->get_ungraded_submissions(); if (count($courseuserids) > 0) { $ungraded = array_intersect($ungraded, $courseuserids); @@ -63,7 +62,7 @@ class quiz_scanner extends scanner_base { return count($ungraded); } - public function count_graded($courseuserids=[]) { + public function count_graded($courseuserids = []) { // Count all users who submitted one or more finished tests. global $DB; $sql = "SELECT DISTINCT g.userid diff --git a/classes/local/ungradedscanners/scanner_base.php b/classes/local/ungradedscanners/scanner_base.php index c1018c9..d58bd68 100644 --- a/classes/local/ungradedscanners/scanner_base.php +++ b/classes/local/ungradedscanners/scanner_base.php @@ -21,7 +21,6 @@ */ namespace local_treestudyplan\local\ungradedscanners; -defined('MOODLE_INTERNAL') || die(); use \grade_item; @@ -32,9 +31,9 @@ abstract class scanner_base { $this->gi = $gi; } - abstract public function count_ungraded($courseuserids=[]); + abstract public function count_ungraded($courseuserids = []); - abstract public function count_graded($courseuserids=[]); + abstract public function count_graded($courseuserids = []); abstract public function has_ungraded_submission($userid); diff --git a/classes/period.php b/classes/period.php index c1061c6..3d1e5ad 100644 --- a/classes/period.php +++ b/classes/period.php @@ -107,7 +107,7 @@ class period { if (!array_key_exists($page->id(), self::$PAGECACHE)) { $periods = []; // Find and add the periods to an array with the period sequence as a key. - for ($i=1; $i <= $page->periods(); $i++) { + for ($i = 1; $i <= $page->periods(); $i++) { $period = self::find($page, $i); $periods[$i] = $period; } @@ -160,7 +160,7 @@ class period { } } - public static function structure($value=VALUE_REQUIRED) { + public static function structure($value = VALUE_REQUIRED) { return new \external_single_structure([ "id" => new \external_value(PARAM_INT, 'id of period'), "fullname" => new \external_value(PARAM_TEXT, 'Full name of period'), @@ -235,7 +235,7 @@ class period { return success::success(); } - public static function page_structure($value=VALUE_REQUIRED) { + public static function page_structure($value = VALUE_REQUIRED) { return new \external_multiple_structure(self::structure(), "The periods in the page", $value); } diff --git a/classes/privacy/provider.php b/classes/privacy/provider.php index fff316c..93f94f3 100644 --- a/classes/privacy/provider.php +++ b/classes/privacy/provider.php @@ -21,7 +21,6 @@ */ namespace local_treestudyplan\privacy; -defined('MOODLE_INTERNAL') || die(); use core_privacy\local\metadata\collection; use \core_privacy\local\request\userlist; diff --git a/classes/reportinvite_form.php b/classes/reportinvite_form.php index 22c8156..fc1354a 100644 --- a/classes/reportinvite_form.php +++ b/classes/reportinvite_form.php @@ -27,13 +27,11 @@ require_once("$CFG->dirroot/local/treestudyplan/lib.php"); class reportinvite_form extends moodleform { // Add elements to form. - const GOALS_EDITOR_OPTIONS = array('trusttext' => true, 'subdirs' => true, 'maxfiles' => 0, 'maxbytes' => 5*1024*1025); public function definition() { global $CFG; - // 'code', 'revision', 'description', 'goals', 'complexity', 'points', 'studyhours'. - $mform = $this->_form; // Don't forget the underscore! . + $mform = $this->_form; // Don't forget the underscore! $mform->addElement('hidden', 'add', 0); $mform->setType('add', PARAM_ALPHANUM); @@ -61,11 +59,6 @@ class reportinvite_form extends moodleform { return array(); } - public function set_data($data) { - - parent::set_data($data); - } - public function get_data() { global $DB, $USER; @@ -87,14 +80,14 @@ class reportinvite_form extends moodleform { do { $length = 20; $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; - $charactersLength = strlen($characters); + $characterslength = strlen($characters); $randomkey = ''; for ($i = 0; $i < $length; $i++) { - $randomkey .= $characters[rand(0, $charactersLength - 1)]; + $randomkey .= $characters[rand(0, $characterslength - 1)]; } // Double check that the key is unique before inserting. - } while($DB->record_exists_select("local_treestudyplan_invit", + } while ($DB->record_exists_select("local_treestudyplan_invit", $DB->sql_compare_text("invitekey"). " = " . $DB->sql_compare_text(":invitekey"), ['invitekey' => $randomkey])); diff --git a/classes/studentstudyplanservice.php b/classes/studentstudyplanservice.php index be33202..960dbc5 100644 --- a/classes/studentstudyplanservice.php +++ b/classes/studentstudyplanservice.php @@ -214,7 +214,7 @@ class studentstudyplanservice extends \external_api { ); } - public static function get_own_studyplan($id=null) { + public static function get_own_studyplan($id = null) { global $USER; // Validate this call in the system context. @@ -258,7 +258,7 @@ class studentstudyplanservice extends \external_api { ); } - public static function get_teaching_studyplans($id=null) { + public static function get_teaching_studyplans($id = null) { global $CFG, $DB, $USER; $userid = $USER->id; diff --git a/classes/studyitem.php b/classes/studyitem.php index 1f07ce0..02d7ff2 100644 --- a/classes/studyitem.php +++ b/classes/studyitem.php @@ -98,7 +98,7 @@ class studyitem { return is_numeric($id) && $DB->record_exists(self::TABLE, array('id' => $id)); } - public static function editor_structure($value=VALUE_REQUIRED) { + public static function editor_structure($value = VALUE_REQUIRED) { return new \external_single_structure([ "id" => new \external_value(PARAM_INT, 'id of study item'), "type" => new \external_value(PARAM_TEXT, 'shortname of study item'), @@ -206,7 +206,7 @@ class studyitem { } - public static function add($fields, $import=false) { + public static function add($fields, $import = false) { global $DB; $addable = ['line_id', 'type', 'layer', 'conditions', 'slot', 'competency_id', 'course_id', 'badge_id', 'continuation_id', 'span']; @@ -253,7 +253,7 @@ class studyitem { } } - public function delete($force=false) { + public function delete($force = false) { global $DB; // Check if this item is referenced in a START item. @@ -312,7 +312,7 @@ class studyitem { return $list; } - private static function link_structure($value=VALUE_REQUIRED) { + private static function link_structure($value = VALUE_REQUIRED) { return new \external_single_structure([ "id" => new \external_value(PARAM_INT, 'id of study item'), "type" => new \external_value(PARAM_TEXT, 'type of study item'), @@ -336,7 +336,7 @@ class studyitem { ]; } - public static function user_structure($value=VALUE_REQUIRED) { + public static function user_structure($value = VALUE_REQUIRED) { return new \external_single_structure([ "id" => new \external_value(PARAM_INT, 'id of study item'), "type" => new \external_value(PARAM_TEXT, 'type of study item'), diff --git a/classes/studyitemconnection.php b/classes/studyitemconnection.php index 2fd400d..42c7de5 100644 --- a/classes/studyitemconnection.php +++ b/classes/studyitemconnection.php @@ -37,7 +37,7 @@ class studyitemconnection { $this->id = $r->id; } - public static function structure($value=VALUE_REQUIRED) { + public static function structure($value = VALUE_REQUIRED) { return new \external_single_structure([ 'id' => new \external_value(PARAM_INT, 'id of connection'), 'from_id' => new \external_value(PARAM_INT, 'id of start item'), diff --git a/classes/studyline.php b/classes/studyline.php index 9f1cb49..d8dc3a5 100644 --- a/classes/studyline.php +++ b/classes/studyline.php @@ -90,7 +90,7 @@ class studyline { return $this->r->shortname; } - public static function editor_structure($value=VALUE_REQUIRED) { + public static function editor_structure($value = VALUE_REQUIRED) { return new \external_single_structure([ "id" => new \external_value(PARAM_INT, 'id of studyline'), "name" => new \external_value(PARAM_TEXT, 'shortname of studyline'), @@ -140,7 +140,7 @@ class studyline { $numslots = max($this->page->periods(), $maxslot +1); // Create the required amount of slots. - for ($i=0; $i < $numslots+1; $i++) { + for ($i = 0; $i < $numslots+1; $i++) { if ($mode == "export") { // Export mode does not separate between filter or competency type, since that is determined automatically. $slots = []; @@ -254,7 +254,7 @@ class studyline { return $list; } - public static function user_structure($value=VALUE_REQUIRED) { + public static function user_structure($value = VALUE_REQUIRED) { return new \external_single_structure([ "id" => new \external_value(PARAM_INT, 'id of studyline'), "name" => new \external_value(PARAM_TEXT, 'shortname of studyline'), @@ -294,7 +294,7 @@ class studyline { $numslots = max($this->page->periods(), $maxslot +1); // Create the required amount of slots. - for ($i=0; $i < $numslots+1; $i++) { + for ($i = 0; $i < $numslots+1; $i++) { if ($i > 0) { $slots = [self::SLOTSET_COMPETENCY => [], self::SLOTSET_FILTER => []]; } else { @@ -356,7 +356,7 @@ class studyline { public function import_studyitems($model, &$itemtranslation, &$connections) { global $DB; - foreach ($model as $slot=> $slotmodel) { + foreach ($model as $slot => $slotmodel) { $courselayer = 0; $filterlayer = 0; foreach ($slotmodel as $itemmodel) { diff --git a/classes/studyplan.php b/classes/studyplan.php index 12cdb5f..bfc0f4d 100644 --- a/classes/studyplan.php +++ b/classes/studyplan.php @@ -95,7 +95,7 @@ class studyplan { return $this->context; } - public static function simple_structure($value=VALUE_REQUIRED) { + public static function simple_structure($value = VALUE_REQUIRED) { return new \external_single_structure([ "id" => new \external_value(PARAM_INT, 'id of studyplan'), "name" => new \external_value(PARAM_TEXT, 'name of studyplan'), @@ -130,7 +130,7 @@ class studyplan { ]; } - public static function editor_structure($value=VALUE_REQUIRED) { + public static function editor_structure($value = VALUE_REQUIRED) { return new \external_single_structure([ "id" => new \external_value(PARAM_INT, 'id of studyplan'), "name" => new \external_value(PARAM_TEXT, 'name of studyplan'), @@ -193,7 +193,7 @@ class studyplan { return $model; } - public static function add($fields, $bare=false) { + public static function add($fields, $bare = false) { global $CFG, $DB; $addable = ['name', 'shortname', 'description', 'idnumber', 'context_id', 'aggregation', 'aggregation_config']; @@ -276,7 +276,7 @@ class studyplan { return $this; } - public function delete($force=false) { + public function delete($force = false) { global $DB; if ($force) { @@ -294,7 +294,7 @@ class studyplan { } } - public static function find_all($contextid=-1) { + public static function find_all($contextid = -1) { global $DB, $USER; $list = []; @@ -443,7 +443,7 @@ class studyplan { } } - public static function user_structure($value=VALUE_REQUIRED) { + public static function user_structure($value = VALUE_REQUIRED) { return new \external_single_structure([ "id" => new \external_value(PARAM_INT, 'id of studyplan'), "name" => new \external_value(PARAM_TEXT, 'name of studyplan'), @@ -482,7 +482,7 @@ class studyplan { public function duplicate($name, $shortname) { // First duplicate the studyplan structure. - $newplan =studyplan::add([ + $newplan = studyplan::add([ 'name' => $name, 'shortname' => $shortname, 'description' => $this->r->description, @@ -535,7 +535,7 @@ class studyplan { return $pages; } - public static function import_studyplan($content, $format="application/json", $contextid=1) { + public static function import_studyplan($content, $format = "application/json", $contextid = 1) { if ($format != "application/json") { return false; } @@ -555,12 +555,12 @@ class studyplan { return $plan->import_pages_model($content["studyplan"]["pages"]); } else { - error_log("Invalid format and type: {$content['type']} version {$content['version']}"); + debugging("Invalid format and type: {$content['type']} version {$content['version']}"); return false; } } - public function import_pages($content, $format="application/json") { + public function import_pages($content, $format = "application/json") { if ($format != "application/json") { return false; } diff --git a/classes/studyplanpage.php b/classes/studyplanpage.php index ed364e4..8ad7c50 100644 --- a/classes/studyplanpage.php +++ b/classes/studyplanpage.php @@ -87,7 +87,7 @@ class studyplanpage { } - public static function simple_structure($value=VALUE_REQUIRED) { + public static function simple_structure($value = VALUE_REQUIRED) { return new \external_single_structure([ "id" => new \external_value(PARAM_INT, 'id of studyplan page'), "fullname" => new \external_value(PARAM_TEXT, 'name of studyplan page'), @@ -113,7 +113,7 @@ class studyplanpage { ]; } - public static function editor_structure($value=VALUE_REQUIRED) { + public static function editor_structure($value = VALUE_REQUIRED) { return new \external_single_structure([ "id" => new \external_value(PARAM_INT, 'id of studyplan'), "fullname" => new \external_value(PARAM_TEXT, 'name of studyplan page'), @@ -193,7 +193,7 @@ class studyplanpage { return $this; } - public function delete($force=false) { + public function delete($force = false) { global $DB; if ($force) { @@ -211,7 +211,7 @@ class studyplanpage { } } - public static function user_structure($value=VALUE_REQUIRED) { + public static function user_structure($value = VALUE_REQUIRED) { return new \external_single_structure([ "id" => new \external_value(PARAM_INT, 'id of studyplan page'), "fullname" => new \external_value(PARAM_TEXT, 'name of studyplan page'), @@ -432,7 +432,7 @@ class studyplanpage { return $lines; } - public function import_periods($content, $format="application/json") { + public function import_periods($content, $format = "application/json") { if ($format != "application/json") { return false; } @@ -446,7 +446,7 @@ class studyplanpage { } } - public function import_studylines($content, $format="application/json") { + public function import_studylines($content, $format = "application/json") { if ($format != "application/json") { return false; } diff --git a/classes/studyplanservice.php b/classes/studyplanservice.php index 0861167..2353663 100644 --- a/classes/studyplanservice.php +++ b/classes/studyplanservice.php @@ -143,7 +143,7 @@ class studyplanservice extends \external_api { } public static function add_studyplan($name, $shortname, $idnumber, $description, $periods, - $startdate, $enddate, $aggregation="bistate", $aggregationconfig='', $contextid=0) { + $startdate, $enddate, $aggregation = "bistate", $aggregationconfig = '', $contextid = 0) { // Check if we have the proper rights for the requested context. $context = webservicehelper::find_context($contextid); webservicehelper::require_capabilities(self::CAP_EDIT, $context); @@ -190,7 +190,7 @@ class studyplanservice extends \external_api { } public static function edit_studyplan($id, $name, $shortname, $idnumber, $description, $periods, $startdate, - $enddate, $aggregation="bistate", $aggregationconfig='', $contextid=0) { + $enddate, $aggregation = "bistate", $aggregationconfig = '', $contextid = 0) { // Validate access in the intended context. $context = webservicehelper::find_context($contextid); // Do not validate the context in this case, just check the permissions. @@ -231,7 +231,7 @@ class studyplanservice extends \external_api { return success::structure(); } - public static function delete_studyplan($id, $force=false) { + public static function delete_studyplan($id, $force = false) { $o = studyplan::findById($id); // Validate if the requesting user has the right to edit the plan in it's current context. webservicehelper::require_capabilities(self::CAP_EDIT, $o->context()); @@ -360,13 +360,13 @@ class studyplanservice extends \external_api { return studyline::reorder($resequence)->model(); } -/*********************************** - * STUDYITEM FUNCTIONS - ***********************************/ + /*********************************** + * STUDYITEM FUNCTIONS + ***********************************/ /************************ * * - * get_studyitem * + * get_studyitem * * * ************************/ @@ -413,7 +413,7 @@ class studyplanservice extends \external_api { return studyitem::editor_structure(); } - public static function add_studyitem($lineid, $type, $details, $slot=-1, $layer=0) { + public static function add_studyitem($lineid, $type, $details, $slot = -1, $layer = 0) { webservicehelper::require_capabilities(self::CAP_EDIT, studyline::findById($lineid)->context()); $o = studyitem::add([ @@ -447,7 +447,7 @@ class studyplanservice extends \external_api { return studyitem::editor_structure(); } - public static function edit_studyitem($id, $conditions, $continuationid=false) { + public static function edit_studyitem($id, $conditions, $continuationid = false) { $o = studyitem::findById($id); webservicehelper::require_capabilities(self::CAP_EDIT, $o->context()); @@ -589,12 +589,10 @@ class studyplanservice extends \external_api { $result = []; $badges = badges_get_badges(BADGE_TYPE_SITE, "timemodified"); foreach ($badges as $badge) { -// TODO: Add config option to list only active badges. -// if ($badge->is_active()) {. - $result[] = (new badgeinfo($badge))->editor_model(); -// }. + // TODO: Add config option to list only active badges. + $result[] = (new badgeinfo($badge))->editor_model(); - // TODO: Include course badges somehow... Just site badges is not enough. + // TODO: Include course badges somehow... Just site badges is not enough. } return $result; @@ -620,7 +618,7 @@ class studyplanservice extends \external_api { return success::structure(); } - public static function include_grade($gradeid, $itemid, $include, $required=false) { + public static function include_grade($gradeid, $itemid, $include, $required = false) { global $USER; // Find related course and course context. @@ -742,7 +740,7 @@ class studyplanservice extends \external_api { $fieldname = "grade"; if ($result && $gi->itemtype == "mod" && $dbman->table_exists($tablename)) { if ($dbman->field_exists($tablename, $fieldname)) { - $gradevalue = intval(0-($scale->id)); + $gradevalue = intval(0 - ($scale->id)); try { $DB->set_field($tablename, $fieldname, $gradevalue, ["id" => $gi->iteminstance]); } catch (\dml_exception $x) { @@ -809,9 +807,9 @@ class studyplanservice extends \external_api { } - /**************************** + /**************************** * * - * disable_autoenddate * + * disable_autoenddate * * * ****************************/ @@ -894,7 +892,7 @@ class studyplanservice extends \external_api { return studyplan::export_structure(); } - public static function export_plan($studyplanid, $format="json") { + public static function export_plan($studyplanid, $format = "json") { try { // Validate permissions. webservicehelper::require_capabilities(self::CAP_EDIT, studyplan::findById($studyplanid)->context()); @@ -951,7 +949,7 @@ class studyplanservice extends \external_api { return success::structure(); } - public static function import_plan($content, $format="application/json", $contextid=1) { + public static function import_plan($content, $format = "application/json", $contextid = 1) { try { // Validate import context. @@ -977,7 +975,7 @@ class studyplanservice extends \external_api { return success::structure(); } - public static function import_studylines($studyplanid, $content, $format="application/json") { + public static function import_studylines($studyplanid, $content, $format = "application/json") { try { $plan = studyplan::findById($studyplanid); @@ -1041,9 +1039,9 @@ class studyplanservice extends \external_api { foreach (explode("&", $formdata) as $pair) { $p = explode("=", $pair, 2); $k = urldecode($p[0]); - $v = (count($p)>1) ? urldecode($p[1]) : ""; + $v = (count($p) > 1) ? urldecode($p[1]) : ""; - if (strpos($k, "[") > 0 && strpos($k, "]") == strlen($k) -1) { + if (strpos($k, "[") > 0 && strpos($k, "]") == strlen($k) - 1) { // Its a bracketet field, like filename[text] which should be separated and put into a named array. list($k, $h) = explode("[", $k, 2); if (strlen($k) > 0 && strlen($h) > 1) { @@ -1053,7 +1051,7 @@ class studyplanservice extends \external_api { } $_POST[$k][$h] = $v; } - }else { + } else { $_POST[$k] = $v; } } @@ -1077,54 +1075,54 @@ class studyplanservice extends \external_api { * * ************************/ - public static function edit_period_parameters() { - return new \external_function_parameters( [ - "id" => new \external_value(PARAM_INT, 'id of study item'), - "fullname" => new \external_value(PARAM_TEXT, 'Full name of period'), - "shortname" => new \external_value(PARAM_TEXT, 'Short name of period'), - "startdate" => new \external_value(PARAM_TEXT, 'start date of period'), - "enddate" => new \external_value(PARAM_TEXT, 'end date of period'), - ]); - } + public static function edit_period_parameters() { + return new \external_function_parameters( [ + "id" => new \external_value(PARAM_INT, 'id of study item'), + "fullname" => new \external_value(PARAM_TEXT, 'Full name of period'), + "shortname" => new \external_value(PARAM_TEXT, 'Short name of period'), + "startdate" => new \external_value(PARAM_TEXT, 'start date of period'), + "enddate" => new \external_value(PARAM_TEXT, 'end date of period'), + ]); + } - public static function edit_period_returns() { - return period::structure(); - } + public static function edit_period_returns() { + return period::structure(); + } - public static function edit_period($id, $fullname, $shortname, $startdate, $enddate) { + public static function edit_period($id, $fullname, $shortname, $startdate, $enddate) { - $p = period::findById($id); - webservicehelper::require_capabilities(self::CAP_EDIT, $p->page()->studyplan()->context()); + $p = period::findById($id); + webservicehelper::require_capabilities(self::CAP_EDIT, $p->page()->studyplan()->context()); - $p->edit([ - 'fullname' => $fullname, - 'shortname' => $shortname, - 'startdate' => $startdate, - 'enddate' => $enddate, - ]); - return $p->model(); + $p->edit([ + 'fullname' => $fullname, + 'shortname' => $shortname, + 'startdate' => $startdate, + 'enddate' => $enddate, + ]); + return $p->model(); - } + } - /************************ - * * - * Change course timing * - * * - ************************/ + /************************ + * * + * Change course timing * + * * + ************************/ - public static function course_period_timing_parameters() { - return new \external_function_parameters( [ - "period_id" => new \external_value(PARAM_INT, 'Period number within page'), - "course_id" => new \external_value(PARAM_INT, 'Id of course to adjust dates for'), - "span" => new \external_value(PARAM_INT, 'Period span (default 1)', VALUE_DEFAULT), - ]); - } + public static function course_period_timing_parameters() { + return new \external_function_parameters( [ + "period_id" => new \external_value(PARAM_INT, 'Period number within page'), + "course_id" => new \external_value(PARAM_INT, 'Id of course to adjust dates for'), + "span" => new \external_value(PARAM_INT, 'Period span (default 1)', VALUE_DEFAULT), + ]); + } - public static function course_period_timing_returns() { - return courseinfo::editor_structure(); - } + public static function course_period_timing_returns() { + return courseinfo::editor_structure(); + } - public static function course_period_timing($periodid, $courseid, $span=1) { + public static function course_period_timing($periodid, $courseid, $span = 1) { global $DB; $period = period::findById($periodid); $periodnr = $period->period(); @@ -1175,27 +1173,27 @@ class studyplanservice extends \external_api { // Probably should return a nice message. throw new \webservice_access_exception("You do not have date change permissions on this course"); } - } + } - public static function set_studyitem_span_parameters() { - return new \external_function_parameters( [ - "id" => new \external_value(PARAM_INT, 'id of study item'), - "span" => new \external_value(PARAM_INT, 'span of item'), - ]); - } + public static function set_studyitem_span_parameters() { + return new \external_function_parameters( [ + "id" => new \external_value(PARAM_INT, 'id of study item'), + "span" => new \external_value(PARAM_INT, 'span of item'), + ]); + } - public static function set_studyitem_span_returns() { - return studyitem::editor_structure(); - } + public static function set_studyitem_span_returns() { + return studyitem::editor_structure(); + } - public static function set_studyitem_span($id, $span=null) { - $o = studyitem::findById($id); - webservicehelper::require_capabilities(self::CAP_EDIT, $o->context()); + public static function set_studyitem_span($id, $span = null) { + $o = studyitem::findById($id); + webservicehelper::require_capabilities(self::CAP_EDIT, $o->context()); - $config = [ 'span' => $span]; - $o->edit($config); - return $o->editor_model(); + $config = [ 'span' => $span]; + $o->edit($config); + return $o->editor_model(); - } + } } diff --git a/classes/success.php b/classes/success.php index 002f893..b0bb4b1 100644 --- a/classes/success.php +++ b/classes/success.php @@ -21,17 +21,16 @@ */ namespace local_treestudyplan; -defined('MOODLE_INTERNAL') || die(); class success { private $success; private $msg; - public static function success($msg="") { + public static function success($msg = "") { return new self(true, $msg); } - public static function fail($msg="") { + public static function fail($msg = "") { return new self(false, $msg); } diff --git a/classes/task/autocohortsync.php b/classes/task/autocohortsync.php index b5ade95..ab4166e 100644 --- a/classes/task/autocohortsync.php +++ b/classes/task/autocohortsync.php @@ -28,7 +28,7 @@ use local_treestudyplan\studyplan; use local_treestudyplan\cascadecohortsync; use local_treestudyplan\cascadeusersync; -class autocohortsync extends \core\task\scheduled_task { +class autocohortsync extends \core\task\scheduled_task { /** * Return the task's name as shown in admin screens. diff --git a/classes/task/refreshteacherlist.php b/classes/task/refreshteacherlist.php index 2ed8aec..9a42287 100644 --- a/classes/task/refreshteacherlist.php +++ b/classes/task/refreshteacherlist.php @@ -26,7 +26,7 @@ defined('MOODLE_INTERNAL') || die(); require_once($CFG->dirroot.'/course/externallib.php'); use local_treestudyplan\teachingfinder; -class refreshteacherlist extends \core\task\scheduled_task { +class refreshteacherlist extends \core\task\scheduled_task { const CACHE_TIME = 4 * 60 * 60; // 2 hours. /** diff --git a/classes/teachingfinder.php b/classes/teachingfinder.php index 5ca0f5f..97ee279 100644 --- a/classes/teachingfinder.php +++ b/classes/teachingfinder.php @@ -21,7 +21,6 @@ */ namespace local_treestudyplan; -defined('MOODLE_INTERNAL') || die(); class teachingfinder { const TABLE = "local_treestudyplan_teachers"; diff --git a/cli/randomize_grades.php b/cli/randomize_grades.php index c6e7188..2bb30a7 100644 --- a/cli/randomize_grades.php +++ b/cli/randomize_grades.php @@ -66,7 +66,7 @@ if ($options['help']) { exit(2); } -/////////////////////////////////. +// Get administrator role and log in as. $user = get_admin(); if (!$user) { @@ -74,7 +74,7 @@ if (!$user) { } $auth = empty($user->auth) ? 'manual' : $user->auth; -if ($auth == 'nologin' or !is_enabled_auth($auth)) { +if ($auth == 'nologin' || !is_enabled_auth($auth)) { cli_error(sprintf("User authentication is either 'nologin' or disabled. Check Moodle authentication method for '%s'", $user->username)); } @@ -84,7 +84,7 @@ $authplugin->sync_roles($user); login_attempt_valid($user); complete_user_login($user); -////////////////////////////////. +// Handle the studyplans. if (empty($options['studyplan']) && empty($options["all"])) { cli_error('Missing mandatory argument studyplan.', 2); diff --git a/db/access.php b/db/access.php index 038f8b2..830d600 100644 --- a/db/access.php +++ b/db/access.php @@ -19,6 +19,7 @@ * @copyright 2023 P.M. Kuipers * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ +defined('MOODLE_INTERNAL') || die(); $capabilities = [ diff --git a/db/itemsetup.txt b/db/itemsetup.txt deleted file mode 100644 index 80ba303..0000000 --- a/db/itemsetup.txt +++ /dev/null @@ -1,18 +0,0 @@ - SLOT INDEX 0 SLOT INDEX [1,slots] ---------------- -------------------------------------- -[FILTER SLOT] [ [COMPETENCY SLOT] [FILTER SLOT ] ] -Types allowed Types allowed Types allowed -- START - COMPETENCY - JUNCTION - - BADGE - - FINISH - - CONTINUATION - - -Type description -- START : Copies the state of an ITEM (FINISH ITEM) in another studyplan. It is used to allow continuation across studyplans -- COMPETENCY : -- JUNCTION : -- BADGE : -- FINISH : Denotes the final outcome of a studyline in a studyplan - -CONDITIONS: \ No newline at end of file diff --git a/db/services.php b/db/services.php index 8d37ec8..145b96d 100644 --- a/db/services.php +++ b/db/services.php @@ -20,6 +20,8 @@ * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ +defined('MOODLE_INTERNAL') || die(); + $services = [ "Competency listing" => [ 'functions' => [ @@ -571,7 +573,7 @@ $functions = [ 'ajax' => true, 'loginrequired' => true, ], - 'local_treestudyplan_set_studyitem_span' => [ // Web service function name. + 'local_treestudyplan_set_studyitem_span' => [ // Web service function name. 'classname' => '\local_treestudyplan\studyplanservice', // Class containing the external function. 'methodname' => 'set_studyitem_span', // External function name. 'description' => 'Change the span of a course item', diff --git a/db/tasks.php b/db/tasks.php index cd6f1dd..bc26053 100644 --- a/db/tasks.php +++ b/db/tasks.php @@ -19,6 +19,7 @@ * @copyright 2023 P.M. Kuipers * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ +defined('MOODLE_INTERNAL') || die(); $tasks = [ [ diff --git a/db/upgrade.php b/db/upgrade.php index 772d110..4dff8bd 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -311,7 +311,7 @@ function xmldb_local_treestudyplan_upgrade($oldversion) { $plans->close(); } - /** + /******* * Finalize studyline table to drop studyplan_id field and have page id be a non-nullable and foreign key */ @@ -338,7 +338,7 @@ function xmldb_local_treestudyplan_upgrade($oldversion) { // Launch add key page_id-id. $dbman->add_key($table, $key); - /*** + /******* * Create Period table and make a period record for all studyplan periods */ @@ -368,20 +368,20 @@ function xmldb_local_treestudyplan_upgrade($oldversion) { // Make a best guess for the periods based on the specified period for the plan and the . $pcount = $r->periods; - $ystart = strtotime($r->startdate)+0; - $yend = strtotime($r->enddate)+0; + $ystart = strtotime($r->startdate) + 0; + $yend = strtotime($r->enddate) + 0; if ($yend < $ystart) { // If no end time is given, assume a year duration for period calculations. - $ydelta = (365*24*60*60)/$pcount; + $ydelta = (365 * 24 * 60 * 60) / $pcount; } else { $ydelta = $yend - $ystart; } $ptime = $ydelta / $pcount; - for ($i=0; $i < $pcount; $i++) { - $pnum = $i+1; - $pstart = $ystart + ($i*$ptime); - $pend = ($pstart + $ptime)-(24*60*60); // Minus one day. + for ($i = 0; $i < $pcount; $i++) { + $pnum = $i + 1; + $pstart = $ystart + ($i * $ptime); + $pend = ($pstart + $ptime) - (24 * 60 * 60); // Minus one day. $o = [ "page_id" => $r->id, "period" => $pnum, diff --git a/edit-invite.php b/edit-invite.php index 63d8cfa..c6fc2af 100644 --- a/edit-invite.php +++ b/edit-invite.php @@ -59,7 +59,7 @@ if (!empty($add)) { $data = $DB->get_record("local_treestudyplan_invit", array('id' => $update)); $data->update = $update; if (empty($data) || $data->user_id != $USER->id) { - print_error('invalidaction'); + throw new \moodle_exception('invalidaction', 'local_treestudyplan');; exit; } @@ -67,7 +67,7 @@ if (!empty($add)) { $data = $DB->get_record("local_treestudyplan_invit", array('id' => $resend)); $data->resend = $resend; if (empty($data) || $data->user_id != $USER->id) { - print_error('invalidaction'); + throw new \moodle_exception('invalidaction', 'local_treestudyplan');; exit; } @@ -80,7 +80,7 @@ if (!empty($add)) { $data = $DB->get_record("local_treestudyplan_invit", array('id' => $delete)); $data->delete = $delete; if (empty($data) || $data->user_id != $USER->id) { - print_error('invalidaction'); + throw new \moodle_exception('invalidaction', 'local_treestudyplan');; exit; } @@ -90,7 +90,7 @@ if (!empty($add)) { print $OUTPUT->footer(); exit; } else { - print_error('invalidaction'); + throw new \moodle_exception('invalidaction', 'local_treestudyplan');; } $mform = new reportinvite_form(); @@ -120,9 +120,8 @@ if ($mform->is_cancelled()) { exit; } else if (!empty($data->delete)) { exit; - } else - { - print_error("invaliddata"); + } else { + throw new \moodle_exception("invaliddata", 'local_treestudyplan');; } exit; diff --git a/edit-plan.php b/edit-plan.php index 77eebbe..1906ef6 100644 --- a/edit-plan.php +++ b/edit-plan.php @@ -41,14 +41,13 @@ if ($categoryid > 0) { $studyplancontext = context::instance_by_id($contextid); if (in_array($studyplancontext->contextlevel, [CONTEXT_SYSTEM, CONTEXT_COURSECAT])) { $categoryid = $studyplancontext->instanceid; - } else - { + } else { $studyplancontext = $systemcontext; } } else { // If no context is selected, find the first available one. $availablecontexts = courseservice::list_accessible_categories_with_usage("edit"); - $contextid=1; // Fallback to system context. + $contextid = 1; // Fallback to system context. foreach ($availablecontexts as $ctx) { if ($ctx->count > 0) { $contextid = $ctx->ctxid; @@ -82,7 +81,7 @@ $PAGE->requires->js_call_amd('local_treestudyplan/page-edit-plan', 'init', [$stu $catlist = courseservice::list_accessible_categories_with_usage("edit"); // Local translate function. -function t($str, $param=null, $plugin='local_treestudyplan') { +function t($str, $param = null, $plugin = 'local_treestudyplan') { print get_string($str, $plugin, $param); } diff --git a/invitations.php b/invitations.php index 1635b7a..336f0b6 100644 --- a/invitations.php +++ b/invitations.php @@ -20,24 +20,16 @@ * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -if (isset($_SERVER['SCRIPT_FILENAME'])) { - // If SCRIPT_FILENAME is set, use that so the symlinked directories the developmen environment uses are handled correctly. - $root = dirname(dirname(dirname($_SERVER['SCRIPT_FILENAME']))); - error_log("Using {$root}/config.php"); - require_once($root."/config.php"); -} else { - // If not, assume the cwd is not symlinked and proceed as we are used to. - require_once("../../config.php"); -} + +require_once("../../config.php"); require_once($CFG->libdir.'/weblib.php'); require_once($CFG->dirroot.'/grade/querylib.php'); use local_treestudyplan; -$INVITEDURL = "/local/treestudyplan/invited.php"; +$invitedurl = "/local/treestudyplan/invited.php"; - // Admin_externalpage_setup('major');. $systemcontext = context_system::instance(); $PAGE->set_url("/local/treestudyplan/invitations.php", array()); @@ -52,7 +44,7 @@ $PAGE->set_heading(get_string('manage_invites', 'local_treestudyplan')); $PAGE->requires->js_call_amd('local_treestudyplan/page-invitemanager', 'init'); $PAGE->requires->js_call_amd('local_treestudyplan/buttonlinks', 'init'); -// retrieve list of courses that the student is enrolled in. +// Retrieve list of courses that the student is enrolled in. $sent = optional_param('sent', '', PARAM_INT); if (!empty($sent)) { $invite = $DB->get_record('local_treestudyplan_invit', array('id' => $sent)); @@ -78,7 +70,7 @@ print ""; print ""; if (count($invites) > 0) { foreach ($invites as $invite) { - $testlink = $INVITEDURL."?key={$invite->invitekey}"; + $testlink = $invitedurl."?key={$invite->invitekey}"; print ""; print "{$invite->name}"; print "{$invite->email}"; diff --git a/invited.php b/invited.php index 98905e5..d521ce9 100644 --- a/invited.php +++ b/invited.php @@ -21,9 +21,10 @@ */ require_once("../../config.php"); +// Since this page is externally accessed and validated in a different way, no login is needed. - // Local translate function. -function t($str, $param=null, $plugin='local_treestudyplan') { +// Local translate function. +function t($str, $param = null, $plugin = 'local_treestudyplan') { print get_string($str, $plugin, $param); } diff --git a/lib.php b/lib.php index 7d9b0ad..5e66829 100644 --- a/lib.php +++ b/lib.php @@ -20,17 +20,19 @@ * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -require_once($CFG->dirroot.'/course/modlib.php'); + defined('MOODLE_INTERNAL') || die(); + require_once($CFG->dirroot.'/course/modlib.php'); use local_treestudyplan\local\helpers\webservicehelper; use \local_treestudyplan\studyplan; -defined('MOODLE_INTERNAL') || die(); + function local_treestudyplan_unit_get_editor_options($context) { global $CFG; return ['subdirs' => 1, 'maxbytes' => $CFG->maxbytes, - 'maxfiles' =>-1, 'changeformat' => 1, + 'maxfiles' => -1, + 'changeformat' => 1, 'context' => $context, 'noclean' => 1, 'trusttext' => 0]; @@ -56,7 +58,7 @@ function local_treestudyplan_extend_navigation(global_navigation $navigation) { and not much more complex than loading a separate stylesheet for each link we want to hide). We will add all the hrefs that should be hidden to this variable below. */ - $hideprimary_hrefs = []; + $hideprimaryhrefs = []; if ($USER->id > 1) { // Don't show if user is not logged in (id == 0) or is guest user (id == 1). @@ -74,7 +76,7 @@ function local_treestudyplan_extend_navigation(global_navigation $navigation) { new pix_icon("myreport", '', 'local_treestudyplan') ); $node->showinflatnavigation = true; - $node->showinsecondarynavigation=true; + $node->showinsecondarynavigation = true; // Create invitenode node. $invitenode = navigation_node::create( @@ -90,7 +92,7 @@ function local_treestudyplan_extend_navigation(global_navigation $navigation) { $navigation->add_node($node, 'mycourses'); } else { - $hideprimary_hrefs[] = "/local/treestudyplan/myreport.php"; + $hideprimaryhrefs[] = "/local/treestudyplan/myreport.php"; } if ( has_capability('local/treestudyplan:viewuserreports', context_system::instance()) || webservicehelper::has_capability_in_any_category('local/treestudyplan:viewuserreports')) { @@ -103,10 +105,10 @@ function local_treestudyplan_extend_navigation(global_navigation $navigation) { new pix_icon("viewplans", '', 'local_treestudyplan') ); $node->showinflatnavigation = true; - $node->showinsecondarynavigation=true; + $node->showinsecondarynavigation = true; $navigation->add_node($node, 'mycourses'); } else { - $hideprimary_hrefs[] = "/local/treestudyplan/view-plan.php"; + $hideprimaryhrefs[] = "/local/treestudyplan/view-plan.php"; } if ( has_capability('local/treestudyplan:editstudyplan', context_system::instance()) || webservicehelper::has_capability_in_any_category('local/treestudyplan:editstudyplan') @@ -120,15 +122,15 @@ function local_treestudyplan_extend_navigation(global_navigation $navigation) { new pix_icon("viewplans", '', 'local_treestudyplan') ); $node->showinflatnavigation = true; - $node->showinsecondarynavigation=true; + $node->showinsecondarynavigation = true; $navigation->add_node($node, 'mycourses'); } else { - $hideprimary_hrefs[] = "/local/treestudyplan/edit-plan.php"; + $hideprimaryhrefs[] = "/local/treestudyplan/edit-plan.php"; } } else { - $hideprimary_hrefs[] = "/local/treestudyplan/myreport.php"; - $hideprimary_hrefs[] = "/local/treestudyplan/edit-plan.php"; - $hideprimary_hrefs[] = "/local/treestudyplan/view-plan.php"; + $hideprimaryhrefs[] = "/local/treestudyplan/myreport.php"; + $hideprimaryhrefs[] = "/local/treestudyplan/edit-plan.php"; + $hideprimaryhrefs[] = "/local/treestudyplan/view-plan.php"; } // Create invitenode node. $invitenode = navigation_node::create( @@ -143,7 +145,7 @@ function local_treestudyplan_extend_navigation(global_navigation $navigation) { $navigation->add_node($invitenode, 'mycourses'); // Now using some javascript magic, we'll hide the links that are not accessible. - $PAGE->requires->js_call_amd('local_treestudyplan/primary-nav-tools', 'hide_primary', [$hideprimary_hrefs]); + $PAGE->requires->js_call_amd('local_treestudyplan/primary-nav-tools', 'hide_primary', [$hideprimaryhrefs]); } @@ -275,9 +277,11 @@ function local_treestudyplan_get_cohort_path($cohort) { $cohortcontext = context::instance_by_id($cohort->contextid); if ($cohortcontext && $cohortcontext->id != SYSCONTEXTID) { $ctxpath = array_map( - function($ctx) { return $ctx->get_context_name(false);}, + function($ctx) { + return $ctx->get_context_name(false); + }, $cohortcontext->get_parent_contexts(true) - ); + ); array_pop($ctxpath); // Pop system context off the list. $ctxpath = array_reverse($ctxpath); $ctxpath[] = $cohort->name; @@ -313,7 +317,7 @@ function local_treestudyplan_output_fragment_mod_edit_form($args) { if (file_exists($modmoodleform)) { require_once($modmoodleform); } else { - print_error('noformdesc'); + throw new \moodle_exception('noformdesc', 'local_treestudyplan');; } $mformclassname = 'mod_'.$module->name.'_mod_form'; diff --git a/myreport-embed.php b/myreport-embed.php index 6cd2446..1e6bbf7 100644 --- a/myreport-embed.php +++ b/myreport-embed.php @@ -42,7 +42,7 @@ $PAGE->requires->css(new moodle_url($CFG->wwwroot.'/local/treestudyplan/css/devs $PAGE->requires->js_call_amd('local_treestudyplan/page-myreport', 'init'); // Local translate function. -function t($str, $param=null, $plugin='local_treestudyplan') { +function t($str, $param = null, $plugin = 'local_treestudyplan') { print get_string($str, $plugin, $param); } diff --git a/myreport.php b/myreport.php index 3cae6b2..3024c81 100644 --- a/myreport.php +++ b/myreport.php @@ -50,7 +50,7 @@ $PAGE->requires->css(new moodle_url($CFG->wwwroot.'/local/treestudyplan/css/devs $PAGE->requires->js_call_amd('local_treestudyplan/page-myreport', 'init', [$teachermode ? 'teaching' : 'myreport']); // Local translate function. -function t($str, $param=null, $plugin='local_treestudyplan') { +function t($str, $param = null, $plugin = 'local_treestudyplan') { print get_string($str, $plugin, $param); } diff --git a/test/simpleline-test.html b/test/simpleline-test.html deleted file mode 100644 index d0efcac..0000000 --- a/test/simpleline-test.html +++ /dev/null @@ -1,64 +0,0 @@ - - - - - - - -
-

Header

-
-
-
Random text to show stuff
-
-
-
-
-
More random text
-
-
-
-
-
Random text to show stuff
-
-
More random text
-
- - \ No newline at end of file diff --git a/view-plan.php b/view-plan.php index d9d3be0..23488c9 100644 --- a/view-plan.php +++ b/view-plan.php @@ -41,14 +41,13 @@ if ($categoryid > 0) { $studyplancontext = context::instance_by_id($contextid); if (in_array($studyplancontext->contextlevel, [CONTEXT_SYSTEM, CONTEXT_COURSECAT])) { $categoryid = $studyplancontext->instanceid; - } else - { + } else { $studyplancontext = $systemcontext; } } else { // If no context is selected, find the first available one. $availablecontexts = courseservice::list_accessible_categories_with_usage("view"); - $contextid=1; // Fallback to system context. + $contextid = 1; // Fallback to system context. foreach ($availablecontexts as $ctx) { if ($ctx->count > 0) { $contextid = $ctx->ctxid; @@ -80,7 +79,7 @@ $PAGE->requires->css(new moodle_url($CFG->wwwroot.'/local/treestudyplan/css/devs $PAGE->requires->js_call_amd('local_treestudyplan/page-view-plan', 'init', [$studyplancontext->id, $categoryid]); // Local translate function. -function t($str, $param=null, $plugin='local_treestudyplan') { +function t($str, $param = null, $plugin = 'local_treestudyplan') { print get_string($str, $plugin, $param); }