Fixed phpdocs

This commit is contained in:
PMKuipers 2024-06-03 04:00:46 +02:00
parent 520034bb5f
commit 2268aba9d5
23 changed files with 138 additions and 139 deletions

View File

@ -134,8 +134,8 @@ class associationservice extends \external_api {
/** /**
* Get last access time of user to any of the courses in the studyplan * Get last access time of user to any of the courses in the studyplan
* @param $userid ID of user * @param int $userid ID of user
* @param $studyplanid ID of studyplan * @param int $studyplanid ID of studyplan
*/ */
public static function user_lastaccess($userid, $studyplanid=null) { public static function user_lastaccess($userid, $studyplanid=null) {
global $DB; global $DB;
@ -224,8 +224,7 @@ class associationservice extends \external_api {
/** /**
* Search users for match * Search users for match
* @param string $like String to match user firstname/lastname with * @param string $like String to match user firstname/lastname with
* @param null $excludeid Do not include these users * @param int $studyplanid Id of studyplan to search for
* @param int $contextid Context to search (default system)
* @return array * @return array
*/ */
public static function find_user($like, $studyplanid) { public static function find_user($like, $studyplanid) {
@ -807,7 +806,7 @@ class associationservice extends \external_api {
public static function find_coach_parameters(): \external_function_parameters { public static function find_coach_parameters(): \external_function_parameters {
return new \external_function_parameters( [ return new \external_function_parameters( [
'like' => new \external_value(PARAM_TEXT, 'search text'), 'like' => new \external_value(PARAM_TEXT, 'search text'),
'studyplan_id' => new \external_value(PARAM_INT, 'studyplan id to associate for', VALUE_OPTIONAL), 'studyplan_id' => new \external_value(PARAM_INT, 'studyplan id to associate for'),
] ); ] );
} }
@ -821,8 +820,7 @@ class associationservice extends \external_api {
/** /**
* Search users for match * Search users for match
* @param string $like String to match user firstname/lastname with * @param string $like String to match user firstname/lastname with
* @param null $excludeid Do not include coaches connected to this studyplan id * @param int $studyplanid Id of studyplan to search for
* @param int $contextid Context to search (default system)
* @return array * @return array
*/ */
public static function find_coach($like, $studyplanid) { public static function find_coach($like, $studyplanid) {

View File

@ -119,7 +119,6 @@ class badgeinfo {
/** /**
* Webservice model for editor info * Webservice model for editor info
* @param int[] $studentlist List of user id's to use for checking issueing progress within a study plan
* @return array Webservice data model * @return array Webservice data model
*/ */
public function simple_model() { public function simple_model() {
@ -395,7 +394,7 @@ class badgeinfo {
/** /**
* Gets the module instance from the database and returns it. * Gets the module instance from the database and returns it.
* If no module instance exists this function returns false. * If no module instance exists this function returns false.
* * @param int $cmid Course module id
* @return stdClass|bool * @return stdClass|bool
*/ */
private static function get_mod_instance($cmid) { private static function get_mod_instance($cmid) {
@ -416,7 +415,7 @@ class badgeinfo {
/** /**
* Gets role name. * Gets role name.
* If no such role exists this function returns null. * If no such role exists this function returns null.
* * @param int $rid Role id
* @return string|null * @return string|null
*/ */
private static function get_role_name($rid) { private static function get_role_name($rid) {
@ -431,10 +430,9 @@ class badgeinfo {
} }
/** /**
* [Description for get_award_subcriteria] * Get subcriteria info for awarding a badge for a user
* * @param award_criteria $crit The criteria to build info for
* @param award_criteria $crit * @param int|null $userid Optional userid to check subcriteria completion for
*
* @return array * @return array
* *
*/ */
@ -872,18 +870,15 @@ class badgeinfo {
} }
/** /**
* [Description for find_page_related_badges] * Find badges related to a page
* * @param studyplanpage $page Page to search for/in
* @param studyplanpage $page * @param mixed $search Search string to use
* @param mixed $search="" * @param mixed $active Include only active badges
* @param mixed $active=false * @param mixed $includecoursebadges Include course badges
* @param mixed $includecoursebadges=true
*
* @return array of badgeinfo * @return array of badgeinfo
* *
*/ */
public static function find_page_related_badges(studyplanpage $page, $search="", $active=false, $includecoursebadges=true) { public static function find_page_related_badges(studyplanpage $page, $search="", $active=false, $includecoursebadges=true) {
$badgeids = []; $badgeids = [];
foreach (studyline::find_page_children($page) as $line) { foreach (studyline::find_page_children($page) as $line) {
foreach (studyitem::find_studyline_children($line) as $item) { foreach (studyitem::find_studyline_children($line) as $item) {

View File

@ -107,7 +107,7 @@ class cascadecohortsync {
/** /**
* Find all cohort sync instances for a specific course * Find all cohort sync instances for a specific course
* @param int courseid * @param int $courseid Id of course to search for
*/ */
private function list_cohortsyncs($courseid) { private function list_cohortsyncs($courseid) {
global $DB; global $DB;
@ -131,7 +131,7 @@ class cascadecohortsync {
/** /**
* Remove this studyplan reference from cohort sync * Remove this studyplan reference from cohort sync
* @param object $enrollinstance * @param object $enrolinstance Enrol instance to unlink or update
*/ */
private function unlink_cohortsync($enrolinstance) { private function unlink_cohortsync($enrolinstance) {
// So it may or may not need to be removed. // So it may or may not need to be removed.
@ -183,6 +183,7 @@ class cascadecohortsync {
/** /**
* Enroll all cohorts associated to the studyplan in the courses linked to the specified study line * Enroll all cohorts associated to the studyplan in the courses linked to the specified study line
* @param studyline $line Studyline to sync enrolment for
*/ */
public function syncline(studyline $line) { public function syncline(studyline $line) {
global $DB; global $DB;

View File

@ -85,6 +85,7 @@ class cascadeusersync {
/** /**
* Enroll all cohorts associated to the studyplan in the courses linked to the specified study line * Enroll all cohorts associated to the studyplan in the courses linked to the specified study line
* @param studyline $line Studyline to sync enrolment for
*/ */
public function syncline(studyline $line) { public function syncline(studyline $line) {
// Find the courses that need to be synced to the associated cohorts. // Find the courses that need to be synced to the associated cohorts.
@ -106,8 +107,8 @@ class cascadeusersync {
} }
/** Enrol a list of users into a specific course /** Enrol a list of users into a specific course
* * @param int $courseid Id of the course
* * @param array $userids List of userids to enrol
*/ */
private function perform_enrol($courseid, $userids) { private function perform_enrol($courseid, $userids) {
global $DB; global $DB;

View File

@ -71,7 +71,7 @@ class contextinfo {
/** /**
* Return context path names * Return context path names
* @param $short Use short names of contexts in path * @param bool $short Use short names of contexts in path
* @return array of context path names * @return array of context path names
*/ */
public function path($short=false) { public function path($short=false) {
@ -88,7 +88,7 @@ class contextinfo {
/** /**
* Return full context path name * Return full context path name
* @param $short Use short names of contexts in path * @param bool $short Use short names of contexts in path
* @return string Concatenated string of paths * @return string Concatenated string of paths
*/ */
public function pathstr($short=false) { public function pathstr($short=false) {

View File

@ -617,7 +617,7 @@ class corecompletioninfo {
/** /**
* Get the overall grade for this course * Get the overall grade for this course
* @param int $userid ID of user to retrieve grade for * @param int $grade The grade object to format
* @return stdClass|null object containing 'grade' and optional 'feedback' attribute * @return stdClass|null object containing 'grade' and optional 'feedback' attribute
*/ */
private function format_course_grade($grade) { private function format_course_grade($grade) {

View File

@ -56,6 +56,7 @@ class coursecompetencyinfo {
/** /**
* Construct new object for a given course * Construct new object for a given course
* @param \stdClass $course Course database record * @param \stdClass $course Course database record
* @param studyitem $studyitem Studyitem the course is linked in
*/ */
public function __construct($course, $studyitem) { public function __construct($course, $studyitem) {
global $DB; global $DB;
@ -95,7 +96,7 @@ class coursecompetencyinfo {
/** /**
* Generic competency info structure for individual competency stats * Generic competency info structure for individual competency stats
* @param $recurse True if child competencies may be included * @param bool $recurse True if child competencies may be included
*/ */
public static function competencyinfo_structure($recurse=true): \external_description { public static function competencyinfo_structure($recurse=true): \external_description {
$struct = [ $struct = [
@ -156,7 +157,8 @@ class coursecompetencyinfo {
/** /**
* Create basic competency information model from competency * Create basic competency information model from competency
* @param Object $competency * @param object $competency The competency to model
* @param int|null $userid Optional userid to include completion data for
*/ */
private function competencyinfo_model($competency, $userid=null): array { private function competencyinfo_model($competency, $userid=null): array {
$displayfield = get_config("local_treestudyplan", "competency_displayname"); $displayfield = get_config("local_treestudyplan", "competency_displayname");
@ -614,7 +616,8 @@ class coursecompetencyinfo {
} }
/** /**
* Check if this gradable item is marked required in the studyitem * Check if this competency is marked required in the studyitem
* @param object $competency The competency to check
* @return bool * @return bool
*/ */
public function is_required($competency) { public function is_required($competency) {

View File

@ -303,7 +303,6 @@ class courseinfo {
/** /**
* Webservice model for editor info * Webservice model for editor info
* @param studyitem $studyitem Specify a specific study item to check gradable selections for. Leave empty to use default
* @return array Webservice data model * @return array Webservice data model
*/ */
public function editor_model() { public function editor_model() {
@ -497,7 +496,7 @@ class courseinfo {
/** /**
* Webservice model for basic info * Webservice model for basic info
* @param $includeteachervisible Include custom fiel * @param bool $includeteachervisible Set to true if in teacher mode, so fields set to visible as teacher will show
* @return array Webservice data model * @return array Webservice data model
*/ */
public function extrafields_model($includeteachervisible=false) { public function extrafields_model($includeteachervisible=false) {
@ -555,6 +554,8 @@ class courseinfo {
/** /**
* Determine value and type of an extra field for this course * Determine value and type of an extra field for this course
* @param string $fieldname The name if the extra field
* @param bool $includeteachervisible Set to true if in teacher mode, so fields set to visible as teacher will show
* @return array [value, type] of the field for this * @return array [value, type] of the field for this
*/ */
protected function extrafields_value($fieldname, $includeteachervisible=false) { protected function extrafields_value($fieldname, $includeteachervisible=false) {

View File

@ -54,6 +54,7 @@ class courseservice extends \external_api {
* Most of the work is offloaded to an SQL query in the interest of speed, * Most of the work is offloaded to an SQL query in the interest of speed,
* but moodle functions are used to double check access permissions. * but moodle functions are used to double check access permissions.
* @param int $userid Id of the user * @param int $userid Id of the user
* @param string $capability Capability the user must posess in the category to include it in the list.
* @return array of core_course_category * @return array of core_course_category
*/ */
public static function user_tops($userid=null, $capability='moodle/category:viewcourselist') { public static function user_tops($userid=null, $capability='moodle/category:viewcourselist') {
@ -143,6 +144,7 @@ class courseservice extends \external_api {
* Find the top-most child categories for a given category that are visible. * Find the top-most child categories for a given category that are visible.
* *
* @param int $parentid The category to search for * @param int $parentid The category to search for
* @param int $userid The id of the user to determine visibility for
* @return array of \core_course_category * @return array of \core_course_category
*/ */
private static function get_first_visible_children($parentid, $userid) { private static function get_first_visible_children($parentid, $userid) {
@ -239,7 +241,7 @@ class courseservice extends \external_api {
/** /**
* Get a category map, and optionally specify a root category to search for * Get a category map, and optionally specify a root category to search for
* User's top category will be used if none specified * User's top category will be used if none specified
* @param int $rootid Optional starting category for the map * @param int $studyplanid Optional id of the studyplan to whose context to limit the search to (if so configures)
* @return array * @return array
*/ */
public static function map_categories($studyplanid = 0) { public static function map_categories($studyplanid = 0) {
@ -352,7 +354,6 @@ class courseservice extends \external_api {
/** /**
* List all user visible categories the current user has a given capability for. * List all user visible categories the current user has a given capability for.
* @param mixed $capability * @param mixed $capability
* @param core_course_category|null $parent
* @return array * @return array
*/ */
public static function categories_by_capability($capability) { public static function categories_by_capability($capability) {

View File

@ -29,8 +29,8 @@ use JsonException;
class debug { class debug {
/** /**
* Dump an object in json format to debug log * Dump an object in json format to debug log
* @param $object Object to dump * @param mixed $object Object to dump
* @param $filename File to write to * @param string $filename File to write to
* @return any The object * @return any The object
*/ */
public static function &dump(&$object, $filename="/tmp/debug.log") { public static function &dump(&$object, $filename="/tmp/debug.log") {
@ -52,12 +52,10 @@ class debug {
return $object; return $object;
} }
/** /**
* Write text to debug log * Write text to debug log file
* @param $object Object to dump * @param string $text Text to write
* @param $filename File to write to * @param string $filename File to write to
* @return any The object * @return any The object
*/ */
public static function write($text, $filename="/tmp/debug.log") { public static function write($text, $filename="/tmp/debug.log") {
@ -70,18 +68,5 @@ class debug {
fclose($f); fclose($f);
} }
} }
/**
* Write nothing to the file. (Used to satisfy the code checker)
* @param $filename File to write to
* @return any The object
*/
public static function void($filename="/tmp/debug.log") {
try {
$f = fopen($filename, "a+");
} catch (\Exception $x) {
$f = null;
} finally {
fclose($f);
}
}
} }

View File

@ -58,7 +58,7 @@ abstract class formbase extends \moodleform {
* Generate form data from parameters * Generate form data from parameters
* Also validate parameters and access permissions here * Also validate parameters and access permissions here
* *
* @param object $customdata The parameters for form initialization * @param object $customdata The form customdata built on form initialization in self::init_customdata(...)
* @return array Form data based on parameters * @return array Form data based on parameters
*/ */
abstract public function init_formdata(object $customdata); abstract public function init_formdata(object $customdata);
@ -67,9 +67,9 @@ abstract class formbase extends \moodleform {
* Validate security access for this form based on the provided parameters * Validate security access for this form based on the provided parameters
* Return true if validation passes, false or throw an exception if it does not. * Return true if validation passes, false or throw an exception if it does not.
* *
* @param object $params The parameters for form initialization * @param object $customdata The form customdata built on form initialization
* @return bool True if security validation passes. * @return bool True if security validation passes.
* @throws \moodle_exception if access denied for a specific reason. * @throws \moodle_exception if access denied for a specific reason in self::init_customdata(...)
*/ */
public static function check_security(object $customdata) { public static function check_security(object $customdata) {
return true; return true;

View File

@ -61,6 +61,7 @@ class webservicehelper {
/** /**
* Test if the current user has a certain capability in any of the categories they have access to * Test if the current user has a certain capability in any of the categories they have access to
* @param string $capability The capability to scan for in the categories * @param string $capability The capability to scan for in the categories
* @param int|null $userid Userid to use in check (Use current user if null or empty)
* @return boolean * @return boolean
*/ */
public static function has_capability_in_any_category($capability, $userid=null ) { public static function has_capability_in_any_category($capability, $userid=null ) {

View File

@ -60,7 +60,7 @@ class randomimage {
/** /**
* Various available styles for arcs * Various available styles for arcs
* @var Arary * @var array
*/ */
const ARC_STYLES = [ const ARC_STYLES = [
IMG_ARC_PIE, IMG_ARC_PIE,
@ -72,10 +72,10 @@ class randomimage {
/** /**
* Create a random polygon with number of points between 0 & $maxpts * Create a random polygon with number of points between 0 & $maxpts
* @param \GdImage $im The image reource * @param \GdImage $im The image reource
* @param integer $maxpts Max number of point to use * @param int $maxpts Max number of point to use
* @return void * @return void
*/ */
private function random_polygon($im, Int $maxpts = 20) { private function random_polygon($im, int $maxpts = 20) {
$color = imagecolorallocatealpha($im, ...$this->random_color_alpha()); $color = imagecolorallocatealpha($im, ...$this->random_color_alpha());
$numpoints = \random_int(3, $maxpts); $numpoints = \random_int(3, $maxpts);
$pts = $this->random_pts($numpoints); $pts = $this->random_pts($numpoints);

View File

@ -299,6 +299,7 @@ Klc5I28bGbvxIV5pnL6ZSjHEDp2WreM8HB0XFJwU+Q==
/** /**
* Check if the current site matches the provided key * Check if the current site matches the provided key
* @param string $key Website pattern to match against
*/ */
private static function website_match($key) { private static function website_match($key) {
global $CFG; global $CFG;
@ -463,6 +464,7 @@ Klc5I28bGbvxIV5pnL6ZSjHEDp2WreM8HB0XFJwU+Q==
/** /**
* Throw an error if premium status is not enabled * Throw an error if premium status is not enabled
* @param string $message Message translation key to use in exception
*/ */
public static function require_premium($message="premiumfeature:warning") { public static function require_premium($message="premiumfeature:warning") {
if (! self::enabled()) { if (! self::enabled()) {

View File

@ -151,10 +151,10 @@ class reportservice extends \external_api {
/** /**
* Webservice function get_report data * Webservice function get_report data
* @param int $pageid * @param int $pageid Id of the studyplan page to build the report for
* @param int $userid * @param int $userid ID ofthe user to gather the report for
* @param int|null $firsteperiod * @param int|null $firstperiod First period of the page to include in the report (first of page if left empty)
* @param int|null $lastperiod * @param int|null $lastperiod Last period of the page to include in the report (last of page if left empty)
*/ */
public static function get_report_data($pageid, $userid, $firstperiod=null, $lastperiod=null) { public static function get_report_data($pageid, $userid, $firstperiod=null, $lastperiod=null) {
$page = studyplanpage::find_by_id($pageid); $page = studyplanpage::find_by_id($pageid);

View File

@ -461,7 +461,7 @@ class studentstudyplanservice extends \external_api {
/** /**
* Get studyplanpage for current user * Get studyplanpage for current user
* @param int $pagid ID of specific studyplan page * @param int $pageid ID of specific studyplan page
* @return array * @return array
*/ */
public static function get_own_page($pageid) { public static function get_own_page($pageid) {
@ -505,8 +505,7 @@ class studentstudyplanservice extends \external_api {
} }
/** /**
* Get all or one studyplan the current user is teaching in * Get all studyplans the current user is teaching in
* @param int $id Optional specific id of studyplan
* @return array * @return array
*/ */
public static function list_teaching_studyplans() { public static function list_teaching_studyplans() {
@ -546,8 +545,7 @@ class studentstudyplanservice extends \external_api {
} }
/** /**
* Get all or one studyplan the current user is teaching in * Get all studyplans the current user is coaching
* @param int $id Optional specific id of studyplan
* @return array * @return array
*/ */
public static function list_coaching_studyplans() { public static function list_coaching_studyplans() {
@ -641,14 +639,12 @@ class studentstudyplanservice extends \external_api {
} }
/** /**
* Get all or one studyplan the current user is teaching in * Get one studyplan page if the current user is teaching in it
* @param int $studyplanid ID of studyplan to retrieve * @param int $pageid ID of studyplan to retrieve
* @return array * @return array
* @throws moodle_exception if current user is not teaching in this studyplan
*/ */
public static function get_teaching_page($pageid) { public static function get_teaching_page($pageid) {
global $USER;
$userid = $USER->id;
\external_api::validate_context(\context_system::instance()); \external_api::validate_context(\context_system::instance());
$page = studyplanpage::find_by_id($pageid); $page = studyplanpage::find_by_id($pageid);
$studyplan = $page->studyplan(); $studyplan = $page->studyplan();
@ -684,7 +680,7 @@ class studentstudyplanservice extends \external_api {
/** /**
* Get all or one studyplan the current user is teaching in * Get all or one studyplan the current user is teaching in
* @param int $studyplanid ID of studyplan to retrieve * @param int $id ID of studyplan to retrieve
* @return array * @return array
*/ */
public static function line_enrol_self($id) { public static function line_enrol_self($id) {

View File

@ -191,7 +191,7 @@ class studyline {
/** /**
* Whether the current user can enrol a specific user in this line * Whether the current user can enrol a specific user in this line
* @param int|null $user ID or user object for user or null * @param int|null $userid ID of user to check for. Checks current user if left empty or null
*/ */
public function can_enrol($userid=null): bool { public function can_enrol($userid=null): bool {
global $USER; global $USER;
@ -797,8 +797,8 @@ class studyline {
} }
/** /**
* Duplicate this studyplan page * Duplicate this studyline into another page
* @param studyplan $newstudyplan Studyplan to copy the line into * @param studyplanpage $newpage Studyplan page to copy the line into
* @param array $translation Mapping array of old item ids to new item ids for connection matching * @param array $translation Mapping array of old item ids to new item ids for connection matching
* @param bool $bare Set to true to skip copying contents * @param bool $bare Set to true to skip copying contents
*/ */

View File

@ -287,6 +287,7 @@ class studyplan {
/** /**
* Webservice model for basic info * Webservice model for basic info
* @param int|null $userid Optional id of user, so progress/teaching info for user can be included
* @return array Webservice data model * @return array Webservice data model
*/ */
public function simple_model($userid=null) { public function simple_model($userid=null) {
@ -918,6 +919,9 @@ class studyplan {
* Duplicate this studyplan * Duplicate this studyplan
* @param string $name New fullname of studyplan * @param string $name New fullname of studyplan
* @param string $shortname New shortname of studyplan * @param string $shortname New shortname of studyplan
* @param int $contextid Id of context for new plan
* @param string|null $idnumber New idnumber (duplicate old one if left empty)
* @param string|null $newstartdate If provided, all dates in the copy will be shifted so this is the start date of the new studyplan
*/ */
public function duplicate($name, $shortname, $contextid, $idnumber=null, $newstartdate = null): self { public function duplicate($name, $shortname, $contextid, $idnumber=null, $newstartdate = null): self {
// First duplicate the studyplan structure. // First duplicate the studyplan structure.
@ -1053,9 +1057,8 @@ class studyplan {
/** /**
* Import previously exported files into the file storage * Import previously exported files into the file storage
* @param string $area Name of the file area to import
* @param mixed $importfiles List of files to import from string in the format exported in export_model() * @param mixed $importfiles List of files to import from string in the format exported in export_model()
* * @param string $area Name of the file area to import
*/ */
public function import_files($importfiles, $area) { public function import_files($importfiles, $area) {
$fs = get_file_storage(); $fs = get_file_storage();

View File

@ -127,6 +127,7 @@ class studyplanpage {
/** /**
* End date * End date
* @param bool $farahead Return a date 100 years in the future if end date is not set. Returns null otherwise
* @return \DateTime|null * @return \DateTime|null
*/ */
public function enddate($farahead = true) { public function enddate($farahead = true) {
@ -492,6 +493,7 @@ class studyplanpage {
/** /**
* Duplicate this studyplan page * Duplicate this studyplan page
* @param studyplan $newstudyplan Studyplan to copy the page into * @param studyplan $newstudyplan Studyplan to copy the page into
* @param \DateInterval|null $timeoffset Amount if time to shift the dates for the new page
*/ */
public function duplicate(studyplan $newstudyplan, $timeoffset = null): self { public function duplicate(studyplan $newstudyplan, $timeoffset = null): self {
if ($timeoffset == null) { if ($timeoffset == null) {
@ -750,9 +752,8 @@ class studyplanpage {
/** /**
* Import previously exported files into the file storage * Import previously exported files into the file storage
* @param string $area Name of the file area to export
* @param mixed $importfiles List of files to import from string in the format exported in export_model() * @param mixed $importfiles List of files to import from string in the format exported in export_model()
* * @param string $area Name of the file area to export
*/ */
public function import_files($importfiles, $area) { public function import_files($importfiles, $area) {
$fs = get_file_storage(); $fs = get_file_storage();

View File

@ -384,11 +384,13 @@ class studyplanservice extends \external_api {
/** /**
* Add a new study line * Add a new study line
* @param mixed $pageid * @param mixed $pageid Id of the page to put it in
* @param mixed $name * @param mixed $name Name of the line
* @param mixed $shortname * @param mixed $shortname Shortname of the line
* @param mixed $color * @param mixed $color Color of the line
* @param mixed $sequence * @param mixed $sequence Order for new line
* @param int|null $enrollable New enrollable setting (From studyline::ENROLLABLE_...)
* @param array|null $enrolroles New list of roles that can enrol a student
* @return array * @return array
*/ */
public static function add_studyline($pageid, $name, $shortname, $color, $sequence, $enrollable=null, $enrolroles=null) { public static function add_studyline($pageid, $name, $shortname, $color, $sequence, $enrollable=null, $enrolroles=null) {
@ -447,11 +449,13 @@ class studyplanservice extends \external_api {
/** /**
* Edit studyline parameters * Edit studyline parameters
* @param mixed $id * @param mixed $id Id of the line
* @param mixed $name * @param mixed $name New name of the line
* @param mixed $shortname * @param mixed $shortname New shortname of the line
* @param mixed $color * @param mixed $color New color of the line
* @return [type] * @param int|null $enrollable New enrollable setting (From studyline::ENROLLABLE_...)
* @param array|null $enrolroles New list of roles that can enrol a student
* @return array
*/ */
public static function edit_studyline($id, $name, $shortname, $color, $enrollable=null, $enrolroles=null) { public static function edit_studyline($id, $name, $shortname, $color, $enrollable=null, $enrolroles=null) {
$o = studyline::find_by_id($id); $o = studyline::find_by_id($id);
@ -936,7 +940,7 @@ class studyplanservice extends \external_api {
****************************/ ****************************/
/** /**
* Parameter description for webservice function list_badges * Parameter description for webservice function search_badges
*/ */
public static function search_badges_parameters(): \external_function_parameters { public static function search_badges_parameters(): \external_function_parameters {
return new \external_function_parameters( [ return new \external_function_parameters( [
@ -946,14 +950,16 @@ class studyplanservice extends \external_api {
} }
/** /**
* Return value description for webservice function list_badges * Return value description for webservice function search_badges
*/ */
public static function search_badges_returns(): \external_description { public static function search_badges_returns(): \external_description {
return new \external_multiple_structure(badgeinfo::editor_structure()); return new \external_multiple_structure(badgeinfo::editor_structure());
} }
/** /**
* List all available badges to drag into a studyplan page * List all available site badges to drag into a studyplan page
* @param string $search Search string to use
* @param bool $active Only include active badges
* @return array * @return array
*/ */
public static function search_badges($search, $active=false) { public static function search_badges($search, $active=false) {
@ -970,7 +976,7 @@ class studyplanservice extends \external_api {
} }
/** /**
* Parameter description for webservice function list_badges * Parameter description for webservice function search_related_badges
*/ */
public static function search_related_badges_parameters(): \external_function_parameters { public static function search_related_badges_parameters(): \external_function_parameters {
return new \external_function_parameters( [ return new \external_function_parameters( [
@ -982,7 +988,7 @@ class studyplanservice extends \external_api {
} }
/** /**
* Return value description for webservice function list_badges * Return value description for webservice function search_related_badges
*/ */
public static function search_related_badges_returns(): \external_description { public static function search_related_badges_returns(): \external_description {
return new \external_multiple_structure(badgeinfo::editor_structure()); return new \external_multiple_structure(badgeinfo::editor_structure());
@ -990,6 +996,10 @@ class studyplanservice extends \external_api {
/** /**
* List all available badges to drag into a studyplan page * List all available badges to drag into a studyplan page
* @param int $pageid ID of the studyplan page to limit search to
* @param string $search Search string to use
* @param bool $active Only include active badges
* @param bool $includecoursebadges Also include course badges in the search
* @return array * @return array
*/ */
public static function search_related_badges($pageid, $search="", $active=false, $includecoursebadges=true) { public static function search_related_badges($pageid, $search="", $active=false, $includecoursebadges=true) {
@ -1090,7 +1100,7 @@ class studyplanservice extends \external_api {
/** /**
* Mark a competency as required for course completion * Mark a competency as required for course completion
* @param mixed $gradeid Id of gradable * @param mixed $competencyid Id of gradable
* @param mixed $itemid Id of study item * @param mixed $itemid Id of study item
* @param bool $required Mark grade as required or not * @param bool $required Mark grade as required or not
* @return array Success/Fail model * @return array Success/Fail model
@ -1403,7 +1413,7 @@ class studyplanservice extends \external_api {
} }
/** /**
* Parameter description for webservice function export_studylines * Parameter description for webservice function export_page
*/ */
public static function export_page_parameters(): \external_function_parameters { public static function export_page_parameters(): \external_function_parameters {
return new \external_function_parameters( [ return new \external_function_parameters( [
@ -1413,15 +1423,15 @@ class studyplanservice extends \external_api {
} }
/** /**
* Return value description for webservice function export_studylines * Return value description for webservice function export_page
*/ */
public static function export_page_returns(): \external_description { public static function export_page_returns(): \external_description {
return studyplanpage::export_structure(); return studyplanpage::export_structure();
} }
/** /**
* Export studylines for a studyplan * Export studylines for a studyplan page
* @param mixed $studyplanid Id of the studyplan to export the studylines for * @param mixed $pageid Id of the studyplan page to export the studylines for
* @param string $format Export format [csv, json (default)] * @param string $format Export format [csv, json (default)]
* @return array * @return array
*/ */
@ -1540,8 +1550,8 @@ class studyplanservice extends \external_api {
} }
/** /**
* Import studylines into existing studtplan * Import studylines into existing studtplan page
* @param int $studyplanid ID of studyplan to import to * @param int $pageid ID of studyplan page to import to
* @param string $content Content of file * @param string $content Content of file
* @param string $format Format of file * @param string $format Format of file
* @return array Success/fail model * @return array Success/fail model
@ -1855,7 +1865,7 @@ class studyplanservice extends \external_api {
************************/ ************************/
/** /**
* Parameter description for webservice function delete_studyplan * Parameter description for webservice function bulk_course_timing
*/ */
public static function bulk_course_timing_parameters(): \external_function_parameters { public static function bulk_course_timing_parameters(): \external_function_parameters {
return new \external_function_parameters( [ return new \external_function_parameters( [
@ -1864,16 +1874,15 @@ class studyplanservice extends \external_api {
} }
/** /**
* Return value description for webservice function delete_studyplan * Return value description for webservice function bulk_course_timing
*/ */
public static function bulk_course_timing_returns(): \external_description { public static function bulk_course_timing_returns(): \external_description {
return success::structure(); return success::structure();
} }
/** /**
* Delete a studyplan * Update course timing for all courses in a studyplan page
* @param mixed $id Id of the studyplan * @param mixed $pageid Id of the studyplan page
* @param bool $force Force deletion, even though studyplan is not empty
* @return array Succes/fail model * @return array Succes/fail model
*/ */
public static function bulk_course_timing($pageid) { public static function bulk_course_timing($pageid) {
@ -1955,7 +1964,7 @@ class studyplanservice extends \external_api {
************************/ ************************/
/** /**
* Parameter description for webservice function delete_studyplan * Parameter description for webservice function list_roles
*/ */
public static function list_roles_parameters(): \external_function_parameters { public static function list_roles_parameters(): \external_function_parameters {
return new \external_function_parameters( [ return new \external_function_parameters( [
@ -1964,7 +1973,7 @@ class studyplanservice extends \external_api {
} }
/** /**
* Return value description for webservice function delete_studyplan * Return value description for webservice function list_roles
*/ */
public static function list_roles_returns(): \external_description { public static function list_roles_returns(): \external_description {
return new \external_multiple_structure(new \external_single_structure([ return new \external_multiple_structure(new \external_single_structure([
@ -1974,10 +1983,9 @@ class studyplanservice extends \external_api {
} }
/** /**
* Delete a studyplan * List available roles
* @param mixed $id Id of the studyplan * @param mixed $studyplanid id of the studyplan to list the roles for
* @param bool $force Force deletion, even though studyplan is not empty * @return array List of roles
* @return array Succes/fail model
*/ */
public static function list_roles($studyplanid) { public static function list_roles($studyplanid) {
global $DB; global $DB;
@ -2012,6 +2020,7 @@ class studyplanservice extends \external_api {
/** /**
* Enrol status structure including user info * Enrol status structure including user info
* @param int $required VALUE_OPTIONAL or VALUE_REQUIRED
*/ */
public static function student_enrol_status_structure($required = VALUE_REQUIRED) { public static function student_enrol_status_structure($required = VALUE_REQUIRED) {
return new \external_single_structure([ return new \external_single_structure([
@ -2035,7 +2044,7 @@ class studyplanservice extends \external_api {
} }
/** /**
* Parameter description for webservice function get_teaching_page * Parameter description for webservice function line_enrol_students
*/ */
public static function line_enrol_students_parameters(): \external_function_parameters { public static function line_enrol_students_parameters(): \external_function_parameters {
return new \external_function_parameters( [ return new \external_function_parameters( [
@ -2045,15 +2054,16 @@ class studyplanservice extends \external_api {
} }
/** /**
* Return value description for webservice function get_teaching_page * Return value description for webservice function line_enrol_students
*/ */
public static function line_enrol_students_returns(): \external_description { public static function line_enrol_students_returns(): \external_description {
return new \external_multiple_structure(self::student_enrol_status_structure()); return new \external_multiple_structure(self::student_enrol_status_structure());
} }
/** /**
* Get all or one studyplan the current user is teaching in * Enrol users in a study line
* @param int $studyplanid ID of studyplan to retrieve * @param int $id ID of the studyline to enrol in
* @param array $users ID's of users to enrol
* @return array * @return array
*/ */
public static function line_enrol_students($id, $users) { public static function line_enrol_students($id, $users) {
@ -2090,7 +2100,7 @@ class studyplanservice extends \external_api {
***************************/ ***************************/
/** /**
* Parameter description for webservice function get_teaching_page * Parameter description for webservice function line_unenrol_students
*/ */
public static function line_unenrol_students_parameters(): \external_function_parameters { public static function line_unenrol_students_parameters(): \external_function_parameters {
return new \external_function_parameters( [ return new \external_function_parameters( [
@ -2100,15 +2110,16 @@ class studyplanservice extends \external_api {
} }
/** /**
* Return value description for webservice function get_teaching_page * Return value description for webservice function line_unenrol_students
*/ */
public static function line_unenrol_students_returns(): \external_description { public static function line_unenrol_students_returns(): \external_description {
return new \external_multiple_structure(self::student_enrol_status_structure()); return new \external_multiple_structure(self::student_enrol_status_structure());
} }
/** /**
* Get all or one studyplan the current user is teaching in * Unenrol users from a study line
* @param int $studyplanid ID of studyplan to retrieve * @param int $id ID of the studyline to unenrol from
* @param array $users ID's of users to unenroll
* @return array * @return array
*/ */
public static function line_unenrol_students($id, $users) { public static function line_unenrol_students($id, $users) {
@ -2141,7 +2152,7 @@ class studyplanservice extends \external_api {
***************************/ ***************************/
/** /**
* Parameter description for webservice function get_teaching_page * Parameter description for webservice function list_line_enrolled_students
*/ */
public static function list_line_enrolled_students_parameters(): \external_function_parameters { public static function list_line_enrolled_students_parameters(): \external_function_parameters {
return new \external_function_parameters( [ return new \external_function_parameters( [
@ -2150,7 +2161,7 @@ class studyplanservice extends \external_api {
} }
/** /**
* Return value description for webservice function get_teaching_page * Return value description for webservice function list_line_enrolled_students
*/ */
public static function list_line_enrolled_students_returns(): \external_description { public static function list_line_enrolled_students_returns(): \external_description {
return new \external_single_structure([ return new \external_single_structure([
@ -2160,8 +2171,8 @@ class studyplanservice extends \external_api {
} }
/** /**
* Get all or one studyplan the current user is teaching in * List all students enrolled in a specific enrollable study line
* @param int $studyplanid ID of studyplan to retrieve * @param int $id ID of studyline to retrieve
* @return array * @return array
*/ */
public static function list_line_enrolled_students($id) { public static function list_line_enrolled_students($id) {
@ -2188,7 +2199,7 @@ class studyplanservice extends \external_api {
***************************/ ***************************/
/** /**
* Parameter description for webservice function get_teaching_page * Parameter description for webservice function count_templates
*/ */
public static function count_templates_parameters(): \external_function_parameters { public static function count_templates_parameters(): \external_function_parameters {
return new \external_function_parameters( [ return new \external_function_parameters( [
@ -2196,15 +2207,14 @@ class studyplanservice extends \external_api {
} }
/** /**
* Return value description for webservice function get_teaching_page * Return value description for webservice function count_templates
*/ */
public static function count_templates_returns(): \external_description { public static function count_templates_returns(): \external_description {
return new \external_value(PARAM_INT, "True if the requesting user can unenrol students"); return new \external_value(PARAM_INT, "True if the requesting user can unenrol students");
} }
/** /**
* Get all or one studyplan the current user is teaching in * Count the number of templates available
* @param int $studyplanid ID of studyplan to retrieve
* @return array * @return array
*/ */
public static function count_templates() { public static function count_templates() {

View File

@ -40,7 +40,6 @@ class success {
/** /**
* Create new successful result with optional message * Create new successful result with optional message
* @param string $msg Message to add to result
* @param array|object $data Custom data to pass to receiver * @param array|object $data Custom data to pass to receiver
*/ */
public static function success($data=[]): self { public static function success($data=[]): self {

View File

@ -74,6 +74,7 @@ class autocohortsync extends \core\task\scheduled_task {
/** /**
* Perform immediate syncronization on a single studyplan. * Perform immediate syncronization on a single studyplan.
* @param studyplan $studyplan Relevant study plan
*/ */
public static function syncplan(studyplan $studyplan) { public static function syncplan(studyplan $studyplan) {
$enroller = new cascadecohortsync($studyplan); $enroller = new cascadecohortsync($studyplan);
@ -88,6 +89,7 @@ class autocohortsync extends \core\task\scheduled_task {
/** /**
* Perform immediate syncronization on a single studyline. * Perform immediate syncronization on a single studyline.
* @param studyline $line Relevant study line
*/ */
public static function syncline(studyline $line) { public static function syncline(studyline $line) {
$plan = $line->studyplan(); $plan = $line->studyplan();

View File

@ -59,6 +59,7 @@ class teachingfinder {
* Check if a user is teaching in a specific studyplan * Check if a user is teaching in a specific studyplan
* (Does not update the cache if results are 0) * (Does not update the cache if results are 0)
* @param studyplan $plan Studyplan to check * @param studyplan $plan Studyplan to check
* @param int $userid UserId to check for
* @return bool If teaching in this plan * @return bool If teaching in this plan
*/ */
public static function is_teaching_studyplan(studyplan $plan, $userid) { public static function is_teaching_studyplan(studyplan $plan, $userid) {
@ -70,8 +71,8 @@ class teachingfinder {
/** /**
* Check if a user is teaching courses in any studyplan * Check if a user is teaching courses in any studyplan
* (Does not update the cache if results are 0) * (Does not update the cache if results are 0)
* @param studyplan $plan Studyplan to check * @param int $userid UserId to check for
* @return bool If teaching in this plan * @return bool If teaching in any plan
*/ */
public static function is_teaching($userid) { public static function is_teaching($userid) {
global $DB; global $DB;
@ -93,8 +94,7 @@ class teachingfinder {
/** /**
* Check if current user is teaching courses in any studyplan * Check if current user is teaching courses in any studyplan
* (Does not update the cache if results are 0) * (Does not update the cache if results are 0)
* @param studyplan $plan Studyplan to check * @return bool If teaching in any studyplan
* @return bool If teaching in this plan
*/ */
public static function am_teaching() { public static function am_teaching() {
global $USER; global $USER;