From 96c2b8477fda3880c7b2154e802bdee273975454 Mon Sep 17 00:00:00 2001 From: Frederic Massart Date: Mon, 14 Mar 2016 13:22:01 +0800 Subject: [PATCH] MDL-53453 cbe: PHP Docs and coding style adjustments --- admin/tool/cohortroles/classes/api.php | 1 - .../classes/form/assign_role_cohort.php | 3 + .../output/cohort_role_assignments_table.php | 20 +- .../classes/task/cohort_role_sync.php | 8 + .../cohortroles/lang/en/tool_cohortroles.php | 2 +- admin/tool/lp/classes/api.php | 15 +- admin/tool/lp/classes/competency.php | 3 +- .../tool/lp/classes/competency_framework.php | 1 + admin/tool/lp/classes/competency_rule.php | 1 + admin/tool/lp/classes/competency_rule_all.php | 2 + .../lp/classes/competency_rule_points.php | 2 + admin/tool/lp/classes/course_competency.php | 2 + .../lp/classes/course_module_competency.php | 6 +- admin/tool/lp/classes/event/plan_deleted.php | 2 +- .../lp/classes/event/template_deleted.php | 2 +- admin/tool/lp/classes/external.php | 37 ++-- admin/tool/lp/classes/external/exporter.php | 8 +- .../classes/external/persistent_exporter.php | 1 - .../external/template_statistics_exporter.php | 12 +- admin/tool/lp/classes/form/competency.php | 1 + .../lp/classes/form/competency_framework.php | 1 + .../classes/form/framework_autocomplete.php | 2 +- admin/tool/lp/classes/form/persistent.php | 3 +- .../classes/output/manage_templates_page.php | 1 + .../classes/output/related_competencies.php | 3 +- .../classes/output/template_cohorts_page.php | 5 + .../classes/output/template_cohorts_table.php | 8 +- .../output/template_competencies_page.php | 1 + .../lp/classes/output/template_plans_page.php | 5 + .../classes/output/template_plans_table.php | 8 +- .../user_competency_course_navigation.php | 7 +- .../output/user_competency_summary.php | 3 +- .../user_competency_summary_in_course.php | 10 +- .../user_competency_summary_in_plan.php | 4 +- admin/tool/lp/classes/page_helper.php | 7 +- admin/tool/lp/classes/persistent.php | 12 +- admin/tool/lp/classes/plan.php | 3 +- admin/tool/lp/classes/related_competency.php | 2 + admin/tool/lp/classes/template_cohort.php | 5 +- admin/tool/lp/classes/template_statistics.php | 2 +- .../lp/classes/user_evidence_competency.php | 2 +- admin/tool/lp/lib.php | 1 + admin/tool/lp/template_plans.php | 3 +- admin/tool/lp/tests/api_test.php | 184 +++++++++++++++--- admin/tool/lp/tests/externallib_test.php | 27 +++ admin/tool/lp/tests/task_test.php | 2 +- admin/tool/lp/user_competency_in_course.php | 1 - .../classes/form/migrate_framework.php | 14 +- .../lpmigrate/classes/framework_processor.php | 2 +- .../output/migrate_framework_results.php | 1 + .../lpmigrate/classes/output/renderer.php | 2 +- admin/tool/lpmigrate/frameworks.php | 2 +- admin/tool/lpmigrate/tests/processor_test.php | 76 ++++++-- blocks/lp/classes/output/renderer.php | 15 ++ blocks/lp/classes/output/summary.php | 9 + report/competency/classes/external.php | 1 + report/competency/classes/output/renderer.php | 3 +- .../classes/output/user_course_navigation.php | 8 +- report/competency/index.php | 2 +- report/competency/lib.php | 2 +- 60 files changed, 451 insertions(+), 127 deletions(-) diff --git a/admin/tool/cohortroles/classes/api.php b/admin/tool/cohortroles/classes/api.php index 36b0d1dbf62..53057bc81da 100644 --- a/admin/tool/cohortroles/classes/api.php +++ b/admin/tool/cohortroles/classes/api.php @@ -110,7 +110,6 @@ class api { * * Requires moodle/role:manage capability at system context. * - * @param array $filters A list of filters to apply to the list. * @return int */ public static function count_cohort_role_assignments() { diff --git a/admin/tool/cohortroles/classes/form/assign_role_cohort.php b/admin/tool/cohortroles/classes/form/assign_role_cohort.php index 9292b9beff1..18ae336e2d4 100644 --- a/admin/tool/cohortroles/classes/form/assign_role_cohort.php +++ b/admin/tool/cohortroles/classes/form/assign_role_cohort.php @@ -39,6 +39,9 @@ require_once($CFG->libdir . '/formslib.php'); */ class assign_role_cohort extends moodleform { + /** + * Form definition. + */ public function definition() { global $OUTPUT; diff --git a/admin/tool/cohortroles/classes/output/cohort_role_assignments_table.php b/admin/tool/cohortroles/classes/output/cohort_role_assignments_table.php index 637fbef7830..08c8c3f7501 100644 --- a/admin/tool/cohortroles/classes/output/cohort_role_assignments_table.php +++ b/admin/tool/cohortroles/classes/output/cohort_role_assignments_table.php @@ -46,7 +46,7 @@ class cohort_role_assignments_table extends table_sql { * Sets up the table. * * @param string $uniqueid Unique id of table. - * @param \tool_lp\template $template The template. + * @param moodle_url $url The base URL. */ public function __construct($uniqueid, $url) { global $CFG; @@ -70,10 +70,22 @@ class cohort_role_assignments_table extends table_sql { $this->define_table_configs(); } + /** + * Role name column. + * + * @param array $data Row data. + * @return string + */ protected function col_rolename($data) { return $this->rolenames[$data->roleid]->localname; } + /** + * Cohort name column. + * + * @param array $data Row data. + * @return string + */ protected function col_cohortname($data) { global $OUTPUT; @@ -93,6 +105,12 @@ class cohort_role_assignments_table extends table_sql { return $html; } + /** + * Actions column. + * + * @param array $data Row data. + * @return string + */ protected function col_actions($data) { global $OUTPUT; diff --git a/admin/tool/cohortroles/classes/task/cohort_role_sync.php b/admin/tool/cohortroles/classes/task/cohort_role_sync.php index 45a5e9e4035..a3d628c85d4 100644 --- a/admin/tool/cohortroles/classes/task/cohort_role_sync.php +++ b/admin/tool/cohortroles/classes/task/cohort_role_sync.php @@ -33,11 +33,19 @@ use tool_cohortroles\api; * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class cohort_role_sync extends scheduled_task { + + /** + * Get name. + * @return string + */ public function get_name() { // Shown in admin screens. return get_string('taskname', 'tool_cohortroles'); } + /** + * Execute. + */ public function execute() { mtrace('Sync cohort roles...'); $result = api::sync_all_cohort_roles(); diff --git a/admin/tool/cohortroles/lang/en/tool_cohortroles.php b/admin/tool/cohortroles/lang/en/tool_cohortroles.php index 40569192962..e735f7e5925 100644 --- a/admin/tool/cohortroles/lang/en/tool_cohortroles.php +++ b/admin/tool/cohortroles/lang/en/tool_cohortroles.php @@ -17,7 +17,7 @@ /** * Strings for component 'tool_userroles', language 'en' * - * @package tool_userroles + * @package tool_cohortroles * @copyright 2015 Damyon Wiese * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/admin/tool/lp/classes/api.php b/admin/tool/lp/classes/api.php index 5c4465beea9..dbbef90f7c8 100644 --- a/admin/tool/lp/classes/api.php +++ b/admin/tool/lp/classes/api.php @@ -2173,7 +2173,7 @@ class api { * This silently ignores when the relation already existed. * * @param template|int $templateorid The template or its ID. - * @param stdClass|int $cohortid The cohort ot its ID. + * @param stdClass|int $cohortorid The cohort ot its ID. * @return template_cohort */ public static function create_template_cohort($templateorid, $cohortorid) { @@ -2209,7 +2209,7 @@ class api { * Remove a relation between a template and a cohort. * * @param template|int $templateorid The template or its ID. - * @param stdClass|int $cohortid The cohort ot its ID. + * @param stdClass|int $cohortorid The cohort ot its ID. * @return boolean True on success or when the relation did not exist. */ public static function delete_template_cohort($templateorid, $cohortorid) { @@ -2335,7 +2335,8 @@ class api { } // TODO MDL-52243 Use core function. - list($insql, $inparams) = external::filter_users_with_capability_on_user_context_sql('tool/lp:planreview', $userid, SQL_PARAMS_NAMED); + list($insql, $inparams) = external::filter_users_with_capability_on_user_context_sql('tool/lp:planreview', + $userid, SQL_PARAMS_NAMED); $sql .= " AND p.userid $insql"; $params += $inparams; @@ -3517,7 +3518,8 @@ class api { } $plan = new plan($ucp->get_planid()); if ($plan->get_status() != plan::STATUS_COMPLETE) { - throw new coding_exception('To log the user competency in non-completed plan use user_competency_viewed_in_plan method.'); + throw new coding_exception('To log the user competency in non-completed plan use ' + . 'user_competency_viewed_in_plan method.'); } \tool_lp\event\user_competency_plan_viewed::create_from_user_competency_plan($ucp)->trigger(); @@ -4210,7 +4212,8 @@ class api { // Simply logging an evidence. case evidence::ACTION_LOG: if ($grade !== null) { - throw new coding_exception("The grade MUST NOT be set when 'logging' an evidence. Or use ACTION_SUGGEST instead."); + throw new coding_exception("The grade MUST NOT be set when 'logging' an evidence. " + . "Or use ACTION_SUGGEST instead."); } break; @@ -4290,7 +4293,7 @@ class api { * rules and if so will see if they match. When matched it will take the required * step to add evidence and trigger completion, etc... * - * @param usercompetency $usercompetency The user competency recently completed. + * @param user_competency $usercompetency The user competency recently completed. * @param competency|null $competency The competency of the user competency, useful to avoid unnecessary read. * @return void */ diff --git a/admin/tool/lp/classes/competency.php b/admin/tool/lp/classes/competency.php index 68147c4dc76..671211a70fe 100644 --- a/admin/tool/lp/classes/competency.php +++ b/admin/tool/lp/classes/competency.php @@ -524,7 +524,7 @@ class competency extends persistent { protected function validate_parentid($value) { // Check that the parent exists. But only if we don't have it already, and we actually have a parent. - if (!empty($value) && !$this->newparent && !competency::record_exists($value)) { + if (!empty($value) && !$this->newparent && !self::record_exists($value)) { return new lang_string('invaliddata', 'error'); } @@ -602,7 +602,6 @@ class competency extends persistent { protected function validate_scaleid($value) { global $DB; - // We'll if ($value === null) { return true; } diff --git a/admin/tool/lp/classes/competency_framework.php b/admin/tool/lp/classes/competency_framework.php index 0a36a4b8474..d665558e39d 100644 --- a/admin/tool/lp/classes/competency_framework.php +++ b/admin/tool/lp/classes/competency_framework.php @@ -379,6 +379,7 @@ class competency_framework extends persistent { * Extract the proficiency of a grade from a scale configuration. * * @param string $config JSON encoded config. + * @param int $grade The grade. * @return int Representing a boolean */ public static function get_proficiency_of_grade_from_scale_configuration($config, $grade) { diff --git a/admin/tool/lp/classes/competency_rule.php b/admin/tool/lp/classes/competency_rule.php index bc75297a639..41c2c7dbea5 100644 --- a/admin/tool/lp/classes/competency_rule.php +++ b/admin/tool/lp/classes/competency_rule.php @@ -76,6 +76,7 @@ abstract class competency_rule { /** * Validate the rule config. * + * @param string $value The value to validate. * @return bool */ abstract public function validate_config($value); diff --git a/admin/tool/lp/classes/competency_rule_all.php b/admin/tool/lp/classes/competency_rule_all.php index 99af3168a46..abfb9382353 100644 --- a/admin/tool/lp/classes/competency_rule_all.php +++ b/admin/tool/lp/classes/competency_rule_all.php @@ -41,6 +41,7 @@ class competency_rule_all extends competency_rule { /** * Whether or not the rule is matched. * + * @param user_competency $usercompetency The user competency. * @return bool */ public function matches(user_competency $usercompetency) { @@ -73,6 +74,7 @@ class competency_rule_all extends competency_rule { /** * Validate the rule config. * + * @param string $value The value to validate. * @return bool */ public function validate_config($value) { diff --git a/admin/tool/lp/classes/competency_rule_points.php b/admin/tool/lp/classes/competency_rule_points.php index e4fe8ed48c5..536dff97ee1 100644 --- a/admin/tool/lp/classes/competency_rule_points.php +++ b/admin/tool/lp/classes/competency_rule_points.php @@ -53,6 +53,7 @@ class competency_rule_points extends competency_rule { /** * Whether or not the rule is matched. * + * @param user_competency $usercompetency The user competency. * @return bool */ public function matches(user_competency $usercompetency) { @@ -102,6 +103,7 @@ class competency_rule_points extends competency_rule { /** * Validate the rule config. * + * @param string $value The value to validate. * @return bool */ public function validate_config($value) { diff --git a/admin/tool/lp/classes/course_competency.php b/admin/tool/lp/classes/course_competency.php index 01ea88d69c9..6aa9aa30cd1 100644 --- a/admin/tool/lp/classes/course_competency.php +++ b/admin/tool/lp/classes/course_competency.php @@ -190,6 +190,7 @@ class course_competency extends persistent { /** * Validate course ID. * + * @param int $data The course ID. * @return true|lang_string */ protected function validate_courseid($data) { @@ -203,6 +204,7 @@ class course_competency extends persistent { /** * Validate competency ID. * + * @param int $data The competency ID. * @return true|lang_string */ protected function validate_competencyid($data) { diff --git a/admin/tool/lp/classes/course_module_competency.php b/admin/tool/lp/classes/course_module_competency.php index 1eb5d7b702d..ac05cc7e1e5 100644 --- a/admin/tool/lp/classes/course_module_competency.php +++ b/admin/tool/lp/classes/course_module_competency.php @@ -136,6 +136,7 @@ class course_module_competency extends persistent { /** * Validate cmid ID. * + * @param int $data The CM ID. * @return true|lang_string */ protected function validate_cmid($data) { @@ -149,6 +150,7 @@ class course_module_competency extends persistent { /** * Validate competency ID. * + * @param int $data The competency ID. * @return true|lang_string */ protected function validate_competencyid($data) { @@ -162,6 +164,7 @@ class course_module_competency extends persistent { * Return the module IDs and visible flags that include this competency in a single course. * * @param int $competencyid The competency id + * @param int $courseid The course ID. * @return array of ints (cmids) */ public static function list_course_modules($competencyid, $courseid) { @@ -171,7 +174,8 @@ class course_module_competency extends persistent { FROM {' . self::TABLE . '} modcomp JOIN {course_modules} coursemodules ON modcomp.cmid = coursemodules.id - WHERE modcomp.competencyid = ? AND coursemodules.course = ?', array($competencyid, $courseid)); + WHERE modcomp.competencyid = ? AND coursemodules.course = ?', + array($competencyid, $courseid)); return array_keys($results); } diff --git a/admin/tool/lp/classes/event/plan_deleted.php b/admin/tool/lp/classes/event/plan_deleted.php index b232769e3dc..07038a34921 100644 --- a/admin/tool/lp/classes/event/plan_deleted.php +++ b/admin/tool/lp/classes/event/plan_deleted.php @@ -45,7 +45,7 @@ class plan_deleted extends base { /** * Convenience method to instantiate the event. - * + * * @param plan $plan The plan. * @return self */ diff --git a/admin/tool/lp/classes/event/template_deleted.php b/admin/tool/lp/classes/event/template_deleted.php index 34c88081666..18a8083ca8c 100644 --- a/admin/tool/lp/classes/event/template_deleted.php +++ b/admin/tool/lp/classes/event/template_deleted.php @@ -45,7 +45,7 @@ class template_deleted extends base { /** * Convenience method to instantiate the event. - * + * * @param template $template The template. * @return self */ diff --git a/admin/tool/lp/classes/external.php b/admin/tool/lp/classes/external.php index 6a8a5c8e0fb..d17ea2aece3 100644 --- a/admin/tool/lp/classes/external.php +++ b/admin/tool/lp/classes/external.php @@ -509,7 +509,6 @@ class external extends external_api { /** * List the existing competency frameworks * - * @param string $filters * @param int $sort * @param string $order * @param string $skip @@ -596,8 +595,9 @@ class external extends external_api { /** * Count the existing competency frameworks * - * @param string $filters Filters to use. - * @return boolean + * @param array $context + * @param string $includes + * @return int */ public static function count_competency_frameworks($context, $includes) { $params = self::validate_parameters(self::count_competency_frameworks_parameters(), @@ -2399,8 +2399,9 @@ class external extends external_api { /** * Count the existing learning plan templates * - * @param array $filters Filters to allow. - * @return boolean + * @param array $context + * @param string $includes + * @return int */ public static function count_templates($context, $includes) { $params = self::validate_parameters(self::count_templates_parameters(), @@ -2934,7 +2935,8 @@ class external extends external_api { /** * External function user_competency_cancel_review_request. * - * @param int $id The ID description. + * @param int $userid The user ID. + * @param int $competencyid The competency ID. * @return boolean */ public static function user_competency_cancel_review_request($userid, $competencyid) { @@ -3013,7 +3015,8 @@ class external extends external_api { /** * External function user_competency_start_review. * - * @param int $id The ID description. + * @param int $userid The user ID. + * @param int $competencyid The competency ID. * @return boolean */ public static function user_competency_start_review($userid, $competencyid) { @@ -3052,7 +3055,8 @@ class external extends external_api { /** * External function user_competency_stop_review. * - * @param int $id The ID description. + * @param int $userid The user ID. + * @param int $competencyid The competency ID. * @return boolean */ public static function user_competency_stop_review($userid, $competencyid) { @@ -4082,7 +4086,7 @@ class external extends external_api { /** * Loads the data required to render the user_evidence_page template. * - * @param int $userid User id. + * @param int $id User id. * @return boolean */ public static function data_for_user_evidence_page($id) { @@ -4442,11 +4446,11 @@ class external extends external_api { * Function used to return a list of users where the given user has a particular capability. * This is used e.g. to find all the users where someone is able to manage their learning plans, * it also would be useful for mentees etc. - * @param $capability String - The capability string we are filtering for. If '' is passed, + * @param string $capability - The capability string we are filtering for. If '' is passed, * an always matching filter is returned. - * @param $userid int - The user id we are using for the access checks. Defaults to current user. - * @param $type int - The type of named params to return (passed to $DB->get_in_or_equal). - * @param $prefix string - The type prefix for the db table (passed to $DB->get_in_or_equal). + * @param int $userid - The user id we are using for the access checks. Defaults to current user. + * @param int $type - The type of named params to return (passed to $DB->get_in_or_equal). + * @param string $prefix - The type prefix for the db table (passed to $DB->get_in_or_equal). * @return list($sql, $params) Same as $DB->get_in_or_equal(). */ public static function filter_users_with_capability_on_user_context_sql($capability, @@ -4486,7 +4490,7 @@ class external extends external_api { $hassystem = has_capability($capability, $syscontext, $userid); $access = get_user_access_sitewide($userid); - // Build up a list of level 2 contexts (candidates to be user context) + // Build up a list of level 2 contexts (candidates to be user context). $filtercontexts = array(); foreach ($access['ra'] as $path => $role) { $parts = explode('/', $path); @@ -4582,6 +4586,9 @@ class external extends external_api { * Search users. * * @param string $query + * @param string $capability + * @param int $limitfrom + * @param int $limitnum * @return array */ public static function search_users($query, $capability = '', $limitfrom = 0, $limitnum = 100) { @@ -4703,6 +4710,8 @@ class external extends external_api { * TODO: MDL-52243 Move this function to cohorts/externallib.php * * @param string $query + * @param array $context + * @param string $includes * @param int $limitfrom * @param int $limitnum * @return array diff --git a/admin/tool/lp/classes/external/exporter.php b/admin/tool/lp/classes/external/exporter.php index 1cce2173ee1..51747b3ef24 100644 --- a/admin/tool/lp/classes/external/exporter.php +++ b/admin/tool/lp/classes/external/exporter.php @@ -37,8 +37,7 @@ use external_value; use external_format_value; /** - * Generic exporter to take a stdClass and prepare it for return by webservice, or as the context - * for a template. + * Generic exporter to take a stdClass and prepare it for return by webservice, or as the context for a template. * * templatable classes implementing export_for_template, should always use a standard exporter if it exists. * External functions should always use a standard exporter if it exists. @@ -51,6 +50,7 @@ abstract class exporter { /** @var array $related List of related objects used to avoid DB queries. */ protected $related = array(); + /** @var stdClass|array The data of this exporter. */ protected $data = null; /** @@ -198,6 +198,7 @@ abstract class exporter { * * Note: These must be defined in {@link self::define_other_properties()}. * + * @param renderer_base $output The renderer. * @return array Keys are the property names, values are their values. */ protected function get_other_values(renderer_base $output) { @@ -421,6 +422,9 @@ abstract class exporter { /** * Returns the read structure from a set of properties (recursive). * + * @param array $properties The properties. + * @param int $required Whether is required. + * @param mixed $default The default value. * @return external_single_structure */ final protected static function get_read_structure_from_properties($properties, $required = VALUE_REQUIRED, $default = null) { diff --git a/admin/tool/lp/classes/external/persistent_exporter.php b/admin/tool/lp/classes/external/persistent_exporter.php index 0aa0f096c75..7e6d5deac37 100644 --- a/admin/tool/lp/classes/external/persistent_exporter.php +++ b/admin/tool/lp/classes/external/persistent_exporter.php @@ -53,7 +53,6 @@ abstract class persistent_exporter extends exporter { } $this->persistent = $persistent; - if (method_exists($this->persistent, 'get_context') && !isset($this->related['context'])) { $this->related['context'] = $this->persistent->get_context(); } diff --git a/admin/tool/lp/classes/external/template_statistics_exporter.php b/admin/tool/lp/classes/external/template_statistics_exporter.php index 9fdd3f11b45..43774941835 100644 --- a/admin/tool/lp/classes/external/template_statistics_exporter.php +++ b/admin/tool/lp/classes/external/template_statistics_exporter.php @@ -90,18 +90,18 @@ class template_statistics_exporter extends exporter { } $linkedcompetencypercentage = 0; if ($this->data->competencycount > 0) { - $linkedcompetencypercentage = format_float(((float) $linkedcompetencycount / - (float) $this->data->competencycount) * 100.0); + $linkedcompetencypercentage = format_float( + ((float) $linkedcompetencycount / (float) $this->data->competencycount) * 100.0); } $completedplanpercentage = 0; if ($this->data->plancount > 0) { - $completedplanpercentage = format_float(((float) $this->data->completedplancount / - (float) $this->data->plancount) * 100.0); + $completedplanpercentage = format_float( + ((float) $this->data->completedplancount / (float) $this->data->plancount) * 100.0); } $proficientusercompetencyplanpercentage = 0; if ($this->data->usercompetencyplancount > 0) { - $proficientusercompetencyplanpercentage = format_float(((float) $this->data->proficientusercompetencyplancount / - (float) $this->data->usercompetencyplancount) * 100.0); + $proficientusercompetencyplanpercentage = format_float( + ((float) $this->data->proficientusercompetencyplancount / (float) $this->data->usercompetencyplancount) * 100.0); } $competencies = array(); $contextcache = array(); diff --git a/admin/tool/lp/classes/form/competency.php b/admin/tool/lp/classes/form/competency.php index 4ce91784001..062e4003f1a 100644 --- a/admin/tool/lp/classes/form/competency.php +++ b/admin/tool/lp/classes/form/competency.php @@ -110,6 +110,7 @@ class competency extends persistent { /** * Convert some fields. * + * @param stdClass $data * @return object */ protected static function convert_fields(stdClass $data) { diff --git a/admin/tool/lp/classes/form/competency_framework.php b/admin/tool/lp/classes/form/competency_framework.php index ba59d19bacb..72869a2c5ee 100644 --- a/admin/tool/lp/classes/form/competency_framework.php +++ b/admin/tool/lp/classes/form/competency_framework.php @@ -109,6 +109,7 @@ class competency_framework extends persistent { /** * Convert some fields. * + * @param stdClass $data * @return object */ protected static function convert_fields(stdClass $data) { diff --git a/admin/tool/lp/classes/form/framework_autocomplete.php b/admin/tool/lp/classes/form/framework_autocomplete.php index 377c83ce7e6..c3249e806ba 100644 --- a/admin/tool/lp/classes/form/framework_autocomplete.php +++ b/admin/tool/lp/classes/form/framework_autocomplete.php @@ -82,7 +82,7 @@ class framework_autocomplete extends MoodleQuickForm_autocomplete { /** * Set the value of this element. * - * @param mixed string|array $value The value to set. + * @param string|array $value The value to set. * @return boolean */ public function setValue($value) { diff --git a/admin/tool/lp/classes/form/persistent.php b/admin/tool/lp/classes/form/persistent.php index 4efc8a43d0e..5a6b9470198 100644 --- a/admin/tool/lp/classes/form/persistent.php +++ b/admin/tool/lp/classes/form/persistent.php @@ -81,7 +81,8 @@ abstract class persistent extends moodleform { * @param mixed $attributes * @param bool $editable */ - public function __construct($action = null, $customdata = null, $method = 'post', $target = '', $attributes = null, $editable = true) { + public function __construct($action = null, $customdata = null, $method = 'post', $target = '', + $attributes = null, $editable = true) { if (empty(static::$persistentclass)) { throw new coding_exception('Static property $persistentclass must be set.'); } else if (!is_subclass_of(static::$persistentclass, 'tool_lp\\persistent')) { diff --git a/admin/tool/lp/classes/output/manage_templates_page.php b/admin/tool/lp/classes/output/manage_templates_page.php index a1a2e6f2fe3..5e9e524eaf3 100644 --- a/admin/tool/lp/classes/output/manage_templates_page.php +++ b/admin/tool/lp/classes/output/manage_templates_page.php @@ -55,6 +55,7 @@ class manage_templates_page implements renderable, templatable { /** * Construct this renderable. + * @param context $pagecontext */ public function __construct(context $pagecontext) { $this->pagecontext = $pagecontext; diff --git a/admin/tool/lp/classes/output/related_competencies.php b/admin/tool/lp/classes/output/related_competencies.php index c8c6e6efae3..c55bbf9559a 100644 --- a/admin/tool/lp/classes/output/related_competencies.php +++ b/admin/tool/lp/classes/output/related_competencies.php @@ -41,7 +41,8 @@ use tool_lp\external\competency_exporter; */ class related_competencies implements renderable, templatable { - var $relatedcompetencies = null; + /** @var array Related competencies. */ + protected $relatedcompetencies = null; /** * Construct this renderable. diff --git a/admin/tool/lp/classes/output/template_cohorts_page.php b/admin/tool/lp/classes/output/template_cohorts_page.php index c61520bc48a..bcadd93650b 100644 --- a/admin/tool/lp/classes/output/template_cohorts_page.php +++ b/admin/tool/lp/classes/output/template_cohorts_page.php @@ -34,6 +34,11 @@ defined('MOODLE_INTERNAL') || die(); */ class template_cohorts_page implements \renderable { + /** + * Constructor. + * @param \tool_lp\template $template + * @param \moodle_url $url + */ public function __construct(\tool_lp\template $template, \moodle_url $url) { $this->template = $template; $this->url = $url; diff --git a/admin/tool/lp/classes/output/template_cohorts_table.php b/admin/tool/lp/classes/output/template_cohorts_table.php index 2e6e38f864c..7fa5ffc74be 100644 --- a/admin/tool/lp/classes/output/template_cohorts_table.php +++ b/admin/tool/lp/classes/output/template_cohorts_table.php @@ -140,10 +140,10 @@ class template_cohorts_table extends table_sql { $select = "$fields"; } - $sql = "SELECT $select - FROM {" . \tool_lp\template_cohort::TABLE . "} tc - JOIN {cohort} c ON c.id = tc.cohortid - WHERE tc.templateid = :templateid"; + $sql = "SELECT $select + FROM {" . \tool_lp\template_cohort::TABLE . "} tc + JOIN {cohort} c ON c.id = tc.cohortid + WHERE tc.templateid = :templateid"; $params = array('templateid' => $this->template->get_id()); // Add order by if needed. diff --git a/admin/tool/lp/classes/output/template_competencies_page.php b/admin/tool/lp/classes/output/template_competencies_page.php index cc7c0123e11..86a39e817d2 100644 --- a/admin/tool/lp/classes/output/template_competencies_page.php +++ b/admin/tool/lp/classes/output/template_competencies_page.php @@ -69,6 +69,7 @@ class template_competencies_page implements renderable, templatable { * Construct this renderable. * * @param int $templateid The learning plan template id for this page. + * @param context $pagecontext The page context. */ public function __construct($templateid, context $pagecontext) { $this->pagecontext = $pagecontext; diff --git a/admin/tool/lp/classes/output/template_plans_page.php b/admin/tool/lp/classes/output/template_plans_page.php index df0f0db810d..f01d99fb95d 100644 --- a/admin/tool/lp/classes/output/template_plans_page.php +++ b/admin/tool/lp/classes/output/template_plans_page.php @@ -34,6 +34,11 @@ defined('MOODLE_INTERNAL') || die(); */ class template_plans_page implements \renderable { + /** + * Constructor. + * @param \tool_lp\template $template + * @param \moodle_url $url + */ public function __construct(\tool_lp\template $template, \moodle_url $url) { $this->template = $template; $this->url = $url; diff --git a/admin/tool/lp/classes/output/template_plans_table.php b/admin/tool/lp/classes/output/template_plans_table.php index 4494e025c19..76211329659 100644 --- a/admin/tool/lp/classes/output/template_plans_table.php +++ b/admin/tool/lp/classes/output/template_plans_table.php @@ -147,10 +147,10 @@ class template_plans_table extends table_sql { $select = "$fields"; } - $sql = "SELECT $select - FROM {" . \tool_lp\plan::TABLE . "} p - JOIN {user} u ON u.id = p.userid - WHERE p.templateid = :templateid"; + $sql = "SELECT $select + FROM {" . \tool_lp\plan::TABLE . "} p + JOIN {user} u ON u.id = p.userid + WHERE p.templateid = :templateid"; $params = array('templateid' => $this->template->get_id()); // Add order by if needed. diff --git a/admin/tool/lp/classes/output/user_competency_course_navigation.php b/admin/tool/lp/classes/output/user_competency_course_navigation.php index 3747dae972d..a6480c6d50f 100644 --- a/admin/tool/lp/classes/output/user_competency_course_navigation.php +++ b/admin/tool/lp/classes/output/user_competency_course_navigation.php @@ -55,9 +55,10 @@ class user_competency_course_navigation implements renderable, templatable { /** * Construct. * - * @param $userid - * @param $competencyid - * @param $courseid + * @param int $userid + * @param int $competencyid + * @param int $courseid + * @param string $baseurl */ public function __construct($userid, $competencyid, $courseid, $baseurl) { $this->userid = $userid; diff --git a/admin/tool/lp/classes/output/user_competency_summary.php b/admin/tool/lp/classes/output/user_competency_summary.php index 86a9960e69f..e3a7694d60f 100644 --- a/admin/tool/lp/classes/output/user_competency_summary.php +++ b/admin/tool/lp/classes/output/user_competency_summary.php @@ -50,8 +50,7 @@ class user_competency_summary implements renderable, templatable { * Constructor. * * @param user_competency $usercompetency The user competency. - * @param competency $competency The competency. - * @param stdClass $user The user of the user competency. + * @param array $related Related objects. */ public function __construct(user_competency $usercompetency, array $related = array()) { $this->usercompetency = $usercompetency; diff --git a/admin/tool/lp/classes/output/user_competency_summary_in_course.php b/admin/tool/lp/classes/output/user_competency_summary_in_course.php index 933848adbb6..2d25fd97f9b 100644 --- a/admin/tool/lp/classes/output/user_competency_summary_in_course.php +++ b/admin/tool/lp/classes/output/user_competency_summary_in_course.php @@ -51,9 +51,9 @@ class user_competency_summary_in_course implements renderable, templatable { /** * Construct. * - * @param $userid - * @param $competencyid - * @param $courseid + * @param int $userid + * @param int $competencyid + * @param int $courseid */ public function __construct($userid, $competencyid, $courseid) { $this->userid = $userid; @@ -94,8 +94,8 @@ class user_competency_summary_in_course implements renderable, templatable { // Some adjustments specific to course. $data->usercompetencysummary->cangrade = user_competency::can_grade_user_in_course($this->userid, $this->courseid); - $data->usercompetencysummary->cansuggest = - user_competency::can_suggest_grade_user_in_course($this->userid, $this->courseid); + $data->usercompetencysummary->cansuggest = user_competency::can_suggest_grade_user_in_course($this->userid, + $this->courseid); $data->usercompetencysummary->cangradeorsuggest = $data->usercompetencysummary->cangrade || $data->usercompetencysummary->cansuggest; diff --git a/admin/tool/lp/classes/output/user_competency_summary_in_plan.php b/admin/tool/lp/classes/output/user_competency_summary_in_plan.php index 6d3581d1d08..7fbf92f30e1 100644 --- a/admin/tool/lp/classes/output/user_competency_summary_in_plan.php +++ b/admin/tool/lp/classes/output/user_competency_summary_in_plan.php @@ -47,8 +47,8 @@ class user_competency_summary_in_plan implements renderable, templatable { /** * Construct. * - * @param $competencyid - * @param $planid + * @param int $competencyid + * @param int $planid */ public function __construct($competencyid, $planid) { $this->competencyid = $competencyid; diff --git a/admin/tool/lp/classes/page_helper.php b/admin/tool/lp/classes/page_helper.php index fc92588a7f6..41538878fcc 100644 --- a/admin/tool/lp/classes/page_helper.php +++ b/admin/tool/lp/classes/page_helper.php @@ -50,10 +50,9 @@ class page_helper { * echo $OUTPUT->heading($title); * echo $OUTPUT->heading($subtitle, 3); * - * @param int $pagecontextid The page context ID. * @param moodle_url $url The current page. - * @param \stdClass $couse The course. - * @param string $subpage The title of the subpage, if any. + * @param stdClass $course The course. + * @param string $subtitle The title of the subpage, if any. * @return array With the following: * - Page title * - Page sub title @@ -100,7 +99,7 @@ class page_helper { * @param int $pagecontextid The page context ID. * @param moodle_url $url The current page. * @param \tool_lp\template $template The template, if any. - * @param string $subpage The title of the subpage, if any. + * @param string $subtitle The title of the subpage, if any. * @return array With the following: * - Page title * - Page sub title diff --git a/admin/tool/lp/classes/persistent.php b/admin/tool/lp/classes/persistent.php index f4801321fcf..4fae7c34da1 100644 --- a/admin/tool/lp/classes/persistent.php +++ b/admin/tool/lp/classes/persistent.php @@ -42,10 +42,10 @@ abstract class persistent { /** The table name. */ const TABLE = null; - /** The model data. */ + /** @var array The model data. */ private $data = array(); - /** @var boolean The list of validation errors. */ + /** @var array The list of validation errors. */ private $errors = array(); /** @var boolean If the data was already validated. */ @@ -70,7 +70,7 @@ abstract class persistent { /** * Magic method to capture getters and setters. * - * @param string $name Callee. + * @param string $method Callee. * @param array $arguments List of arguments. * @return mixed */ @@ -121,6 +121,7 @@ abstract class persistent { * using $persistent->set('property_name', ''), the lengthy setters must be used. * * @param string $property The property name. + * @param mixed $value The value. * @return mixed */ final protected function set($property, $value) { @@ -188,7 +189,6 @@ abstract class persistent { 'type' => PARAM_INT ); - // List of reserved property names. Mostly because we have methods (getters/setters) which would confict with them. // Think about backwards compability before adding new ones here! $reserved = array('errors', 'formatted_properties', 'records', 'records_select', 'property_default_value', @@ -660,7 +660,7 @@ abstract class persistent { /** * Extract a record from a row of data. * - * Most likely used in combination with {@see self::get_sql_fields()}. This method is + * Most likely used in combination with {@link self::get_sql_fields()}. This method is * simple enough to be used by non-persistent classes, keep that in mind when modifying it. * * e.g. persistent::extract_record($row, 'user'); should work. @@ -758,7 +758,7 @@ abstract class persistent { * Return the list of fields for use in a SELECT clause. * * Having the complete list of fields prefixed allows for multiple persistents to be fetched - * in a single query. Use {@see self::extract_record()} to extract the records from the query result. + * in a single query. Use {@link self::extract_record()} to extract the records from the query result. * * @param string $alias The alias used for the table. * @param string $prefix The prefix to use for each field, defaults to the table name followed by underscore. diff --git a/admin/tool/lp/classes/plan.php b/admin/tool/lp/classes/plan.php index 73f9b5d6c25..be25b0f289b 100644 --- a/admin/tool/lp/classes/plan.php +++ b/admin/tool/lp/classes/plan.php @@ -232,8 +232,9 @@ class plan extends persistent { } /** - * Get a single competency from this plan + * Get a single competency from this plan. * + * @param int $competencyid The competency ID. * @return competency */ public function get_competency($competencyid) { diff --git a/admin/tool/lp/classes/related_competency.php b/admin/tool/lp/classes/related_competency.php index 019a6f04b5d..be5f3992c40 100644 --- a/admin/tool/lp/classes/related_competency.php +++ b/admin/tool/lp/classes/related_competency.php @@ -57,6 +57,7 @@ class related_competency extends persistent { /** * Validate competency ID. * + * @param int $data The competency ID. * @return true|lang_string */ protected function validate_competencyid($data) { @@ -69,6 +70,7 @@ class related_competency extends persistent { /** * Validate related competency ID. * + * @param int $data The related competency ID. * @return true|lang_string */ protected function validate_relatedcompetencyid($data) { diff --git a/admin/tool/lp/classes/template_cohort.php b/admin/tool/lp/classes/template_cohort.php index 1f529771307..3b09e78b4e1 100644 --- a/admin/tool/lp/classes/template_cohort.php +++ b/admin/tool/lp/classes/template_cohort.php @@ -190,7 +190,10 @@ class template_cohort extends persistent { public static function get_all_missing_plans($lastruntime = 0, $unlinkedaremissing = false) { global $DB; - $planwhereclause = " WHERE (p.id is NULL AND (cm.timeadded >= :lastruntime1 OR tc.timecreated >= :lastruntime3 OR t.timemodified >= :lastruntime4))"; + $planwhereclause = " WHERE (p.id is NULL + AND (cm.timeadded >= :lastruntime1 + OR tc.timecreated >= :lastruntime3 + OR t.timemodified >= :lastruntime4))"; if ($unlinkedaremissing) { $planwhereclause .= " OR (p.origtemplateid IS NOT NULL AND cm.timeadded < :lastruntime2)"; diff --git a/admin/tool/lp/classes/template_statistics.php b/admin/tool/lp/classes/template_statistics.php index 616f35cbde4..623804ee7fa 100644 --- a/admin/tool/lp/classes/template_statistics.php +++ b/admin/tool/lp/classes/template_statistics.php @@ -58,7 +58,7 @@ class template_statistics { /** * Return the custom definition of the properties of this model. * - * @param int $template The template we want to generate statistics for. + * @param int $templateid The template we want to generate statistics for. */ public function __construct($templateid) { $template = new template($templateid); diff --git a/admin/tool/lp/classes/user_evidence_competency.php b/admin/tool/lp/classes/user_evidence_competency.php index f6259a9de27..88599c90c89 100644 --- a/admin/tool/lp/classes/user_evidence_competency.php +++ b/admin/tool/lp/classes/user_evidence_competency.php @@ -133,7 +133,7 @@ class user_evidence_competency extends persistent { /** * Delete evidences using competencies. - * + * * @param array $competencyids Array of competencies ids. * @return bool Return true if the delete was successful. */ diff --git a/admin/tool/lp/lib.php b/admin/tool/lp/lib.php index c0feb3a177d..2ddec4ee9f2 100644 --- a/admin/tool/lp/lib.php +++ b/admin/tool/lp/lib.php @@ -465,6 +465,7 @@ function tool_lp_coursemodule_standard_elements($formwrapper, $mform) { * Hook the add/edit of the course module. * * @param stdClass $data Data from the form submission. + * @param stdClass $course The course. */ function tool_lp_coursemodule_edit_post_actions($data, $course) { if (!\tool_lp\api::is_enabled()) { diff --git a/admin/tool/lp/template_plans.php b/admin/tool/lp/template_plans.php index 633b1aae0e7..c118a4e3e36 100644 --- a/admin/tool/lp/template_plans.php +++ b/admin/tool/lp/template_plans.php @@ -43,7 +43,8 @@ $url = new moodle_url('/admin/tool/lp/template_plans.php', array( 'id' => $id, 'pagecontextid' => $pagecontextid )); -list($title, $subtitle) = \tool_lp\page_helper::setup_for_template($pagecontextid, $url, $template, get_string('userplans', 'tool_lp')); +list($title, $subtitle) = \tool_lp\page_helper::setup_for_template($pagecontextid, $url, $template, + get_string('userplans', 'tool_lp')); // Capture the form submission. $form = new \tool_lp\form\template_plans($url->out(false)); diff --git a/admin/tool/lp/tests/api_test.php b/admin/tool/lp/tests/api_test.php index 7091dd7a987..b22cd597aea 100644 --- a/admin/tool/lp/tests/api_test.php +++ b/admin/tool/lp/tests/api_test.php @@ -555,6 +555,7 @@ class tool_lp_api_testcase extends advanced_testcase { api::update_plan($record); $this->fail('A plan cannot be unlinked using api::update_plan()'); } catch (coding_exception $e) { + // All good. } try { @@ -564,6 +565,7 @@ class tool_lp_api_testcase extends advanced_testcase { api::update_plan($record); $this->fail('A plan cannot be moved to another template.'); } catch (coding_exception $e) { + // All good. } try { @@ -573,6 +575,7 @@ class tool_lp_api_testcase extends advanced_testcase { api::update_plan($record); $this->fail('A plan cannot be update to use a template.'); } catch (coding_exception $e) { + // All good. } } @@ -642,6 +645,7 @@ class tool_lp_api_testcase extends advanced_testcase { api::unlink_plan_from_template($plan3); $this->fail('We can not unlink completed plan.'); } catch (coding_exception $e) { + // All good. } // Even the order remains. @@ -816,6 +820,7 @@ class tool_lp_api_testcase extends advanced_testcase { api::add_competency_to_plan($plan->get_id(), $c4->get_id()); $this->fail('We can not add competency to completed plan.'); } catch (coding_exception $e) { + // All good. } // Check we can not remove competency to completed plan. @@ -823,6 +828,7 @@ class tool_lp_api_testcase extends advanced_testcase { api::remove_competency_from_plan($plan->get_id(), $c3->get_id()); $this->fail('We can not remove competency to completed plan.'); } catch (coding_exception $e) { + // All good. } // Completing a plan that is completed throws an exception. @@ -876,7 +882,13 @@ class tool_lp_api_testcase extends advanced_testcase { */ public function test_plan_request_review() { $data = $this->setup_workflow_data(); - extract($data); + $dg = $data['dg']; + $lpg = $data['lpg']; + $user = $data['user']; + $reviewer = $data['reviewer']; + $otheruser = $data['otheruser']; + $plan = $data['plan']; + $tplplan = $data['tplplan']; $this->assertEquals(plan::STATUS_DRAFT, $plan->get_status()); $this->assertEquals(plan::STATUS_DRAFT, $tplplan->get_status()); @@ -968,7 +980,13 @@ class tool_lp_api_testcase extends advanced_testcase { */ public function test_plan_cancel_review_request() { $data = $this->setup_workflow_data(); - extract($data); + $dg = $data['dg']; + $lpg = $data['lpg']; + $user = $data['user']; + $reviewer = $data['reviewer']; + $otheruser = $data['otheruser']; + $plan = $data['plan']; + $tplplan = $data['tplplan']; // Set waiting for review. $tplplan->set_status(plan::STATUS_WAITING_FOR_REVIEW); @@ -1063,7 +1081,13 @@ class tool_lp_api_testcase extends advanced_testcase { */ public function test_plan_start_review() { $data = $this->setup_workflow_data(); - extract($data); + $dg = $data['dg']; + $lpg = $data['lpg']; + $user = $data['user']; + $reviewer = $data['reviewer']; + $otheruser = $data['otheruser']; + $plan = $data['plan']; + $tplplan = $data['tplplan']; // Set waiting for review. $tplplan->set_status(plan::STATUS_WAITING_FOR_REVIEW); @@ -1161,7 +1185,13 @@ class tool_lp_api_testcase extends advanced_testcase { */ public function test_plan_stop_review() { $data = $this->setup_workflow_data(); - extract($data); + $dg = $data['dg']; + $lpg = $data['lpg']; + $user = $data['user']; + $reviewer = $data['reviewer']; + $otheruser = $data['otheruser']; + $plan = $data['plan']; + $tplplan = $data['tplplan']; // Set waiting for review. $tplplan->set_status(plan::STATUS_IN_REVIEW); @@ -1256,7 +1286,13 @@ class tool_lp_api_testcase extends advanced_testcase { */ public function test_approve_plan() { $data = $this->setup_workflow_data(); - extract($data); + $dg = $data['dg']; + $lpg = $data['lpg']; + $user = $data['user']; + $reviewer = $data['reviewer']; + $otheruser = $data['otheruser']; + $plan = $data['plan']; + $tplplan = $data['tplplan']; // Set waiting for review. $tplplan->set_status(plan::STATUS_IN_REVIEW); @@ -1345,7 +1381,13 @@ class tool_lp_api_testcase extends advanced_testcase { */ public function test_unapprove_plan() { $data = $this->setup_workflow_data(); - extract($data); + $dg = $data['dg']; + $lpg = $data['lpg']; + $user = $data['user']; + $reviewer = $data['reviewer']; + $otheruser = $data['otheruser']; + $plan = $data['plan']; + $tplplan = $data['tplplan']; // Set waiting for review. $tplplan->set_status(plan::STATUS_ACTIVE); @@ -1498,6 +1540,7 @@ class tool_lp_api_testcase extends advanced_testcase { $plan = api::update_plan($record); $this->fail('We cannot complete a plan using api::update_plan().'); } catch (coding_exception $e) { + // All good. } api::complete_plan($plan); @@ -1533,6 +1576,7 @@ class tool_lp_api_testcase extends advanced_testcase { api::update_plan($record); $this->fail('Completed plan can not be edited'); } catch (coding_exception $e) { + // All good. } api::reopen_plan($record->id); @@ -1907,8 +1951,8 @@ class tool_lp_api_testcase extends advanced_testcase { // Trying to pass a grade should fail. try { - $evidence = api::add_evidence($u1->id, $c1->get_id(), $u1ctx->id, \tool_lp\evidence::ACTION_LOG, 'invaliddata', 'error', - null, false, null, 1); + $evidence = api::add_evidence($u1->id, $c1->get_id(), $u1ctx->id, \tool_lp\evidence::ACTION_LOG, 'invaliddata', + 'error', null, false, null, 1); $this->fail('A grade can not be set'); } catch (coding_exception $e) { $this->assertRegExp('/grade MUST NOT be set/', $e->getMessage()); @@ -1953,8 +1997,8 @@ class tool_lp_api_testcase extends advanced_testcase { // Trying not to pass a grade should fail. try { - $evidence = api::add_evidence($u1->id, $c1->get_id(), $u1ctx->id, \tool_lp\evidence::ACTION_SUGGEST, 'invaliddata', 'error', - false, null); + $evidence = api::add_evidence($u1->id, $c1->get_id(), $u1ctx->id, \tool_lp\evidence::ACTION_SUGGEST, 'invaliddata', + 'error', false, null); $this->fail('A grade must be set'); } catch (coding_exception $e) { $this->assertRegExp('/grade MUST be set/', $e->getMessage()); @@ -2653,7 +2697,7 @@ class tool_lp_api_testcase extends advanced_testcase { $this->assertEquals($expected, $result); $pagegenerator = $this->getDataGenerator()->get_plugin_generator('mod_page'); - $page = $pagegenerator->create_instance(array('course'=>$course->id)); + $page = $pagegenerator->create_instance(array('course' => $course->id)); $cm = get_coursemodule_from_instance('page', $page->id); // Add a link and list again. @@ -2977,7 +3021,17 @@ class tool_lp_api_testcase extends advanced_testcase { } public function test_moving_competency_reset_rules_updown() { - extract($this->setup_framework_for_reset_rules_tests()); + $data = $this->setup_framework_for_reset_rules_tests(); + $f1 = $data['f1']; + $c1 = $data['c1']; + $c1a = $data['c1a']; + $c1a1 = $data['c1a1']; + $c1a1a = $data['c1a1a']; + $c1b = $data['c1b']; + $c1b1 = $data['c1b1']; + $c1b1a = $data['c1b1a']; + $c2 = $data['c2']; + $c2a = $data['c2a']; // Moving up and down doesn't change anything. api::move_down_competency($c1a->get_id()); @@ -2997,7 +3051,17 @@ class tool_lp_api_testcase extends advanced_testcase { } public function test_moving_competency_reset_rules_parent() { - extract($this->setup_framework_for_reset_rules_tests()); + $data = $this->setup_framework_for_reset_rules_tests(); + $f1 = $data['f1']; + $c1 = $data['c1']; + $c1a = $data['c1a']; + $c1a1 = $data['c1a1']; + $c1a1a = $data['c1a1a']; + $c1b = $data['c1b']; + $c1b1 = $data['c1b1']; + $c1b1a = $data['c1b1a']; + $c2 = $data['c2']; + $c2a = $data['c2a']; // Moving out of parent will reset the parent, and the destination. api::set_parent_competency($c1a->get_id(), $c1b->get_id()); @@ -3014,7 +3078,17 @@ class tool_lp_api_testcase extends advanced_testcase { } public function test_moving_competency_reset_rules_totoplevel() { - extract($this->setup_framework_for_reset_rules_tests()); + $data = $this->setup_framework_for_reset_rules_tests(); + $f1 = $data['f1']; + $c1 = $data['c1']; + $c1a = $data['c1a']; + $c1a1 = $data['c1a1']; + $c1a1a = $data['c1a1a']; + $c1b = $data['c1b']; + $c1b1 = $data['c1b1']; + $c1b1a = $data['c1b1a']; + $c2 = $data['c2']; + $c2a = $data['c2a']; // Moving to top level only affects the initial parent. api::set_parent_competency($c1a1->get_id(), 0); @@ -3031,7 +3105,17 @@ class tool_lp_api_testcase extends advanced_testcase { } public function test_moving_competency_reset_rules_fromtoplevel() { - extract($this->setup_framework_for_reset_rules_tests()); + $data = $this->setup_framework_for_reset_rules_tests(); + $f1 = $data['f1']; + $c1 = $data['c1']; + $c1a = $data['c1a']; + $c1a1 = $data['c1a1']; + $c1a1a = $data['c1a1a']; + $c1b = $data['c1b']; + $c1b1 = $data['c1b1']; + $c1b1a = $data['c1b1a']; + $c2 = $data['c2']; + $c2a = $data['c2a']; // Moving from top level only affects the destination parent. api::set_parent_competency($c2->get_id(), $c1a1->get_id()); @@ -3048,7 +3132,17 @@ class tool_lp_api_testcase extends advanced_testcase { } public function test_moving_competency_reset_rules_child() { - extract($this->setup_framework_for_reset_rules_tests()); + $data = $this->setup_framework_for_reset_rules_tests(); + $f1 = $data['f1']; + $c1 = $data['c1']; + $c1a = $data['c1a']; + $c1a1 = $data['c1a1']; + $c1a1a = $data['c1a1a']; + $c1b = $data['c1b']; + $c1b1 = $data['c1b1']; + $c1b1a = $data['c1b1a']; + $c2 = $data['c2']; + $c2a = $data['c2a']; // Moving to a child of self resets self, parent and destination. api::set_parent_competency($c1a->get_id(), $c1a1->get_id()); @@ -3065,7 +3159,17 @@ class tool_lp_api_testcase extends advanced_testcase { } public function test_create_competency_reset_rules() { - extract($this->setup_framework_for_reset_rules_tests()); + $data = $this->setup_framework_for_reset_rules_tests(); + $f1 = $data['f1']; + $c1 = $data['c1']; + $c1a = $data['c1a']; + $c1a1 = $data['c1a1']; + $c1a1a = $data['c1a1a']; + $c1b = $data['c1b']; + $c1b1 = $data['c1b1']; + $c1b1a = $data['c1b1a']; + $c2 = $data['c2']; + $c2a = $data['c2a']; // Adding a new competency resets the rule of its parent. api::create_competency((object) array('shortname' => 'A', 'parentid' => $c1->get_id(), 'idnumber' => 'A', @@ -3083,7 +3187,17 @@ class tool_lp_api_testcase extends advanced_testcase { } public function test_delete_competency_reset_rules() { - extract($this->setup_framework_for_reset_rules_tests()); + $data = $this->setup_framework_for_reset_rules_tests(); + $f1 = $data['f1']; + $c1 = $data['c1']; + $c1a = $data['c1a']; + $c1a1 = $data['c1a1']; + $c1a1a = $data['c1a1a']; + $c1b = $data['c1b']; + $c1b1 = $data['c1b1']; + $c1b1a = $data['c1b1a']; + $c2 = $data['c2']; + $c2a = $data['c2a']; // Deleting a competency resets the rule of its parent. api::delete_competency($c1a->get_id()); @@ -3904,6 +4018,15 @@ class tool_lp_api_testcase extends advanced_testcase { $this->assertSuccessWithGradeCompetencyInCourse($c1->id, $student1->id, $comp1->get_id(), 1, false); } + /** + * Assert that a competency was graded in a course. + * + * @param int $courseid The course ID. + * @param int $userid The user ID. + * @param int $compid The competency ID. + * @param int $grade The grade. + * @param boolean $override Overridden flag. + */ protected function assertSuccessWithGradeCompetencyInCourse($courseid, $userid, $compid, $grade = 1, $override = true) { $beforecount = evidence::count_records(); api::grade_competency_in_course($courseid, $userid, $compid, $grade, $override); @@ -3914,6 +4037,17 @@ class tool_lp_api_testcase extends advanced_testcase { $this->assertEquals($uc->get_id(), $evidence->get_usercompetencyid()); } + /** + * Assert that grading a competency in course throws an exception. + * + * @param string $exceptiontype The exception type. + * @param string $exceptiontest The exceptiont text. + * @param int $courseid The course ID. + * @param int $userid The user ID. + * @param int $compid The competency ID. + * @param int $grade The grade. + * @param boolean $override Overridden flag. + */ protected function assertExceptionWithGradeCompetencyInCourse($exceptiontype, $exceptiontext, $courseid, $userid, $compid, $grade = 1, $override = true) { @@ -4155,12 +4289,14 @@ class tool_lp_api_testcase extends advanced_testcase { $result = api::get_least_proficient_competencies_for_template($tpl->get_id(), 0, 2); // Our times completed counts should look like this: - // comp1 - 1 - // comp2 - 1 - // comp3 - 2 - // comp4 - 0 - // comp5 - 1 - // comp6 - 0 + // - comp1 - 1 + // - comp2 - 1 + // - comp3 - 2 + // - comp4 - 0 + // - comp5 - 1 + // - comp6 - 0 + // + // And this is a fullstop to make CiBoT happy. $this->assertEquals(2, count($result)); $leastarray = array($comp4->get_id(), $comp6->get_id()); foreach ($result as $one) { diff --git a/admin/tool/lp/tests/externallib_test.php b/admin/tool/lp/tests/externallib_test.php index c690465e5c7..0c4798bb691 100644 --- a/admin/tool/lp/tests/externallib_test.php +++ b/admin/tool/lp/tests/externallib_test.php @@ -340,6 +340,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase { $result = $this->create_competency_framework(1, true); $this->fail('User cannot create a framework at system level.'); } catch (required_capability_exception $e) { + // All good. } } @@ -416,6 +417,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase { $result = (object) external_api::clean_returnvalue(external::read_competency_framework_returns(), $result); $this->fail('User cannot read a framework at system level.'); } catch (required_capability_exception $e) { + // All good. } } @@ -474,6 +476,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase { $result = external::read_competency_framework($insystem->id); $this->fail('Current user cannot should not be able to read the framework.'); } catch (required_capability_exception $e) { + // All good. } } @@ -513,6 +516,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase { $result = external_api::clean_returnvalue(external::delete_competency_framework_returns(), $result); $this->fail('Current user cannot should not be able to delete the framework.'); } catch (required_capability_exception $e) { + // All good. } } @@ -562,6 +566,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase { $result = $this->update_competency_framework($insystem->id, 4, true); $this->fail('Current user should not be able to update the framework.'); } catch (required_capability_exception $e) { + // All good. } } @@ -786,6 +791,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase { $competency = $this->create_competency(2, $insystem->id); $this->fail('User should not be able to create a competency in system context.'); } catch (required_capability_exception $e) { + // All good. } } @@ -862,6 +868,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase { external::read_competency($insystem->id); $this->fail('User should not be able to read a competency in system context.'); } catch (required_capability_exception $e) { + // All good. } } @@ -920,6 +927,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase { external::read_competency($insystem->id); $this->fail('User should not be able to read a competency in system context.'); } catch (required_capability_exception $e) { + // All good. } } @@ -960,6 +968,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase { $result = external::delete_competency($insystem->id); $this->fail('User should not be able to delete a competency in system context.'); } catch (required_capability_exception $e) { + // All good. } } @@ -1012,6 +1021,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase { $result = $this->update_competency($insystem->id, 3); $this->fail('User should not be able to update a competency in system context.'); } catch (required_capability_exception $e) { + // All good. } } @@ -1781,6 +1791,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase { $result = $this->create_template(1, true); $this->fail('Invalid permissions'); } catch (required_capability_exception $e) { + // All good. } // A user without permission in a category. @@ -1789,6 +1800,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase { $result = $this->create_template(1, false); $this->fail('Invalid permissions'); } catch (required_capability_exception $e) { + // All good. } // A user with permissions in the system. @@ -1809,6 +1821,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase { $result = $this->create_template(3, true); $this->fail('Invalid permissions'); } catch (required_capability_exception $e) { + // All good. } $result = $this->create_template(3, false); @@ -1843,11 +1856,13 @@ class tool_lp_external_testcase extends externallib_advanced_testcase { external::read_template($systemplate->id); $this->fail('Invalid permissions'); } catch (required_capability_exception $e) { + // All good. } try { external::read_template($cattemplate->id); $this->fail('Invalid permissions'); } catch (required_capability_exception $e) { + // All good. } // User with permissions to read in a category. @@ -1860,6 +1875,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase { external::read_template($systemplate->id); $this->fail('Invalid permissions'); } catch (required_capability_exception $e) { + // All good. } $result = external::read_template($cattemplate->id); @@ -1920,12 +1936,14 @@ class tool_lp_external_testcase extends externallib_advanced_testcase { $this->update_template($systemplate->id, 3); $this->fail('Invalid permissions'); } catch (required_capability_exception $e) { + // All good. } try { $this->update_template($cattemplate->id, 3); $this->fail('Invalid permissions'); } catch (required_capability_exception $e) { + // All good. } // User with permissions to update in category. @@ -1934,6 +1952,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase { $this->update_template($systemplate->id, 3); $this->fail('Invalid permissions'); } catch (required_capability_exception $e) { + // All good. } $result = $this->update_template($cattemplate->id, 3); @@ -1998,11 +2017,13 @@ class tool_lp_external_testcase extends externallib_advanced_testcase { external::delete_template($sys1->id); $this->fail('Invalid permissions'); } catch (required_capability_exception $e) { + // All good. } try { external::delete_template($cat1->id); $this->fail('Invalid permissions'); } catch (required_capability_exception $e) { + // All good. } // User with category permissions. @@ -2011,6 +2032,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase { external::delete_template($sys1->id); $this->fail('Invalid permissions'); } catch (required_capability_exception $e) { + // All good. } $result = external::delete_template($cat1->id); @@ -2052,6 +2074,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase { external::list_templates('id', 'ASC', 0, 10, array('contextid' => $syscontextid), 'children', false); $this->fail('Invalid permissions'); } catch (required_capability_exception $e) { + // All good. } // User with category permissions. @@ -2142,6 +2165,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase { external::count_templates(array('contextid' => $syscontextid), 'children'); $this->fail('Invalid permissions'); } catch (required_capability_exception $e) { + // All good. } // User with category permissions. @@ -2985,6 +3009,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase { $result = external::search_cohorts("Cohortsearch", $syscontext, 'parents'); $this->fail('Invalid permissions in system'); } catch (required_capability_exception $e) { + // All good. } // A user without permission in a category. @@ -2993,6 +3018,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase { $result = external::search_cohorts("Cohortsearch", $catcontext, 'parents'); $this->fail('Invalid permissions in category'); } catch (required_capability_exception $e) { + // All good. } // A user with permissions in the system. @@ -3029,6 +3055,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase { $result = external::search_cohorts("Cohortsearch", $syscontext, 'invalid'); $this->fail('Invalid parameter includes'); } catch (coding_exception $e) { + // All good. } } diff --git a/admin/tool/lp/tests/task_test.php b/admin/tool/lp/tests/task_test.php index aee34644834..0a04e9b45be 100644 --- a/admin/tool/lp/tests/task_test.php +++ b/admin/tool/lp/tests/task_test.php @@ -146,7 +146,7 @@ class tool_lp_task_testcase extends advanced_testcase { $task->set_last_run_time($currenttime); $this->assertEquals(4, plan::count_records(array('templateid' => $tpl->get_id()))); - // Test a user plan deleted will not be recreated + // Test a user plan deleted will not be recreated. $currenttime = $currenttime + 1; $plan = plan::get_record(array('userid' => $user4->id, 'templateid' => $tpl->get_id())); \tool_lp\api::delete_plan($plan->get_id()); diff --git a/admin/tool/lp/user_competency_in_course.php b/admin/tool/lp/user_competency_in_course.php index c0854c02726..1bc0ff62478 100644 --- a/admin/tool/lp/user_competency_in_course.php +++ b/admin/tool/lp/user_competency_in_course.php @@ -82,7 +82,6 @@ echo $output->header(); if ($userid > 0) { echo $OUTPUT->context_header($userheading, 3); } -//echo $output->heading($title, 3); $baseurl = new moodle_url('/admin/tool/lp/user_competency_in_course.php'); $nav = new \tool_lp\output\user_competency_course_navigation($userid, $competencyid, $courseid, $baseurl); diff --git a/admin/tool/lpmigrate/classes/form/migrate_framework.php b/admin/tool/lpmigrate/classes/form/migrate_framework.php index 174b54f9a6c..db50360558e 100644 --- a/admin/tool/lpmigrate/classes/form/migrate_framework.php +++ b/admin/tool/lpmigrate/classes/form/migrate_framework.php @@ -39,8 +39,13 @@ require_once($CFG->libdir . '/formslib.php'); */ class migrate_framework extends \moodleform { + /** @var context The page context. */ protected $pagecontext; + /** + * Constructor. + * @param \context $context The page context. + */ public function __construct(\context $context) { $this->pagecontext = $context; parent::__construct(); @@ -66,11 +71,14 @@ class migrate_framework extends \moodleform { $mform->addHelpButton('to', 'migrateto', 'tool_lpmigrate'); $mform->addElement('header', 'hdrcourses', get_string('courses')); - $mform->addElement('course', 'allowedcourses', get_string('limittothese', 'tool_lpmigrate'), array('showhidden' => true, 'multiple' => true)); + $mform->addElement('course', 'allowedcourses', get_string('limittothese', 'tool_lpmigrate'), + array('showhidden' => true, 'multiple' => true)); $mform->addHelpButton('allowedcourses', 'allowedcourses', 'tool_lpmigrate'); - $mform->addElement('course', 'disallowedcourses', get_string('excludethese', 'tool_lpmigrate'), array('showhidden' => true, 'multiple' => true)); + $mform->addElement('course', 'disallowedcourses', get_string('excludethese', 'tool_lpmigrate'), + array('showhidden' => true, 'multiple' => true)); $mform->addHelpButton('disallowedcourses', 'disallowedcourses', 'tool_lpmigrate'); - $mform->addElement('date_time_selector', 'coursestartdate', get_string('startdatefrom', 'tool_lpmigrate'), array('optional' => true)); + $mform->addElement('date_time_selector', 'coursestartdate', get_string('startdatefrom', 'tool_lpmigrate'), + array('optional' => true)); $mform->addHelpButton('coursestartdate', 'coursestartdate', 'tool_lpmigrate'); $this->add_action_buttons(true, get_string('performmigration', 'tool_lpmigrate')); diff --git a/admin/tool/lpmigrate/classes/framework_processor.php b/admin/tool/lpmigrate/classes/framework_processor.php index 500ee1592a7..697b47c0821 100644 --- a/admin/tool/lpmigrate/classes/framework_processor.php +++ b/admin/tool/lpmigrate/classes/framework_processor.php @@ -99,7 +99,7 @@ class framework_processor { * Constructor. * * @param framework_mapper $mapper The mapper. - * @param \core\progress\base|null $progress The progress object. + * @param \core\progress\base $progress The progress object. */ public function __construct(framework_mapper $mapper, \core\progress\base $progress = null) { $this->mapper = $mapper; diff --git a/admin/tool/lpmigrate/classes/output/migrate_framework_results.php b/admin/tool/lpmigrate/classes/output/migrate_framework_results.php index c3369710227..405023fc188 100644 --- a/admin/tool/lpmigrate/classes/output/migrate_framework_results.php +++ b/admin/tool/lpmigrate/classes/output/migrate_framework_results.php @@ -46,6 +46,7 @@ class migrate_framework_results implements renderable, templatable { /** @var context The current page context. */ protected $pagecontext; + /** @var framework_processor The processor. */ protected $processor; /** diff --git a/admin/tool/lpmigrate/classes/output/renderer.php b/admin/tool/lpmigrate/classes/output/renderer.php index 98125d16503..1983c81f077 100644 --- a/admin/tool/lpmigrate/classes/output/renderer.php +++ b/admin/tool/lpmigrate/classes/output/renderer.php @@ -41,7 +41,7 @@ class renderer extends plugin_renderer_base { /** * Defer to template. * - * @param renderable $page + * @param migrate_framework_results $page * @return string */ public function render_migrate_framework_results(migrate_framework_results $page) { diff --git a/admin/tool/lpmigrate/frameworks.php b/admin/tool/lpmigrate/frameworks.php index 0cb4fc7dd93..58fd3ac51d1 100644 --- a/admin/tool/lpmigrate/frameworks.php +++ b/admin/tool/lpmigrate/frameworks.php @@ -47,7 +47,7 @@ if ($form->is_cancelled()) { } else if ($data = $form->get_data()) { - // Map competencies from both framework + // Map competencies from both framework. $mapper = new \tool_lpmigrate\framework_mapper($data->from, $data->to); $mapper->automap(); diff --git a/admin/tool/lpmigrate/tests/processor_test.php b/admin/tool/lpmigrate/tests/processor_test.php index 6ff6d7a161c..816cde1a02e 100644 --- a/admin/tool/lpmigrate/tests/processor_test.php +++ b/admin/tool/lpmigrate/tests/processor_test.php @@ -278,7 +278,7 @@ class tool_lpmigrate_framework_processor_testcase extends advanced_testcase { $this->assertModuleCompetencyNotMigrated($this->cms[$this->c2->id]['F1'], $this->f1comps['A3'], $this->f2comps['A3']); } - public function abc_test_course_start_date_from() { + public function test_course_start_date_from() { $this->setAdminUser(); $mapper = new framework_mapper($this->f1->get_id(), $this->f2->get_id()); @@ -356,7 +356,7 @@ class tool_lpmigrate_framework_processor_testcase extends advanced_testcase { $this->assertRegexp('/competency already exists/', $warning['message']); $this->assertCourseCompetencyExists($this->c1, $this->f1comps['A1']); - $this->assertModuleCompetencyExists($this->c2, $this->f1comps['A2']); + $this->assertModuleCompetencyExists($this->cms[$this->c2->id]['F1'], $this->f1comps['A2']); } public function test_destination_competency_exists_remove_original() { @@ -392,7 +392,7 @@ class tool_lpmigrate_framework_processor_testcase extends advanced_testcase { $this->assertEquals(array(), $processor->get_warnings()); $this->assertCourseCompetencyNotExists($this->c1, $this->f1comps['A1']); - $this->assertModuleCompetencyNotExists($this->c2, $this->f1comps['A2']); + $this->assertModuleCompetencyNotExists($this->cms[$this->c2->id]['F1'], $this->f1comps['A2']); } public function test_permission_exception() { @@ -478,16 +478,35 @@ class tool_lpmigrate_framework_processor_testcase extends advanced_testcase { $this->assertModuleCompetencyNotMigrated($this->cms[$this->c2->id]['F1'], $this->f1comps['A3'], $this->f2comps['A2']); } + /** + * Assert that the course competency exists. + * + * @param stdClass $course The course. + * @param competency $competency The competency. + */ protected function assertCourseCompetencyExists($course, $competency) { - return course_competency::record_exists_select("courseid = :courseid AND competencyid = :competencyid", - array('courseid' => $course->id, 'competencyid' => $competency->get_id())); + $this->assertTrue(course_competency::record_exists_select("courseid = :courseid AND competencyid = :competencyid", + array('courseid' => $course->id, 'competencyid' => $competency->get_id()))); } + /** + * Assert that the course competency does not exist. + * + * @param stdClass $course The course. + * @param competency $competency The competency. + */ protected function assertCourseCompetencyNotExists($course, $competency) { - return !course_competency::record_exists_select("courseid = :courseid AND competencyid = :competencyid", - array('courseid' => $course->id, 'competencyid' => $competency->get_id())); + $this->assertFalse(course_competency::record_exists_select("courseid = :courseid AND competencyid = :competencyid", + array('courseid' => $course->id, 'competencyid' => $competency->get_id()))); } + /** + * Assert that the course competency was migrated. + * + * @param stdClass $course The course. + * @param competency $compfrom The competency from. + * @param competency $compto The competency to. + */ protected function assertCourseCompetencyMigrated($course, $compfrom, $compto) { $ccs = $this->ccs[$course->id]; @@ -506,6 +525,13 @@ class tool_lpmigrate_framework_processor_testcase extends advanced_testcase { $this->assertEquals($before->get_ruleoutcome(), $after->get_ruleoutcome()); } + /** + * Assert that the course competency was not migrated. + * + * @param stdClass $course The course. + * @param competency $compfrom The competency from. + * @param competency $compto The competency to. + */ protected function assertCourseCompetencyNotMigrated($course, $compfrom, $compto) { $ccs = $this->ccs[$course->id]; @@ -517,20 +543,39 @@ class tool_lpmigrate_framework_processor_testcase extends advanced_testcase { $this->assertEquals($before->get_id(), $after->get_id()); $this->assertEquals($before->get_courseid(), $after->get_courseid()); - // $this->assertEquals($before->get_sortorder(), $after->get_sortorder()); + $this->assertEquals($before->get_sortorder(), $after->get_sortorder()); $this->assertEquals($before->get_ruleoutcome(), $after->get_ruleoutcome()); } + /** + * Assert that the course module competency exists. + * + * @param stdClass $cm The CM. + * @param competency $competency The competency. + */ protected function assertModuleCompetencyExists($cm, $competency) { - return course_module_competency::record_exists_select("cmid = :cmid AND competencyid = :competencyid", - array('cmid' => $cm->id, 'competencyid' => $competency->get_id())); + $this->assertTrue(course_module_competency::record_exists_select("cmid = :cmid AND competencyid = :competencyid", + array('cmid' => $cm->cmid, 'competencyid' => $competency->get_id()))); } + /** + * Assert that the course module competency does not exist. + * + * @param stdClass $cm The CM. + * @param competency $competency The competency. + */ protected function assertModuleCompetencyNotExists($cm, $competency) { - return !course_module_competency::record_exists_select("cmid = :cmid AND competencyid = :competencyid", - array('cmid' => $cm->id, 'competencyid' => $competency->get_id())); + $this->assertFalse(course_module_competency::record_exists_select("cmid = :cmid AND competencyid = :competencyid", + array('cmid' => $cm->cmid, 'competencyid' => $competency->get_id()))); } + /** + * Assert that the course module competency was migrated. + * + * @param stdClass $cm The CM. + * @param competency $compfrom The competency from. + * @param competency $compto The competency to. + */ protected function assertModuleCompetencyMigrated($cm, $compfrom, $compto) { $cmcs = $this->cmcs[$cm->cmid]; @@ -549,6 +594,13 @@ class tool_lpmigrate_framework_processor_testcase extends advanced_testcase { $this->assertEquals($before->get_ruleoutcome(), $after->get_ruleoutcome()); } + /** + * Assert that the course module competency was not migrated. + * + * @param stdClass $cm The CM. + * @param competency $compfrom The competency from. + * @param competency $compto The competency to. + */ protected function assertModuleCompetencyNotMigrated($cm, $compfrom, $compto) { $cmcs = $this->cmcs[$cm->cmid]; diff --git a/blocks/lp/classes/output/renderer.php b/blocks/lp/classes/output/renderer.php index 5a7c05a7f1a..2c8ce966d1c 100644 --- a/blocks/lp/classes/output/renderer.php +++ b/blocks/lp/classes/output/renderer.php @@ -37,16 +37,31 @@ use renderable; */ class renderer extends plugin_renderer_base { + /** + * Defer to template. + * @param renderable $page + * @return string + */ public function render_competencies_to_review_page(renderable $page) { $data = $page->export_for_template($this); return parent::render_from_template('block_lp/competencies_to_review_page', $data); } + /** + * Defer to template. + * @param renderable $page + * @return string + */ public function render_plans_to_review_page(renderable $page) { $data = $page->export_for_template($this); return parent::render_from_template('block_lp/plans_to_review_page', $data); } + /** + * Defer to template. + * @param renderable $page + * @return string + */ public function render_summary(renderable $summary) { $data = $summary->export_for_template($this); return parent::render_from_template('block_lp/summary', $data); diff --git a/blocks/lp/classes/output/summary.php b/blocks/lp/classes/output/summary.php index 50cabbf8d12..fde41262e87 100644 --- a/blocks/lp/classes/output/summary.php +++ b/blocks/lp/classes/output/summary.php @@ -43,12 +43,21 @@ use templatable; */ class summary implements renderable, templatable { + /** @var array Active plans. */ protected $activeplans = array(); + /** @var array Competencies to review. */ protected $compstoreview = array(); + /** @var array Plans to review. */ protected $planstoreview = array(); + /** @var array Plans. */ protected $plans = array(); + /** @var stdClass The user. */ protected $user; + /** + * Constructor. + * @param stdClass $user The user. + */ public function __construct($user = null) { global $USER; if (!$user) { diff --git a/report/competency/classes/external.php b/report/competency/classes/external.php index c373bb60293..b83b1a3fcd9 100644 --- a/report/competency/classes/external.php +++ b/report/competency/classes/external.php @@ -73,6 +73,7 @@ class external extends external_api { * Loads the data required to render the report. * * @param int $courseid The course id + * @param int $userid The user id * @return \stdClass */ public static function data_for_report($courseid, $userid) { diff --git a/report/competency/classes/output/renderer.php b/report/competency/classes/output/renderer.php index 6981f93ac56..455853fa45c 100644 --- a/report/competency/classes/output/renderer.php +++ b/report/competency/classes/output/renderer.php @@ -41,8 +41,7 @@ class renderer extends plugin_renderer_base { /** * Defer to template. * - * @param report $report - * + * @param report $page * @return string html for the page */ public function render_report(report $page) { diff --git a/report/competency/classes/output/user_course_navigation.php b/report/competency/classes/output/user_course_navigation.php index c2f16796f9f..9f71c7c6269 100644 --- a/report/competency/classes/output/user_course_navigation.php +++ b/report/competency/classes/output/user_course_navigation.php @@ -33,7 +33,7 @@ use stdClass; /** * User course navigation class. * - * @package tool_lp + * @package report_competency * @copyright 2015 Damyon Wiese * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -51,9 +51,9 @@ class user_course_navigation implements renderable, templatable { /** * Construct. * - * @param $userid - * @param $courseid - * @param $baseurl + * @param int $userid + * @param int $courseid + * @param string $baseurl */ public function __construct($userid, $courseid, $baseurl) { $this->userid = $userid; diff --git a/report/competency/index.php b/report/competency/index.php index aefac18983a..42add489570 100644 --- a/report/competency/index.php +++ b/report/competency/index.php @@ -17,7 +17,7 @@ /** * This page lets users to manage site wide competencies. * - * @package tool_lp + * @package report_competency * @copyright 2015 Damyon Wiese * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/report/competency/lib.php b/report/competency/lib.php index a788f665219..fe1a3bfa11e 100644 --- a/report/competency/lib.php +++ b/report/competency/lib.php @@ -35,7 +35,7 @@ defined('MOODLE_INTERNAL') || die; */ function report_competency_extend_navigation_course($navigation, $course, $context) { if (has_capability('tool/lp:coursecompetencyread', $context)) { - $url = new moodle_url('/report/competency/index.php', array('id'=>$course->id)); + $url = new moodle_url('/report/competency/index.php', array('id' => $course->id)); $name = get_string('pluginname', 'report_competency'); $navigation->add($name, $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/report', '')); }