From b17d3d10d77a2b8d6608ad7828c2da466a8a400f Mon Sep 17 00:00:00 2001 From: Ankit Agarwal Date: Tue, 16 Jun 2015 11:52:02 +0530 Subject: [PATCH] MDL-50608 tool_lp: Code cleanup --- .../lp/amd/build/competencyactions.min.js | 2 +- .../tool/lp/amd/build/frameworkdelete.min.js | 2 +- admin/tool/lp/amd/build/plandelete.min.js | 2 +- admin/tool/lp/amd/build/templatedelete.min.js | 2 +- admin/tool/lp/amd/src/competencies.js | 4 +- admin/tool/lp/amd/src/competencyactions.js | 16 +- admin/tool/lp/amd/src/frameworkdelete.js | 6 +- admin/tool/lp/amd/src/plandelete.js | 11 +- admin/tool/lp/amd/src/templatedelete.js | 6 +- admin/tool/lp/classes/api.php | 15 +- admin/tool/lp/classes/competency.php | 24 +- .../tool/lp/classes/competency_framework.php | 5 +- admin/tool/lp/classes/course_competency.php | 4 +- admin/tool/lp/classes/external.php | 135 +++-- admin/tool/lp/classes/form/competency.php | 4 +- .../lp/classes/form/competency_framework.php | 4 +- admin/tool/lp/classes/form/template.php | 6 +- .../output/course_competencies_page.php | 19 +- .../output/manage_competencies_page.php | 17 +- .../manage_competency_frameworks_page.php | 9 +- .../classes/output/manage_templates_page.php | 7 +- admin/tool/lp/classes/output/plans_page.php | 13 +- admin/tool/lp/classes/output/renderer.php | 18 +- .../output/template_competencies_page.php | 16 + admin/tool/lp/classes/persistent.php | 25 +- admin/tool/lp/classes/plan.php | 100 +++- admin/tool/lp/classes/template.php | 2 - admin/tool/lp/db/access.php | 138 ++--- admin/tool/lp/db/services.php | 540 +++++++++--------- admin/tool/lp/editcompetency.php | 11 +- admin/tool/lp/editcompetencyframework.php | 2 +- admin/tool/lp/edittemplate.php | 2 +- admin/tool/lp/lang/en/tool_lp.php | 184 +++--- ...manage_competency_frameworks_page.mustache | 4 +- .../templates/manage_templates_page.mustache | 4 +- admin/tool/lp/tests/externallib_test.php | 46 +- 36 files changed, 811 insertions(+), 594 deletions(-) diff --git a/admin/tool/lp/amd/build/competencyactions.min.js b/admin/tool/lp/amd/build/competencyactions.min.js index 6a9a021dae2..87ead549f72 100644 --- a/admin/tool/lp/amd/build/competencyactions.min.js +++ b/admin/tool/lp/amd/build/competencyactions.min.js @@ -1 +1 @@ -define(["jquery","core/url","core/templates","core/notification","core/str","core/ajax","tool_lp/dragdrop-reorder","tool_lp/tree","tool_lp/dialogue","tool_lp/menubar"],function(a,b,c,d,e,f,g,h,i,j){var k=null,l=null,m=null,n=function(){var c=a('[data-region="competencyactions"]').data("competency"),d={competencyframeworkid:k.getCompetencyFrameworkId()};null!==c&&(d.parentid=c.id);var e=a.param(d),f=b.relativeUrl("/admin/tool/lp/editcompetency.php?"+e);window.location=f},o=function(){if("undefined"==typeof m&&(m=0),m!=l){var b=a('[data-region="filtercompetencies"]').data("frameworkid"),c=f.call([{methodname:"tool_lp_set_parent_competency",args:{competencyid:l,parentid:m}},{methodname:"tool_lp_data_for_competencies_manage_page",args:{competencyframeworkid:b,search:a('[data-region="filtercompetencies"] input').val()}}]);c[1].done(t).fail(d.exception)}},p=function(b){new h("[data-enhance=movetree]",function(b){m=a(b).data("id")});var c=a(b.getContent());c.on("click",'[data-action="move"]',function(){b.close(),o()}),c.on("click",'[data-action="cancel"]',function(){b.close()})},q=function(a,b){var c;for(c=0;c $framework) { $sort = $framework->get_sortorder(); - if ($down && $sort > $frameworkfrom->get_sortorder() && $sort <= $frameworkto->get_sortorder()) { + if ($down && $sort > $frameworkfrom->get_sortorder() && $sort <= $frameworkto->get_sortorder()) { $framework->set_sortorder($framework->get_sortorder() - 1); $framework->update(); - } else if (!$down && $sort >= $frameworkto->get_sortorder() && $sort < $frameworkfrom->get_sortorder()) { + } else if (!$down && $sort >= $frameworkto->get_sortorder() && $sort < $frameworkfrom->get_sortorder()) { $framework->set_sortorder($framework->get_sortorder() + 1); $framework->update(); } @@ -501,7 +503,6 @@ class api { // OK - all set. $coursecompetency = new course_competency(); $courses = $coursecompetency->list_courses($competencyid); - $count = 0; $result = array(); // Now check permissions on each course. foreach ($courses as $id => $course) { @@ -790,10 +791,10 @@ class api { foreach ($all as $id => $template) { $sort = $template->get_sortorder(); - if ($down && $sort > $templatefrom->get_sortorder() && $sort <= $templateto->get_sortorder()) { + if ($down && $sort > $templatefrom->get_sortorder() && $sort <= $templateto->get_sortorder()) { $template->set_sortorder($template->get_sortorder() - 1); $template->update(); - } else if (!$down && $sort >= $templateto->get_sortorder() && $sort < $templatefrom->get_sortorder()) { + } else if (!$down && $sort >= $templateto->get_sortorder() && $sort < $templatefrom->get_sortorder()) { $template->set_sortorder($template->get_sortorder() + 1); $template->update(); } @@ -1161,7 +1162,7 @@ class api { // We don't allow users without planmanage and without // planmanageown to edit plans that other users modified. if (!$manageplans && !$manageownplan && $USER->id != $current->get_usermodified()) { - throw new moodle_exception('erroreditingmodifiedplan', 'tool_lp'); + throw new \moodle_exception('erroreditingmodifiedplan', 'tool_lp'); } else if (!$manageplans && $USER->id != $current->get_userid()) { throw new required_capability_exception($context, 'tool/lp:planmanageall', 'nopermissions', ''); } diff --git a/admin/tool/lp/classes/competency.php b/admin/tool/lp/classes/competency.php index 5701eb4bd62..267dd27217b 100644 --- a/admin/tool/lp/classes/competency.php +++ b/admin/tool/lp/classes/competency.php @@ -145,7 +145,7 @@ class competency extends persistent { /** * Get the sort order index. * - * @return string The sort order index + * @return int The sort order index */ public function get_sortorder() { return $this->sortorder; @@ -190,7 +190,7 @@ class competency extends persistent { /** * Set the parent id * - * @param int $parentid The parent id number (can be null) + * @param int $id The parent id number (can be null) */ public function set_parentid($id) { $this->parentid = $id; @@ -236,7 +236,7 @@ class competency extends persistent { * Populate this class with data from a DB record. * * @param stdClass $record A DB record. - * @return framework + * @return \tool_lp\competency */ public function from_record($record) { if (isset($record->id)) { @@ -320,7 +320,8 @@ class competency extends persistent { } else { $this->path = '/0/'; } - $this->sortorder = $this->count_records(array('parentid' => $this->parentid, 'competencyframeworkid' => $this->competencyframeworkid)); + $this->sortorder = $this->count_records(array('parentid' => $this->parentid, + 'competencyframeworkid' => $this->competencyframeworkid)); return parent::create(); } @@ -360,11 +361,13 @@ class competency extends persistent { * This does a specialised search that finds all nodes in the tree with matching text on any text like field, * and returns this node and all its parents in a displayable sort order. * - * @param string $searchText The text to search for. + * + * @param string $searchtext The text to search for. * @param int $competencyframeworkid The competency framework to limit the search. + * * @return persistent */ - public function search($searchText, $competencyframeworkid) { + public function search($searchtext, $competencyframeworkid) { global $DB; $like1 = $DB->sql_like('shortname', ':like1', false); @@ -372,9 +375,9 @@ class competency extends persistent { $like3 = $DB->sql_like('description', ':like3', false); $params = array( - 'like1' => '%' . $DB->sql_like_escape($searchText) . '%', - 'like2' => '%' . $DB->sql_like_escape($searchText) . '%', - 'like3' => '%' . $DB->sql_like_escape($searchText) . '%', + 'like1' => '%' . $DB->sql_like_escape($searchtext) . '%', + 'like2' => '%' . $DB->sql_like_escape($searchtext) . '%', + 'like3' => '%' . $DB->sql_like_escape($searchtext) . '%', 'frameworkid' => $competencyframeworkid ); @@ -401,7 +404,8 @@ class competency extends persistent { if (count($parents)) { list($parentsql, $parentparams) = $DB->get_in_or_equal($parents, SQL_PARAMS_NAMED); - $parentrecords = $DB->get_records_select($this->get_table_name(), 'id ' . $parentsql, $parentparams, 'path, sortorder ASC', '*'); + $parentrecords = $DB->get_records_select($this->get_table_name(), 'id ' . $parentsql, + $parentparams, 'path, sortorder ASC', '*'); foreach ($parentrecords as $id => $record) { $records[$id] = $record; diff --git a/admin/tool/lp/classes/competency_framework.php b/admin/tool/lp/classes/competency_framework.php index 759bf685441..cff830e1685 100644 --- a/admin/tool/lp/classes/competency_framework.php +++ b/admin/tool/lp/classes/competency_framework.php @@ -185,7 +185,7 @@ class competency_framework extends persistent { /** * Set the scale ID. * - * @param int $scale The scale ID + * @param int $scaleid The scale ID */ public function set_scaleid($scaleid) { $this->scaleid = $scaleid; @@ -213,7 +213,7 @@ class competency_framework extends persistent { * Populate this class with data from a DB record. * * @param stdClass $record A DB record. - * @return framework + * @return \tool_lp\competency_framework */ public function from_record($record) { if (isset($record->id)) { @@ -289,5 +289,4 @@ class competency_framework extends persistent { return parent::create(); } - } diff --git a/admin/tool/lp/classes/course_competency.php b/admin/tool/lp/classes/course_competency.php index f2dae18148a..047f7e9b5f1 100644 --- a/admin/tool/lp/classes/course_competency.php +++ b/admin/tool/lp/classes/course_competency.php @@ -159,7 +159,7 @@ class course_competency extends persistent { * for the full records use list_courses. * * @param int $competencyid The competency id - * @return int + * @return array() */ public function list_courses_min($competencyid) { global $DB; @@ -224,7 +224,7 @@ class course_competency extends persistent { * * @param int $courseid The course id * @param bool $onlyvisible If true, only count visible competencies in this course. - * @return array[competency] + * @return competency[] */ public function list_competencies($courseid, $onlyvisible) { global $DB; diff --git a/admin/tool/lp/classes/external.php b/admin/tool/lp/classes/external.php index ccca11fc32d..d702b1ff841 100644 --- a/admin/tool/lp/classes/external.php +++ b/admin/tool/lp/classes/external.php @@ -236,7 +236,7 @@ class external extends external_api { * @param string $description The description * @param int $descriptionformat The description format * @param bool $visible Is this framework visible. - * @return stdClass The new record + * @return \stdClass The new record */ public static function create_competency_framework($shortname, $idnumber, $description, $descriptionformat, $visible) { $params = self::validate_parameters(self::create_competency_framework_parameters(), @@ -293,7 +293,7 @@ class external extends external_api { * Read a competency framework by id. * * @param int $id The id of the framework. - * @return stdClass + * @return \stdClass */ public static function read_competency_framework($id) { $params = self::validate_parameters(self::read_competency_framework_parameters(), @@ -480,7 +480,15 @@ class external extends external_api { /** * List the existing competency frameworks * - * @return boolean + * @param string $filters + * @param int $sort + * @param string $order + * @param string $skip + * @param int $limit + * + * @return array + * @throws \required_capability_exception + * @throws invalid_parameter_exception */ public static function list_competency_frameworks($filters, $sort, $order, $skip, $limit) { $params = self::validate_parameters(self::list_competency_frameworks_parameters(), @@ -557,6 +565,7 @@ class external extends external_api { /** * Count the existing competency frameworks * + * @param string $filters Filters to use. * @return boolean */ public static function count_competency_frameworks($filters) { @@ -613,7 +622,7 @@ class external extends external_api { public static function data_for_competency_frameworks_manage_page() { global $PAGE; - $renderable = new \tool_lp\output\manage_competency_frameworks_page(); + $renderable = new output\manage_competency_frameworks_page(); $renderer = $PAGE->get_renderer('tool_lp'); $data = $renderable->export_for_template($renderer); @@ -919,7 +928,7 @@ class external extends external_api { * Read a competency by id. * * @param int $id The id of the competency - * @return stdClass + * @return \stdClass */ public static function read_competency($id) { $params = self::validate_parameters(self::read_competency_parameters(), @@ -1104,9 +1113,17 @@ class external extends external_api { } /** - * List the existing competency frameworks + * List the existing competency. * - * @return boolean + * @param string $filters + * @param int $sort + * @param string $order + * @param string $skip + * @param int $limit + * + * @return array + * @throws \required_capability_exception + * @throws invalid_parameter_exception */ public static function list_competencies($filters, $sort, $order, $skip, $limit) { $params = self::validate_parameters(self::list_competencies_parameters(), @@ -1123,7 +1140,8 @@ class external extends external_api { } $safefilters = array(); - $validcolumns = array('id', 'shortname', 'description', 'sortorder', 'idnumber', 'visible', 'parentid', 'competencyframeworkid'); + $validcolumns = array('id', 'shortname', 'description', 'sortorder', + 'idnumber', 'visible', 'parentid', 'competencyframeworkid'); foreach ($params['filters'] as $filter) { if (!in_array($filter->column, $validcolumns)) { throw new invalid_parameter_exception('Filter column was invalid'); @@ -1190,6 +1208,14 @@ class external extends external_api { * * @return boolean */ + /** + * List the existing competency frameworks + * + * @param string $searchtext Text to search. + * @param int $competencyframeworkid Framework id. + * + * @return array + */ public static function search_competencies($searchtext, $competencyframeworkid) { $params = self::validate_parameters(self::search_competencies_parameters(), array( @@ -1215,7 +1241,6 @@ class external extends external_api { return new external_multiple_structure(self::get_competency_external_structure()); } - /** * Returns description of count_competencies() parameters. * @@ -1234,8 +1259,9 @@ class external extends external_api { } /** - * Count the existing competency frameworks + * Count the existing competency frameworks. * + * @param string $filters Filters to use. * @return boolean */ public static function count_competencies($filters) { @@ -1245,7 +1271,8 @@ class external extends external_api { )); $safefilters = array(); - $validcolumns = array('id', 'shortname', 'description', 'sortorder', 'idnumber', 'visible', 'parentid', 'competencyframeworkid'); + $validcolumns = array('id', 'shortname', 'description', 'sortorder', 'idnumber', + 'visible', 'parentid', 'competencyframeworkid'); foreach ($params['filters'] as $filter) { if (!in_array($filter->column, $validcolumns)) { throw new invalid_parameter_exception('Filter column was invalid'); @@ -1300,6 +1327,9 @@ class external extends external_api { /** * Loads the data required to render the competencies_manage_page template. * + * @param int $competencyframeworkid Framework id. + * @param string $search Text to search. + * * @return boolean */ public static function data_for_competencies_manage_page($competencyframeworkid, $search) { @@ -1310,9 +1340,9 @@ class external extends external_api { 'search' => $search )); - $framework = new \tool_lp\competency_framework($params['competencyframeworkid']); + $framework = new competency_framework($params['competencyframeworkid']); - $renderable = new \tool_lp\output\manage_competencies_page($framework, $params['search']); + $renderable = new output\manage_competencies_page($framework, $params['search']); $renderer = $PAGE->get_renderer('tool_lp'); $data = $renderable->export_for_template($renderer); @@ -1370,10 +1400,12 @@ class external extends external_api { /** * Move the competency to a new parent. * - * @return boolean + * @param int $competencyid Competency id. + * @param int $parentid Parent id. + * + * @return bool */ public static function set_parent_competency($competencyid, $parentid) { - global $PAGE; $params = self::validate_parameters(self::set_parent_competency_parameters(), array( 'competencyid' => $competencyid, @@ -1420,10 +1452,10 @@ class external extends external_api { /** * Change the sort order of a competency. * + * @param int $competencyid Competency id. * @return boolean */ public static function move_up_competency($competencyid) { - global $PAGE; $params = self::validate_parameters(self::move_up_competency_parameters(), array( 'id' => $competencyid, @@ -1469,10 +1501,10 @@ class external extends external_api { /** * Change the sort order of a competency. * + * @param int $competencyid Competency id. * @return boolean */ public static function move_down_competency($competencyid) { - global $PAGE; $params = self::validate_parameters(self::move_down_competency_parameters(), array( 'id' => $competencyid, @@ -1518,10 +1550,10 @@ class external extends external_api { /** * Count the courses (visible to this user) that use this competency. * + * @param int $competencyid Competency id. * @return int */ public static function count_courses_using_competency($competencyid) { - global $PAGE; $params = self::validate_parameters(self::count_courses_using_competency_parameters(), array( 'id' => $competencyid, @@ -1567,10 +1599,10 @@ class external extends external_api { /** * Count the courses (visible to this user) that use this competency. * + * @param int $competencyid Competency id. * @return array */ public static function list_courses_using_competency($competencyid) { - global $PAGE; $params = self::validate_parameters(self::list_courses_using_competency_parameters(), array( 'id' => $competencyid, @@ -1654,11 +1686,10 @@ class external extends external_api { /** * Count the competencies (visible to this user) in this course. * - * @param int $couseid The course id to check. + * @param int $courseid The course id to check. * @return int */ public static function count_competencies_in_course($courseid) { - global $PAGE; $params = self::validate_parameters(self::count_competencies_in_course_parameters(), array( 'id' => $courseid, @@ -1704,10 +1735,10 @@ class external extends external_api { /** * List the competencies (visible to this user) in this course. * + * @param int $courseid The course id to check. * @return array */ public static function list_competencies_in_course($courseid) { - global $PAGE; $params = self::validate_parameters(self::list_competencies_in_course_parameters(), array( 'id' => $courseid, @@ -1765,10 +1796,11 @@ class external extends external_api { /** * Count the competencies (visible to this user) in this course. * + * @param int $courseid The course id to check. + * @param int $competencyid Competency id. * @return int */ public static function add_competency_to_course($courseid, $competencyid) { - global $PAGE; $params = self::validate_parameters(self::add_competency_to_course_parameters(), array( 'courseid' => $courseid, @@ -1821,6 +1853,8 @@ class external extends external_api { /** * Count the competencies (visible to this user) in this course. * + * @param int $courseid The course id to check. + * @param int $competencyid Competency id. * @return int */ public static function remove_competency_from_course($courseid, $competencyid) { @@ -1868,6 +1902,7 @@ class external extends external_api { /** * Loads the data required to render the course_competencies_page template. * + * @param int $courseid The course id to check. * @return boolean */ public static function data_for_course_competencies_page($courseid) { @@ -1877,7 +1912,7 @@ class external extends external_api { 'courseid' => $courseid, )); - $renderable = new \tool_lp\output\course_competencies_page($params['courseid']); + $renderable = new output\course_competencies_page($params['courseid']); $renderer = $PAGE->get_renderer('tool_lp'); $data = $renderable->export_for_template($renderer); @@ -2176,7 +2211,7 @@ class external extends external_api { * @param string $description The description of the template. * @param int $descriptionformat The format of the description * @param bool $visible Is this template visible. - * @return stdClass Record of new template. + * @return \stdClass Record of new template. */ public static function create_template($shortname, $idnumber, $duedate, $description, $descriptionformat, $visible) { $params = self::validate_parameters(self::create_template_parameters(), @@ -2234,7 +2269,7 @@ class external extends external_api { * Read a learning plan template by id. * * @param int $id The id of the template. - * @return stdClass + * @return \stdClass */ public static function read_template($id) { $params = self::validate_parameters(self::read_template_parameters(), @@ -2430,7 +2465,13 @@ class external extends external_api { /** * List the existing learning plan templates * - * @return boolean + * @param array $filters Filters to apply. + * @param string $sort Field to sort by. + * @param string $order Sort order. + * @param int $skip Limitstart. + * @param int $limit Number of rows to return. + * + * @return array */ public static function list_templates($filters, $sort, $order, $skip, $limit) { $params = self::validate_parameters(self::list_templates_parameters(), @@ -2507,6 +2548,7 @@ class external extends external_api { /** * Count the existing learning plan templates * + * @param array $filters Filters to allow. * @return boolean */ public static function count_templates($filters) { @@ -2619,7 +2661,7 @@ class external extends external_api { public static function data_for_templates_manage_page() { global $PAGE; - $renderable = new \tool_lp\output\manage_templates_page(); + $renderable = new output\manage_templates_page(); $renderer = $PAGE->get_renderer('tool_lp'); $data = $renderable->export_for_template($renderer); @@ -2674,10 +2716,10 @@ class external extends external_api { /** * Count the learning plan templates (visible to this user) that use this competency. * + * @param int $competencyid Competency id. * @return int */ public static function count_templates_using_competency($competencyid) { - global $PAGE; $params = self::validate_parameters(self::count_templates_using_competency_parameters(), array( 'id' => $competencyid, @@ -2723,6 +2765,7 @@ class external extends external_api { /** * List the learning plan templates (visible to this user) that use this competency. * + * @param int $competencyid Competency id. * @return array */ public static function list_templates_using_competency($competencyid) { @@ -2822,6 +2865,7 @@ class external extends external_api { /** * List the competencies (visible to this user) in this learning plan template. * + * @param int $templateid Template id. * @return array */ public static function list_competencies_in_template($templateid) { @@ -2883,6 +2927,8 @@ class external extends external_api { /** * Count the competencies (visible to this user) in this template. * + * @param int $templateid Template id. + * @param int $competencyid Competency id. * @return int */ public static function add_competency_to_template($templateid, $competencyid) { @@ -2939,6 +2985,8 @@ class external extends external_api { /** * Count the competencies (visible to this user) in this learning plan template. * + * @param int $templateid Template id. + * @param int $competencyid Competency id. * @return int */ public static function remove_competency_from_template($templateid, $competencyid) { @@ -2986,6 +3034,7 @@ class external extends external_api { /** * Loads the data required to render the template_competencies_page template. * + * @param int $templateid Template id. * @return boolean */ public static function data_for_template_competencies_page($templateid) { @@ -2995,7 +3044,7 @@ class external extends external_api { 'templateid' => $templateid, )); - $renderable = new \tool_lp\output\template_competencies_page($params['templateid']); + $renderable = new output\template_competencies_page($params['templateid']); $renderer = $PAGE->get_renderer('tool_lp'); $data = $renderable->export_for_template($renderer); @@ -3168,6 +3217,16 @@ class external extends external_api { /** * Create a new learning plan. + * + * @param string $name Name. + * @param string $description Plan description. + * @param string $descriptionformat Plan description format. + * @param int $userid User id. + * @param int $templateid Related template id. + * @param int $status status. + * @param int $duedate due date. + * + * @return mixed */ public static function create_plan($name, $description, $descriptionformat, $userid, $templateid, $status, $duedate) { $params = self::validate_parameters(self::create_plan_parameters(), @@ -3269,6 +3328,17 @@ class external extends external_api { /** * Updates a new learning plan. + * + * @param int $id Plan id. + * @param string $name Name. + * @param string $description Plan description. + * @param string $descriptionformat Plan description format. + * @param int $userid User id. + * @param int $templateid Related template id. + * @param int $status status. + * @param int $duedate due date. + * + * @return mixed */ public static function update_plan($id, $name, $description, $descriptionformat, $userid, $templateid, $status, $duedate) { $params = self::validate_parameters(self::update_plan_parameters(), @@ -3323,7 +3393,7 @@ class external extends external_api { * Read a plan by id. * * @param int $id The id of the plan. - * @return stdClass + * @return \stdClass */ public static function read_plan($id) { $params = self::validate_parameters(self::read_plan_parameters(), @@ -3419,6 +3489,7 @@ class external extends external_api { /** * Loads the data required to render the plans_page template. * + * @param int $userid User id. * @return boolean */ public static function data_for_plans_page($userid) { @@ -3508,7 +3579,7 @@ class external extends external_api { /** * Returns description of get_scale_values() result value. * - * @return external_description + * @return external_multiple_structure */ public static function get_scale_values_returns() { return new external_multiple_structure( diff --git a/admin/tool/lp/classes/form/competency.php b/admin/tool/lp/classes/form/competency.php index 3f7224b8da0..667de8326fe 100644 --- a/admin/tool/lp/classes/form/competency.php +++ b/admin/tool/lp/classes/form/competency.php @@ -81,7 +81,7 @@ class competency extends moodleform { $mform->setType('shortname', PARAM_TEXT); $mform->addRule('shortname', null, 'required', null, 'client'); $mform->addElement('editor', 'description', - get_string('description', 'tool_lp'), array('rows'=>4)); + get_string('description', 'tool_lp'), array('rows' => 4)); $mform->setType('description', PARAM_TEXT); $mform->addElement('text', 'idnumber', get_string('idnumber', 'tool_lp')); @@ -98,7 +98,7 @@ class competency extends moodleform { $competency = api::read_competency($id); $record = $competency->to_record(); // Massage for editor API. - $record->description = array('text'=>$record->description, 'format'=>$record->descriptionformat); + $record->description = array('text' => $record->description, 'format' => $record->descriptionformat); $this->set_data($record); } } diff --git a/admin/tool/lp/classes/form/competency_framework.php b/admin/tool/lp/classes/form/competency_framework.php index 9cb34080908..d95fa4bf99b 100644 --- a/admin/tool/lp/classes/form/competency_framework.php +++ b/admin/tool/lp/classes/form/competency_framework.php @@ -58,7 +58,7 @@ class competency_framework extends moodleform { $mform->setType('shortname', PARAM_TEXT); $mform->addRule('shortname', null, 'required', null, 'client'); $mform->addElement('editor', 'description', - get_string('description', 'tool_lp'), array('rows'=>4)); + get_string('description', 'tool_lp'), array('rows' => 4)); $mform->setType('description', PARAM_TEXT); $mform->addElement('text', 'idnumber', get_string('idnumber', 'tool_lp')); @@ -87,7 +87,7 @@ class competency_framework extends moodleform { $framework = api::read_framework($id); $record = $framework->to_record(); // Massage for editor API. - $record->description = array('text'=>$record->description, 'format'=>$record->descriptionformat); + $record->description = array('text' => $record->description, 'format' => $record->descriptionformat); $this->set_data($record); } } diff --git a/admin/tool/lp/classes/form/template.php b/admin/tool/lp/classes/form/template.php index dd951523868..490e0849378 100644 --- a/admin/tool/lp/classes/form/template.php +++ b/admin/tool/lp/classes/form/template.php @@ -56,7 +56,7 @@ class template extends moodleform { $mform->setType('shortname', PARAM_TEXT); $mform->addRule('shortname', null, 'required', null, 'client'); $mform->addElement('editor', 'description', - get_string('description', 'tool_lp'), array('rows'=>4)); + get_string('description', 'tool_lp'), array('rows' => 4)); $mform->setType('description', PARAM_TEXT); $mform->addElement('text', 'idnumber', get_string('idnumber', 'tool_lp')); @@ -66,7 +66,7 @@ class template extends moodleform { $mform->addElement('date_time_selector', 'duedate', get_string('duedate', 'tool_lp'), - array('optional'=>true)); + array('optional' => true)); $mform->addHelpButton('duedate', 'duedate', 'tool_lp'); $mform->setDefault('visible', true); @@ -79,7 +79,7 @@ class template extends moodleform { $template = api::read_template($id); $record = $template->to_record(); // Massage for editor API. - $record->description = array('text'=>$record->description, 'format'=>$record->descriptionformat); + $record->description = array('text' => $record->description, 'format' => $record->descriptionformat); $this->set_data($record); } } diff --git a/admin/tool/lp/classes/output/course_competencies_page.php b/admin/tool/lp/classes/output/course_competencies_page.php index 0532eac62e4..56cbe67e739 100644 --- a/admin/tool/lp/classes/output/course_competencies_page.php +++ b/admin/tool/lp/classes/output/course_competencies_page.php @@ -40,12 +40,24 @@ use tool_lp\api; */ class course_competencies_page implements renderable, templatable { - /** @var stdClass $course Course record for this page. */ - var $course = null; + /** @var int $courseid Course id for this page. */ + protected $courseid = null; + + /** @var \tool_lp\competency[] $competencies List of competencies. */ + protected $competencies = array(); + + /** @var bool $canmanagecompetencyframeworks Can the current user manage competency frameworks. */ + protected $canmanagecompetencyframeworks = false; + + /** @var bool $canmanagecoursecompetencies Can the current user manage course competency frameworks.. */ + protected $canmanagecoursecompetencies = false; + + /** @var string $manageurl manage url. */ + protected $manageurl = null; /** * Construct this renderable. - * @param stdClass $course The course record for this page. + * @param int $courseid The course record for this page. */ public function __construct($courseid) { $context = context_course::instance($courseid); @@ -59,6 +71,7 @@ class course_competencies_page implements renderable, templatable { /** * Export this data so it can be used as the context for a mustache template. * + * @param renderer_base $output Renderer base. * @return stdClass */ public function export_for_template(renderer_base $output) { diff --git a/admin/tool/lp/classes/output/manage_competencies_page.php b/admin/tool/lp/classes/output/manage_competencies_page.php index 7408d09a3c5..2d1a85963e9 100644 --- a/admin/tool/lp/classes/output/manage_competencies_page.php +++ b/admin/tool/lp/classes/output/manage_competencies_page.php @@ -41,23 +41,25 @@ use tool_lp\api; class manage_competencies_page implements renderable, templatable { /** @var \tool_lp\competency_framework $framework This competency framework. */ - var $framework = null; + protected $framework = null; - /** @var array $competencies List of competencies. */ - var $competencies = array(); + /** @var \tool_lp\competency[] $competencies List of competencies. */ + protected $competencies = array(); /** @var string $search Text to search for. */ - var $search = ''; + protected $search = ''; /** @var bool $canmanage Result of permissions checks. */ - var $canmanage = false; + protected $canmanage = false; /** @var moodle_url $pluginurlbase Base url to use constructing links. */ - var $pluginbaseurl = null; + protected $pluginbaseurl = null; /** * Construct this renderable. - * @param \tool_lp\competency_framework $framework + * + * @param \tool_lp\competency_framework $framework Competency framework. + * @param string $search Search string. */ public function __construct($framework, $search) { $this->framework = $framework; @@ -96,6 +98,7 @@ class manage_competencies_page implements renderable, templatable { /** * Export this data so it can be used as the context for a mustache template. * + * @param renderer_base $output Renderer base. * @return stdClass */ public function export_for_template(renderer_base $output) { diff --git a/admin/tool/lp/classes/output/manage_competency_frameworks_page.php b/admin/tool/lp/classes/output/manage_competency_frameworks_page.php index f74eb7b1061..15897ca4ced 100644 --- a/admin/tool/lp/classes/output/manage_competency_frameworks_page.php +++ b/admin/tool/lp/classes/output/manage_competency_frameworks_page.php @@ -41,16 +41,16 @@ use tool_lp\api; class manage_competency_frameworks_page implements renderable, templatable { /** @var array $navigation List of links to display on the page. Each link contains a url and a title. */ - var $navigation = array(); + protected $navigation = array(); /** @var array $competencyframeworks List of competency frameworks. */ - var $competencyframeworks = array(); + protected $competencyframeworks = array(); /** @var bool $canmanage Result of permissions checks. */ - var $canmanage = false; + protected $canmanage = false; /** @var moodle_url $pluginurlbase Base url to use constructing links. */ - var $pluginbaseurl = null; + protected $pluginbaseurl = null; /** * Construct this renderable. @@ -71,6 +71,7 @@ class manage_competency_frameworks_page implements renderable, templatable { /** * Export this data so it can be used as the context for a mustache template. * + * @param renderer_base $output Renderer base. * @return stdClass */ public function export_for_template(renderer_base $output) { diff --git a/admin/tool/lp/classes/output/manage_templates_page.php b/admin/tool/lp/classes/output/manage_templates_page.php index 4f5e39c0c1f..83e3eaaa05e 100644 --- a/admin/tool/lp/classes/output/manage_templates_page.php +++ b/admin/tool/lp/classes/output/manage_templates_page.php @@ -41,13 +41,13 @@ use tool_lp\api; class manage_templates_page implements renderable, templatable { /** @var array $navigation List of links to display on the page. Each link contains a url and a title. */ - var $navigation = array(); + protected $navigation = array(); /** @var array $templates List of learning plan templates. */ - var $templates = array(); + protected $templates = array(); /** @var bool $canmanage Result of permissions checks. */ - var $canmanage = false; + protected $canmanage = false; /** * Construct this renderable. @@ -68,6 +68,7 @@ class manage_templates_page implements renderable, templatable { /** * Export this data so it can be used as the context for a mustache template. * + * @param renderer_base $output Renderer base. * @return stdClass */ public function export_for_template(renderer_base $output) { diff --git a/admin/tool/lp/classes/output/plans_page.php b/admin/tool/lp/classes/output/plans_page.php index afe0a3c2836..01892865bf5 100644 --- a/admin/tool/lp/classes/output/plans_page.php +++ b/admin/tool/lp/classes/output/plans_page.php @@ -42,13 +42,16 @@ use context_user; class plans_page implements renderable, templatable { /** @var array $navigation List of links to display on the page. Each link contains a url and a title. */ - var $navigation = array(); + protected $navigation = array(); - var $plans = array(); + /** @var array|\tool_lp\plan[] $plans List of plans. */ + protected $plans = array(); - var $context = null; + /** @var context_user|null $context context. */ + protected $context = null; - var $userid = null; + /** @var int|null $userid Userid. */ + protected $userid = null; /** * Construct this renderable. @@ -75,8 +78,6 @@ class plans_page implements renderable, templatable { * @return stdClass */ public function export_for_template(renderer_base $output) { - global $USER; - $data = new stdClass(); $data->userid = $this->userid; $data->pluginbaseurl = (new moodle_url('/admin/tool/lp'))->out(true); diff --git a/admin/tool/lp/classes/output/renderer.php b/admin/tool/lp/classes/output/renderer.php index 318acb3e4bd..debac3f79ac 100644 --- a/admin/tool/lp/classes/output/renderer.php +++ b/admin/tool/lp/classes/output/renderer.php @@ -45,7 +45,7 @@ class renderer extends plugin_renderer_base { * * @return string html for the page */ - public function render_manage_competency_frameworks_page($page) { + public function render_manage_competency_frameworks_page(manage_competency_frameworks_page $page) { $data = $page->export_for_template($this); return parent::render_from_template('tool_lp/manage_competency_frameworks_page', $data); } @@ -57,7 +57,7 @@ class renderer extends plugin_renderer_base { * * @return string html for the page */ - public function render_manage_competencies_page($page) { + public function render_manage_competencies_page(manage_competencies_page $page) { $data = $page->export_for_template($this); return parent::render_from_template('tool_lp/manage_competencies_page', $data); } @@ -69,7 +69,7 @@ class renderer extends plugin_renderer_base { * * @return string html for the page */ - public function render_course_competencies_page($page) { + public function render_course_competencies_page(course_competencies_page $page) { $data = $page->export_for_template($this); return parent::render_from_template('tool_lp/course_competencies_page', $data); } @@ -81,7 +81,7 @@ class renderer extends plugin_renderer_base { * * @return string html for the page */ - public function render_template_competencies_page($page) { + public function render_template_competencies_page(template_competencies_page $page) { $data = $page->export_for_template($this); return parent::render_from_template('tool_lp/template_competencies_page', $data); } @@ -93,12 +93,18 @@ class renderer extends plugin_renderer_base { * * @return string html for the page */ - public function render_manage_templates_page($page) { + public function render_manage_templates_page(manage_templates_page $page) { $data = $page->export_for_template($this); return parent::render_from_template('tool_lp/manage_templates_page', $data); } - public function render_plans_page(renderable $page) { + /** + * Defer to template. + * @param plans_page $page + * + * @return bool|string + */ + public function render_plans_page(plans_page $page) { $data = $page->export_for_template($this); return parent::render_from_template('tool_lp/plans_page', $data); } diff --git a/admin/tool/lp/classes/output/template_competencies_page.php b/admin/tool/lp/classes/output/template_competencies_page.php index 65d453bea9c..e195a8fac89 100644 --- a/admin/tool/lp/classes/output/template_competencies_page.php +++ b/admin/tool/lp/classes/output/template_competencies_page.php @@ -39,8 +39,24 @@ use tool_lp\api; */ class template_competencies_page implements renderable, templatable { + /** @var int $templateid Template id for this page. */ + protected $templateid = null; + + /** @var \tool_lp\competency[] $competencies List of competencies. */ + protected $competencies = array(); + + /** @var bool $canmanagecompetencyframeworks Can the current user manage competency frameworks. */ + protected $canmanagecompetencyframeworks = false; + + /** @var bool $canmanagecoursecompetencies Can the current user manage course competency frameworks.. */ + protected $canmanagecoursecompetencies = false; + + /** @var string $manageurl manage url. */ + protected $manageurl = null; + /** * Construct this renderable. + * * @param int $templateid The learning plan template id for this page. */ public function __construct($templateid) { diff --git a/admin/tool/lp/classes/persistent.php b/admin/tool/lp/classes/persistent.php index 75d88647242..cf9da6315e8 100644 --- a/admin/tool/lp/classes/persistent.php +++ b/admin/tool/lp/classes/persistent.php @@ -56,7 +56,7 @@ abstract class persistent { /** * Create an instance of this class. * @param int $id If set, this is the id of an existing record, used to load the data. - * @param stdClass $record If set, the data for this class will be taken from the record. + * @param \stdClass $record If set, the data for this class will be taken from the record. */ public function __construct($id = 0, $record = null) { if ($id > 0) { @@ -143,7 +143,7 @@ abstract class persistent { /** * Populate this class with data from a DB record. * - * @param stdClass $record A DB record. + * @param \stdClass $record A DB record. * @return persistent */ abstract public function from_record($record); @@ -151,20 +151,20 @@ abstract class persistent { /** * Create a DB record from this class. * - * @return stdClass + * @return \stdClass */ abstract public function to_record(); /** * Reload the data for this class from the DB. * - * @return framework + * @return persistent */ public function read() { global $DB; if ($this->id <= 0) { - throw new coding_exception('id is required to load'); + throw new \coding_exception('id is required to load'); } $record = $DB->get_record($this->get_table_name(), array('id' => $this->id), '*', MUST_EXIST); return $this->from_record($record); @@ -188,8 +188,6 @@ abstract class persistent { return $this; } - - /** * Update the existing record in the DB. * @@ -199,7 +197,7 @@ abstract class persistent { global $DB, $USER; if ($this->id <= 0) { - throw new coding_exception('id is required to update'); + throw new \coding_exception('id is required to update'); } $record = $this->to_record(); unset($record->timecreated); @@ -218,7 +216,7 @@ abstract class persistent { global $DB; if ($this->id <= 0) { - throw new coding_exception('id is required to delete'); + throw new \coding_exception('id is required to delete'); } return $DB->delete_records($this->get_table_name(), array('id' => $this->id)); } @@ -226,7 +224,13 @@ abstract class persistent { /** * Load a list of records. * - * @return \tool_lp\plan[] + * @param array $filters Filters to apply. + * @param string $sort Field to sort by. + * @param string $order Sort order. + * @param int $skip Limitstart. + * @param int $limit Number of rows to return. + * + * @return persistent[] */ public function get_records($filters = array(), $sort = '', $order = 'ASC', $skip = 0, $limit = 0) { global $DB; @@ -277,6 +281,7 @@ abstract class persistent { /** * Count a list of records. * + * @param array $filters Filters to apply. * @return int */ public function count_records($filters = array()) { diff --git a/admin/tool/lp/classes/plan.php b/admin/tool/lp/classes/plan.php index dd0b235d530..2c5fb476bb1 100644 --- a/admin/tool/lp/classes/plan.php +++ b/admin/tool/lp/classes/plan.php @@ -34,8 +34,13 @@ use context_user; */ class plan extends persistent { + /** Draft status */ const STATUS_DRAFT = 0; + + /** Active status */ const STATUS_ACTIVE = 1; + + /** Complete status */ const STATUS_COMPLETE = 2; /** @var string $name Name */ @@ -68,46 +73,106 @@ class plan extends persistent { return 'tool_lp_plan'; } + /** + * Getter method. + * + * @return string + */ public function get_name() { return $this->name; } + /** + * Setter method. + * + * @param string $value value of the field. + * @return string + */ public function set_name($value) { $this->name = $value; } + /** + * Getter method. + * + * @return string + */ public function get_description() { return $this->description; } + /** + * Setter method. + * + * @param string $value value of the field. + * @return string + */ public function set_description($value) { $this->description = $value; } + /** + * Getter method. + * + * @return string + */ public function get_descriptionformat() { return $this->descriptionformat; } + /** + * Setter method. + * + * @param int $value value of the field. + * @return string + */ public function set_descriptionformat($value) { $this->descriptionformat = $value; } + /** + * Getter method. + * + * @return string + */ public function get_userid() { return $this->userid; } + /** + * Setter method. + * + * @param int $value value of the field. + * @return string + */ public function set_userid($value) { $this->userid = $value; } + /** + * Getter method. + * + * @return string + */ public function get_templateid() { return $this->templateid; } + /** + * Setter method. + * + * @param int $value value of the field. + * @return string + */ public function set_templateid($value) { $this->templateid = $value; } + /** + * Getter method. + * + * @return string + */ public function get_status() { if ($this->status === null) { return null; @@ -116,25 +181,40 @@ class plan extends persistent { return (int)$this->status; } + /** + * Setter method. + * + * @param string $value value of the field. + * @return string + */ public function set_status($value) { $this->status = $value; } + /** + * Getter method. + * + * @return string + */ public function get_duedate() { return $this->duedate; } + /** + * Setter method. + * + * @param string $value value of the field. + * @return string + */ public function set_duedate($value) { $this->duedate = $value; } // Extra methods. - - /** * Human readable status name. * - * @return void + * @return string */ public function get_statusname() { @@ -151,7 +231,7 @@ class plan extends persistent { $strname = 'complete'; break; default: - throw moodle_exception('errorplanstatus', 'tool_lp', '', $status); + throw new \moodle_exception('errorplanstatus', 'tool_lp', '', $status); break; } @@ -161,7 +241,7 @@ class plan extends persistent { /** * Whether the current user can update the learning plan. * - * @return void + * @return bool */ public function get_usercanupdate() { global $USER; @@ -182,7 +262,7 @@ class plan extends persistent { // The user that created the template can also edit it if he was the last one that modified it. But // can't do it if it is already completed. - if ($USER->id == $userid && $this->get_usermodified() == $USER->id && $this->get_status() != plan::STATUS_COMPLETE) { + if ($USER->id == $userid && $this->get_usermodified() == $USER->id && $this->get_status() != self::STATUS_COMPLETE) { return true; } @@ -195,7 +275,7 @@ class plan extends persistent { * If it is used to insert/update into DB the extra fields like statusname will be * ignored, they are useful though when passing the object to templates. * - * @return void + * @return \stdClass */ public function to_record() { @@ -219,6 +299,12 @@ class plan extends persistent { return $record; } + /** + * Get plan object from record. + * + * @param stdClass $record + * @return plan + */ public function from_record($record) { if (isset($record->id)) { $this->set_id($record->id); diff --git a/admin/tool/lp/classes/template.php b/admin/tool/lp/classes/template.php index 200f1170ea0..0046a964b22 100644 --- a/admin/tool/lp/classes/template.php +++ b/admin/tool/lp/classes/template.php @@ -171,7 +171,6 @@ class template extends persistent { $this->duedate = $duedate; } - /** * Get the visible flag. * @@ -270,5 +269,4 @@ class template extends persistent { return parent::create(); } - } diff --git a/admin/tool/lp/db/access.php b/admin/tool/lp/db/access.php index 31328e39b89..2b3d4409617 100644 --- a/admin/tool/lp/db/access.php +++ b/admin/tool/lp/db/access.php @@ -28,79 +28,20 @@ defined('MOODLE_INTERNAL') || die(); $capabilities = array( + 'tool/lp:competencymanage' => array( + 'captype' => 'write', + 'contextlevel' => CONTEXT_SYSTEM, + 'archetypes' => array( + ), + 'clonepermissionsfrom' => 'moodle/site:config' + ), 'tool/lp:competencyread' => array( 'captype' => 'read', 'contextlevel' => CONTEXT_SYSTEM, 'archetypes' => array( 'user' => CAP_ALLOW ), - 'clonepermissionsfrom' => 'moodle/block:view' - ), - 'tool/lp:competencymanage' => array( - 'captype' => 'write', - 'contextlevel' => CONTEXT_SYSTEM, - 'archetypes' => array( - ), - 'clonepermissionsfrom' => 'moodle/site:config' - ), - 'tool/lp:templateread' => array( - 'captype' => 'read', - 'contextlevel' => CONTEXT_SYSTEM, - 'archetypes' => array( - 'user' => CAP_ALLOW - ), - 'clonepermissionsfrom' => 'moodle/block:view' - ), - 'tool/lp:templatemanage' => array( - 'captype' => 'write', - 'contextlevel' => CONTEXT_SYSTEM, - 'archetypes' => array( - ), - 'clonepermissionsfrom' => 'moodle/site:config' - ), - 'tool/lp:plancreatedraft' => array( - 'captype' => 'write', - 'contextlevel' => CONTEXT_SYSTEM, - 'archetypes' => array( - ), - 'clonepermissionsfrom' => 'moodle/site:config' - ), - 'tool/lp:planmanageall' => array( - 'captype' => 'write', - 'contextlevel' => CONTEXT_SYSTEM, - 'archetypes' => array( - ), - 'clonepermissionsfrom' => 'moodle/site:config' - ), - 'tool/lp:planmanageown' => array( - 'captype' => 'write', - 'contextlevel' => CONTEXT_USER, - 'archetypes' => array( - ), - 'clonepermissionsfrom' => 'moodle/site:config' - ), - 'tool/lp:planviewall' => array( - 'captype' => 'read', - 'contextlevel' => CONTEXT_USER, - 'archetypes' => array( - ), - 'clonepermissionsfrom' => 'moodle/site:config' - ), - 'tool/lp:planviewown' => array( - 'captype' => 'read', - 'contextlevel' => CONTEXT_USER, - 'archetypes' => array( - 'user' => CAP_ALLOW - ), - 'clonepermissionsfrom' => 'moodle/block:view' - ), - 'tool/lp:coursecompetencyread' => array( - 'captype' => 'read', - 'contextlevel' => CONTEXT_COURSE, - 'archetypes' => array( - 'user' => CAP_ALLOW - ), - 'clonepermissionsfrom' => 'moodle/block:view' + 'clonepermissionsfrom' => 'moodle/block:view' ), 'tool/lp:coursecompetencymanage' => array( 'captype' => 'write', @@ -109,6 +50,65 @@ $capabilities = array( 'editingteacher' => CAP_ALLOW, 'manager' => CAP_ALLOW ), - 'clonepermissionsfrom' => 'moodle/site:backup' - ) + 'clonepermissionsfrom' => 'moodle/site:backup' + ), + 'tool/lp:coursecompetencyread' => array( + 'captype' => 'read', + 'contextlevel' => CONTEXT_COURSE, + 'archetypes' => array( + 'user' => CAP_ALLOW + ), + 'clonepermissionsfrom' => 'moodle/block:view' + ), + 'tool/lp:plancreatedraft' => array( + 'captype' => 'write', + 'contextlevel' => CONTEXT_SYSTEM, + 'archetypes' => array( + ), + 'clonepermissionsfrom' => 'moodle/site:config' + ), + 'tool/lp:planmanageall' => array( + 'captype' => 'write', + 'contextlevel' => CONTEXT_SYSTEM, + 'archetypes' => array( + ), + 'clonepermissionsfrom' => 'moodle/site:config' + ), + 'tool/lp:planmanageown' => array( + 'captype' => 'write', + 'contextlevel' => CONTEXT_USER, + 'archetypes' => array( + ), + 'clonepermissionsfrom' => 'moodle/site:config' + ), + 'tool/lp:planviewall' => array( + 'captype' => 'read', + 'contextlevel' => CONTEXT_USER, + 'archetypes' => array( + ), + 'clonepermissionsfrom' => 'moodle/site:config' + ), + 'tool/lp:planviewown' => array( + 'captype' => 'read', + 'contextlevel' => CONTEXT_USER, + 'archetypes' => array( + 'user' => CAP_ALLOW + ), + 'clonepermissionsfrom' => 'moodle/block:view' + ), + 'tool/lp:templatemanage' => array( + 'captype' => 'write', + 'contextlevel' => CONTEXT_SYSTEM, + 'archetypes' => array( + ), + 'clonepermissionsfrom' => 'moodle/site:config' + ), + 'tool/lp:templateread' => array( + 'captype' => 'read', + 'contextlevel' => CONTEXT_SYSTEM, + 'archetypes' => array( + 'user' => CAP_ALLOW + ), + 'clonepermissionsfrom' => 'moodle/block:view' + ), ); diff --git a/admin/tool/lp/db/services.php b/admin/tool/lp/db/services.php index d5a5441972c..3f7aa42ad4f 100644 --- a/admin/tool/lp/db/services.php +++ b/admin/tool/lp/db/services.php @@ -29,364 +29,364 @@ $functions = array( // Learning plan related functions. 'tool_lp_create_competency_framework' => array( - 'classname' => 'tool_lp\external', - 'methodname' => 'create_competency_framework', - 'classpath' => '', - 'description' => 'Creates new competency frameworks.', - 'type' => 'write', - 'capabilities'=> 'tool/lp:competencymanage', + 'classname' => 'tool_lp\external', + 'methodname' => 'create_competency_framework', + 'classpath' => '', + 'description' => 'Creates new competency frameworks.', + 'type' => 'write', + 'capabilities' => 'tool/lp:competencymanage', ), 'tool_lp_read_competency_framework' => array( - 'classname' => 'tool_lp\external', - 'methodname' => 'read_competency_framework', - 'classpath' => '', - 'description' => 'Load a summary of a competency framework.', - 'type' => 'read', - 'capabilities'=> 'tool/lp:competencyview', + 'classname' => 'tool_lp\external', + 'methodname' => 'read_competency_framework', + 'classpath' => '', + 'description' => 'Load a summary of a competency framework.', + 'type' => 'read', + 'capabilities' => 'tool/lp:competencyview', ), 'tool_lp_delete_competency_framework' => array( - 'classname' => 'tool_lp\external', - 'methodname' => 'delete_competency_framework', - 'classpath' => '', - 'description' => 'Delete a competency framework.', - 'type' => 'write', - 'capabilities'=> 'tool/lp:competencymanage', + 'classname' => 'tool_lp\external', + 'methodname' => 'delete_competency_framework', + 'classpath' => '', + 'description' => 'Delete a competency framework.', + 'type' => 'write', + 'capabilities' => 'tool/lp:competencymanage', ), 'tool_lp_update_competency_framework' => array( - 'classname' => 'tool_lp\external', - 'methodname' => 'update_competency_framework', - 'classpath' => '', - 'description' => 'Update a competency framework.', - 'type' => 'write', - 'capabilities'=> 'tool/lp:competencymanage', + 'classname' => 'tool_lp\external', + 'methodname' => 'update_competency_framework', + 'classpath' => '', + 'description' => 'Update a competency framework.', + 'type' => 'write', + 'capabilities' => 'tool/lp:competencymanage', ), 'tool_lp_list_competency_frameworks' => array( - 'classname' => 'tool_lp\external', - 'methodname' => 'list_competency_frameworks', - 'classpath' => '', - 'description' => 'Load a list of a competency frameworks.', - 'type' => 'read', - 'capabilities'=> 'tool/lp:competencyview', + 'classname' => 'tool_lp\external', + 'methodname' => 'list_competency_frameworks', + 'classpath' => '', + 'description' => 'Load a list of a competency frameworks.', + 'type' => 'read', + 'capabilities' => 'tool/lp:competencyview', ), 'tool_lp_count_competency_frameworks' => array( - 'classname' => 'tool_lp\external', - 'methodname' => 'count_competency_frameworks', - 'classpath' => '', - 'description' => 'Count a list of a competency frameworks.', - 'type' => 'read', - 'capabilities'=> 'tool/lp:competencyview', + 'classname' => 'tool_lp\external', + 'methodname' => 'count_competency_frameworks', + 'classpath' => '', + 'description' => 'Count a list of a competency frameworks.', + 'type' => 'read', + 'capabilities' => 'tool/lp:competencyview', ), 'tool_lp_data_for_competency_frameworks_manage_page' => array( - 'classname' => 'tool_lp\external', - 'methodname' => 'data_for_competency_frameworks_manage_page', - 'classpath' => '', - 'description' => 'Load the data for the competency frameworks manage page template', - 'type' => 'read', - 'capabilities'=> 'tool/lp:competencyview', + 'classname' => 'tool_lp\external', + 'methodname' => 'data_for_competency_frameworks_manage_page', + 'classpath' => '', + 'description' => 'Load the data for the competency frameworks manage page template', + 'type' => 'read', + 'capabilities' => 'tool/lp:competencyview', ), 'tool_lp_reorder_competency_framework' => array( - 'classname' => 'tool_lp\external', - 'methodname' => 'reorder_competency_framework', - 'classpath' => '', - 'description' => 'Move a competency framework to a new relative sort order.', - 'type' => 'write', - 'capabilities'=> 'tool/lp:competencymanage', + 'classname' => 'tool_lp\external', + 'methodname' => 'reorder_competency_framework', + 'classpath' => '', + 'description' => 'Move a competency framework to a new relative sort order.', + 'type' => 'write', + 'capabilities' => 'tool/lp:competencymanage', ), 'tool_lp_create_competency' => array( - 'classname' => 'tool_lp\external', - 'methodname' => 'create_competency', - 'classpath' => '', - 'description' => 'Creates new competencies.', - 'type' => 'write', - 'capabilities'=> 'tool/lp:competencymanage', + 'classname' => 'tool_lp\external', + 'methodname' => 'create_competency', + 'classpath' => '', + 'description' => 'Creates new competencies.', + 'type' => 'write', + 'capabilities' => 'tool/lp:competencymanage', ), 'tool_lp_read_competency' => array( - 'classname' => 'tool_lp\external', - 'methodname' => 'read_competency', - 'classpath' => '', - 'description' => 'Load a summary of a competency.', - 'type' => 'read', - 'capabilities'=> 'tool/lp:competencyview', + 'classname' => 'tool_lp\external', + 'methodname' => 'read_competency', + 'classpath' => '', + 'description' => 'Load a summary of a competency.', + 'type' => 'read', + 'capabilities' => 'tool/lp:competencyview', ), 'tool_lp_delete_competency' => array( - 'classname' => 'tool_lp\external', - 'methodname' => 'delete_competency', - 'classpath' => '', - 'description' => 'Delete a competency.', - 'type' => 'write', - 'capabilities'=> 'tool/lp:competencymanage', + 'classname' => 'tool_lp\external', + 'methodname' => 'delete_competency', + 'classpath' => '', + 'description' => 'Delete a competency.', + 'type' => 'write', + 'capabilities' => 'tool/lp:competencymanage', ), 'tool_lp_update_competency' => array( - 'classname' => 'tool_lp\external', - 'methodname' => 'update_competency', - 'classpath' => '', - 'description' => 'Update a competency.', - 'type' => 'write', - 'capabilities'=> 'tool/lp:competencymanage', + 'classname' => 'tool_lp\external', + 'methodname' => 'update_competency', + 'classpath' => '', + 'description' => 'Update a competency.', + 'type' => 'write', + 'capabilities' => 'tool/lp:competencymanage', ), 'tool_lp_list_competencies' => array( - 'classname' => 'tool_lp\external', - 'methodname' => 'list_competencies', - 'classpath' => '', - 'description' => 'Load a list of a competencies.', - 'type' => 'read', - 'capabilities'=> 'tool/lp:competencyview', + 'classname' => 'tool_lp\external', + 'methodname' => 'list_competencies', + 'classpath' => '', + 'description' => 'Load a list of a competencies.', + 'type' => 'read', + 'capabilities' => 'tool/lp:competencyview', ), 'tool_lp_count_competencies' => array( - 'classname' => 'tool_lp\external', - 'methodname' => 'count_competencies', - 'classpath' => '', - 'description' => 'Count a list of a competencies.', - 'type' => 'read', - 'capabilities'=> 'tool/lp:competencyview', + 'classname' => 'tool_lp\external', + 'methodname' => 'count_competencies', + 'classpath' => '', + 'description' => 'Count a list of a competencies.', + 'type' => 'read', + 'capabilities' => 'tool/lp:competencyview', ), 'tool_lp_search_competencies' => array( - 'classname' => 'tool_lp\external', - 'methodname' => 'search_competencies', - 'classpath' => '', - 'description' => 'Search a list of a competencies.', - 'type' => 'read', - 'capabilities'=> 'tool/lp:competencyview', + 'classname' => 'tool_lp\external', + 'methodname' => 'search_competencies', + 'classpath' => '', + 'description' => 'Search a list of a competencies.', + 'type' => 'read', + 'capabilities' => 'tool/lp:competencyview', ), 'tool_lp_data_for_competencies_manage_page' => array( - 'classname' => 'tool_lp\external', - 'methodname' => 'data_for_competencies_manage_page', - 'classpath' => '', - 'description' => 'Load the data for the competencies manage page template', - 'type' => 'read', - 'capabilities'=> 'tool/lp:competencyview', + 'classname' => 'tool_lp\external', + 'methodname' => 'data_for_competencies_manage_page', + 'classpath' => '', + 'description' => 'Load the data for the competencies manage page template', + 'type' => 'read', + 'capabilities' => 'tool/lp:competencyview', ), 'tool_lp_set_parent_competency' => array( - 'classname' => 'tool_lp\external', - 'methodname' => 'set_parent_competency', - 'classpath' => '', - 'description' => 'Set a new parent for a competency.', - 'type' => 'write', - 'capabilities'=> 'tool/lp:competencymanage', + 'classname' => 'tool_lp\external', + 'methodname' => 'set_parent_competency', + 'classpath' => '', + 'description' => 'Set a new parent for a competency.', + 'type' => 'write', + 'capabilities' => 'tool/lp:competencymanage', ), 'tool_lp_move_up_competency' => array( - 'classname' => 'tool_lp\external', - 'methodname' => 'move_up_competency', - 'classpath' => '', - 'description' => 'Re-order a competency.', - 'type' => 'write', - 'capabilities'=> 'tool/lp:competencymanage', + 'classname' => 'tool_lp\external', + 'methodname' => 'move_up_competency', + 'classpath' => '', + 'description' => 'Re-order a competency.', + 'type' => 'write', + 'capabilities' => 'tool/lp:competencymanage', ), 'tool_lp_move_down_competency' => array( - 'classname' => 'tool_lp\external', - 'methodname' => 'move_down_competency', - 'classpath' => '', - 'description' => 'Re-order a competency.', - 'type' => 'write', - 'capabilities'=> 'tool/lp:competencymanage', + 'classname' => 'tool_lp\external', + 'methodname' => 'move_down_competency', + 'classpath' => '', + 'description' => 'Re-order a competency.', + 'type' => 'write', + 'capabilities' => 'tool/lp:competencymanage', ), 'tool_lp_list_competencies_in_course' => array( - 'classname' => 'tool_lp\external', - 'methodname' => 'list_competencies_in_course', - 'classpath' => '', - 'description' => 'List the competencies in a course', - 'type' => 'read', - 'capabilities'=> 'tool/lp:coursecompetencyread', + 'classname' => 'tool_lp\external', + 'methodname' => 'list_competencies_in_course', + 'classpath' => '', + 'description' => 'List the competencies in a course', + 'type' => 'read', + 'capabilities' => 'tool/lp:coursecompetencyread', ), 'tool_lp_list_courses_using_competency' => array( - 'classname' => 'tool_lp\external', - 'methodname' => 'list_courses_using_competency', - 'classpath' => '', - 'description' => 'List the courses using a competency', - 'type' => 'read', - 'capabilities'=> 'tool/lp:coursecompetencyread', + 'classname' => 'tool_lp\external', + 'methodname' => 'list_courses_using_competency', + 'classpath' => '', + 'description' => 'List the courses using a competency', + 'type' => 'read', + 'capabilities' => 'tool/lp:coursecompetencyread', ), 'tool_lp_count_competencies_in_course' => array( - 'classname' => 'tool_lp\external', - 'methodname' => 'count_competencies_in_course', - 'classpath' => '', - 'description' => 'List the competencies in a course', - 'type' => 'read', - 'capabilities'=> 'tool/lp:coursecompetencyread', + 'classname' => 'tool_lp\external', + 'methodname' => 'count_competencies_in_course', + 'classpath' => '', + 'description' => 'List the competencies in a course', + 'type' => 'read', + 'capabilities' => 'tool/lp:coursecompetencyread', ), 'tool_lp_count_courses_using_competency' => array( - 'classname' => 'tool_lp\external', - 'methodname' => 'count_courses_using_competency', - 'classpath' => '', - 'description' => 'List the courses using a competency', - 'type' => 'read', - 'capabilities'=> 'tool/lp:coursecompetencyread', + 'classname' => 'tool_lp\external', + 'methodname' => 'count_courses_using_competency', + 'classpath' => '', + 'description' => 'List the courses using a competency', + 'type' => 'read', + 'capabilities' => 'tool/lp:coursecompetencyread', ), 'tool_lp_add_competency_to_course' => array( - 'classname' => 'tool_lp\external', - 'methodname' => 'add_competency_to_course', - 'classpath' => '', - 'description' => 'Add the competency to a course', - 'type' => 'write', - 'capabilities'=> 'tool/lp:coursecompetencymanage', + 'classname' => 'tool_lp\external', + 'methodname' => 'add_competency_to_course', + 'classpath' => '', + 'description' => 'Add the competency to a course', + 'type' => 'write', + 'capabilities' => 'tool/lp:coursecompetencymanage', ), 'tool_lp_add_competency_to_template' => array( - 'classname' => 'tool_lp\external', - 'methodname' => 'add_competency_to_template', - 'classpath' => '', - 'description' => 'Add the competency to a template', - 'type' => 'write', - 'capabilities'=> 'tool/lp:templatemanage', + 'classname' => 'tool_lp\external', + 'methodname' => 'add_competency_to_template', + 'classpath' => '', + 'description' => 'Add the competency to a template', + 'type' => 'write', + 'capabilities' => 'tool/lp:templatemanage', ), 'tool_lp_remove_competency_from_course' => array( - 'classname' => 'tool_lp\external', - 'methodname' => 'remove_competency_from_course', - 'classpath' => '', - 'description' => 'Remove a competency from a course', - 'type' => 'write', - 'capabilities'=> 'tool/lp:coursecompetencymanage', + 'classname' => 'tool_lp\external', + 'methodname' => 'remove_competency_from_course', + 'classpath' => '', + 'description' => 'Remove a competency from a course', + 'type' => 'write', + 'capabilities' => 'tool/lp:coursecompetencymanage', ), 'tool_lp_remove_competency_from_template' => array( - 'classname' => 'tool_lp\external', - 'methodname' => 'remove_competency_from_template', - 'classpath' => '', - 'description' => 'Remove a competency from a template', - 'type' => 'write', - 'capabilities'=> 'tool/lp:templatemanage', + 'classname' => 'tool_lp\external', + 'methodname' => 'remove_competency_from_template', + 'classpath' => '', + 'description' => 'Remove a competency from a template', + 'type' => 'write', + 'capabilities' => 'tool/lp:templatemanage', ), 'tool_lp_data_for_course_competencies_page' => array( - 'classname' => 'tool_lp\external', - 'methodname' => 'data_for_course_competencies_page', - 'classpath' => '', - 'description' => 'Load the data for the course competencies page template.', - 'type' => 'read', - 'capabilities'=> 'tool/lp:coursecompetencyread', + 'classname' => 'tool_lp\external', + 'methodname' => 'data_for_course_competencies_page', + 'classpath' => '', + 'description' => 'Load the data for the course competencies page template.', + 'type' => 'read', + 'capabilities' => 'tool/lp:coursecompetencyread', ), 'tool_lp_data_for_template_competencies_page' => array( - 'classname' => 'tool_lp\external', - 'methodname' => 'data_for_template_competencies_page', - 'classpath' => '', - 'description' => 'Load the data for the template competencies page template.', - 'type' => 'read', - 'capabilities'=> 'tool/lp:templateread', + 'classname' => 'tool_lp\external', + 'methodname' => 'data_for_template_competencies_page', + 'classpath' => '', + 'description' => 'Load the data for the template competencies page template.', + 'type' => 'read', + 'capabilities' => 'tool/lp:templateread', ), 'tool_lp_reorder_course_competency' => array( - 'classname' => 'tool_lp\external', - 'methodname' => 'reorder_course_competency', - 'classpath' => '', - 'description' => 'Move a course competency to a new relative sort order.', - 'type' => 'write', - 'capabilities'=> 'tool/lp:coursecompetencymanage', + 'classname' => 'tool_lp\external', + 'methodname' => 'reorder_course_competency', + 'classpath' => '', + 'description' => 'Move a course competency to a new relative sort order.', + 'type' => 'write', + 'capabilities' => 'tool/lp:coursecompetencymanage', ), 'tool_lp_reorder_template_competency' => array( - 'classname' => 'tool_lp\external', - 'methodname' => 'reorder_template_competency', - 'classpath' => '', - 'description' => 'Move a template competency to a new relative sort order.', - 'type' => 'write', - 'capabilities'=> 'tool/lp:templatemanage', + 'classname' => 'tool_lp\external', + 'methodname' => 'reorder_template_competency', + 'classpath' => '', + 'description' => 'Move a template competency to a new relative sort order.', + 'type' => 'write', + 'capabilities' => 'tool/lp:templatemanage', ), 'tool_lp_create_template' => array( - 'classname' => 'tool_lp\external', - 'methodname' => 'create_template', - 'classpath' => '', - 'description' => 'Creates new learning plan templates.', - 'type' => 'write', - 'capabilities'=> 'tool/lp:templatemanage', + 'classname' => 'tool_lp\external', + 'methodname' => 'create_template', + 'classpath' => '', + 'description' => 'Creates new learning plan templates.', + 'type' => 'write', + 'capabilities' => 'tool/lp:templatemanage', ), 'tool_lp_read_template' => array( - 'classname' => 'tool_lp\external', - 'methodname' => 'read_template', - 'classpath' => '', - 'description' => 'Load a summary of a learning plan template.', - 'type' => 'read', - 'capabilities'=> 'tool/lp:templateview', + 'classname' => 'tool_lp\external', + 'methodname' => 'read_template', + 'classpath' => '', + 'description' => 'Load a summary of a learning plan template.', + 'type' => 'read', + 'capabilities' => 'tool/lp:templateview', ), 'tool_lp_delete_template' => array( - 'classname' => 'tool_lp\external', - 'methodname' => 'delete_template', - 'classpath' => '', - 'description' => 'Delete a learning plan template.', - 'type' => 'write', - 'capabilities'=> 'tool/lp:templatemanage', + 'classname' => 'tool_lp\external', + 'methodname' => 'delete_template', + 'classpath' => '', + 'description' => 'Delete a learning plan template.', + 'type' => 'write', + 'capabilities' => 'tool/lp:templatemanage', ), 'tool_lp_update_template' => array( - 'classname' => 'tool_lp\external', - 'methodname' => 'update_template', - 'classpath' => '', - 'description' => 'Update a learning plan template.', - 'type' => 'write', - 'capabilities'=> 'tool/lp:templatemanage', + 'classname' => 'tool_lp\external', + 'methodname' => 'update_template', + 'classpath' => '', + 'description' => 'Update a learning plan template.', + 'type' => 'write', + 'capabilities' => 'tool/lp:templatemanage', ), 'tool_lp_list_templates' => array( - 'classname' => 'tool_lp\external', - 'methodname' => 'list_templates', - 'classpath' => '', - 'description' => 'Load a list of a learning plan templates.', - 'type' => 'read', - 'capabilities'=> 'tool/lp:templateview', + 'classname' => 'tool_lp\external', + 'methodname' => 'list_templates', + 'classpath' => '', + 'description' => 'Load a list of a learning plan templates.', + 'type' => 'read', + 'capabilities' => 'tool/lp:templateview', ), 'tool_lp_count_templates' => array( - 'classname' => 'tool_lp\external', - 'methodname' => 'count_templates', - 'classpath' => '', - 'description' => 'Count a list of a learning plan templates.', - 'type' => 'read', - 'capabilities'=> 'tool/lp:templateview', + 'classname' => 'tool_lp\external', + 'methodname' => 'count_templates', + 'classpath' => '', + 'description' => 'Count a list of a learning plan templates.', + 'type' => 'read', + 'capabilities' => 'tool/lp:templateview', ), 'tool_lp_data_for_templates_manage_page' => array( - 'classname' => 'tool_lp\external', - 'methodname' => 'data_for_templates_manage_page', - 'classpath' => '', - 'description' => 'Load the data for the learning plan templates manage page template', - 'type' => 'read', - 'capabilities'=> 'tool/lp:templateview', + 'classname' => 'tool_lp\external', + 'methodname' => 'data_for_templates_manage_page', + 'classpath' => '', + 'description' => 'Load the data for the learning plan templates manage page template', + 'type' => 'read', + 'capabilities' => 'tool/lp:templateview', ), 'tool_lp_reorder_template' => array( - 'classname' => 'tool_lp\external', - 'methodname' => 'reorder_template', - 'classpath' => '', - 'description' => 'Move a learning plan template to a new relative sort order.', - 'type' => 'write', - 'capabilities'=> 'tool/lp:templatemanage', + 'classname' => 'tool_lp\external', + 'methodname' => 'reorder_template', + 'classpath' => '', + 'description' => 'Move a learning plan template to a new relative sort order.', + 'type' => 'write', + 'capabilities' => 'tool/lp:templatemanage', ), 'tool_lp_create_plan' => array( - 'classname' => 'tool_lp\external', - 'methodname' => 'create_plan', - 'classpath' => '', - 'description' => 'Creates a learning plan.', - 'type' => 'write', - 'capabilities'=> 'tool/lp:planmanageall', + 'classname' => 'tool_lp\external', + 'methodname' => 'create_plan', + 'classpath' => '', + 'description' => 'Creates a learning plan.', + 'type' => 'write', + 'capabilities' => 'tool/lp:planmanageall', ), 'tool_lp_update_plan' => array( - 'classname' => 'tool_lp\external', - 'methodname' => 'update_plan', - 'classpath' => '', - 'description' => 'Updates a learning plan.', - 'type' => 'write', - 'capabilities'=> 'tool/lp:planmanageall', + 'classname' => 'tool_lp\external', + 'methodname' => 'update_plan', + 'classpath' => '', + 'description' => 'Updates a learning plan.', + 'type' => 'write', + 'capabilities' => 'tool/lp:planmanageall', ), 'tool_lp_read_plan' => array( - 'classname' => 'tool_lp\external', - 'methodname' => 'read_plan', - 'classpath' => '', - 'description' => 'Load a learning plan.', - 'type' => 'read', - 'capabilities'=> 'tool/lp:planviewown', + 'classname' => 'tool_lp\external', + 'methodname' => 'read_plan', + 'classpath' => '', + 'description' => 'Load a learning plan.', + 'type' => 'read', + 'capabilities' => 'tool/lp:planviewown', ), 'tool_lp_delete_plan' => array( - 'classname' => 'tool_lp\external', - 'methodname' => 'delete_plan', - 'classpath' => '', - 'description' => 'Delete a learning plan.', - 'type' => 'write', - 'capabilities'=> 'tool/lp:planmanageall', + 'classname' => 'tool_lp\external', + 'methodname' => 'delete_plan', + 'classpath' => '', + 'description' => 'Delete a learning plan.', + 'type' => 'write', + 'capabilities' => 'tool/lp:planmanageall', ), 'tool_lp_data_for_plans_page' => array( - 'classname' => 'tool_lp\external', - 'methodname' => 'data_for_plans_page', - 'classpath' => '', - 'description' => 'Load the data for the plans page template', - 'type' => 'read', - 'capabilities'=> 'tool/lp:planviewown', + 'classname' => 'tool_lp\external', + 'methodname' => 'data_for_plans_page', + 'classpath' => '', + 'description' => 'Load the data for the plans page template', + 'type' => 'read', + 'capabilities' => 'tool/lp:planviewown', ), 'tool_lp_get_scale_values' => array( - 'classname' => 'tool_lp\external', - 'methodname' => 'get_scale_values', - 'classpath' => '', - 'description' => 'Fetch the values for a specific scale', - 'type' => 'read', - 'capabilities'=> 'tool/lp:competencymanage', + 'classname' => 'tool_lp\external', + 'methodname' => 'get_scale_values', + 'classpath' => '', + 'description' => 'Fetch the values for a specific scale', + 'type' => 'read', + 'capabilities' => 'tool/lp:competencymanage', ) ); diff --git a/admin/tool/lp/editcompetency.php b/admin/tool/lp/editcompetency.php index 7608c7b7876..6788d9401a3 100644 --- a/admin/tool/lp/editcompetency.php +++ b/admin/tool/lp/editcompetency.php @@ -38,7 +38,7 @@ if (empty($id)) { $pagetitle = get_string('editcompetency', 'tool_lp'); } // Set up the page. -$params = array('id'=>$id, 'competencyframeworkid'=>$competencyframeworkid, 'parentid'=>$parentid); +$params = array('id' => $id, 'competencyframeworkid' => $competencyframeworkid, 'parentid' => $parentid); $url = new moodle_url("/admin/tool/lp/editcompetency.php", $params); $PAGE->set_url($url); $PAGE->set_title($title); @@ -54,7 +54,7 @@ if ($parentid) { $form = new \tool_lp\form\competency(null, array('id' => $id, 'competencyframework' => $competencyframework, 'parent' => $parent)); if ($form->is_cancelled()) { - redirect(new moodle_url('/admin/tool/lp/competencies.php', array('competencyframeworkid'=>$competencyframeworkid))); + redirect(new moodle_url('/admin/tool/lp/competencies.php', array('competencyframeworkid' => $competencyframeworkid))); } echo $output->header(); @@ -71,16 +71,17 @@ if ($data) { require_sesskey(); \tool_lp\api::create_competency($data); echo $output->notification(get_string('competencycreated', 'tool_lp'), 'notifysuccess'); - echo $output->continue_button(new moodle_url('/admin/tool/lp/competencies.php', array('competencyframeworkid'=>$competencyframeworkid))); + echo $output->continue_button(new moodle_url('/admin/tool/lp/competencies.php', + array('competencyframeworkid' => $competencyframeworkid))); } else { require_sesskey(); \tool_lp\api::update_competency($data); echo $output->notification(get_string('competencyupdated', 'tool_lp'), 'notifysuccess'); - echo $output->continue_button(new moodle_url('/admin/tool/lp/competencies.php', array('competencyframeworkid'=>$competencyframeworkid))); + echo $output->continue_button(new moodle_url('/admin/tool/lp/competencies.php', + array('competencyframeworkid' => $competencyframeworkid))); } } else { $form->display(); } - echo $output->footer(); diff --git a/admin/tool/lp/editcompetencyframework.php b/admin/tool/lp/editcompetencyframework.php index 46735b96474..d1e36519ad9 100644 --- a/admin/tool/lp/editcompetencyframework.php +++ b/admin/tool/lp/editcompetencyframework.php @@ -35,7 +35,7 @@ if (empty($id)) { $pagetitle = get_string('editcompetencyframework', 'tool_lp'); } // Set up the page. -$url = new moodle_url("/admin/tool/lp/editcompetencyframework.php", array('id'=>$id)); +$url = new moodle_url("/admin/tool/lp/editcompetencyframework.php", array('id' => $id)); $PAGE->set_url($url); $PAGE->set_title($title); $PAGE->set_heading($title); diff --git a/admin/tool/lp/edittemplate.php b/admin/tool/lp/edittemplate.php index b2c2db53be6..6c2930f2ff8 100644 --- a/admin/tool/lp/edittemplate.php +++ b/admin/tool/lp/edittemplate.php @@ -35,7 +35,7 @@ if (empty($id)) { $pagetitle = get_string('edittemplate', 'tool_lp'); } // Set up the page. -$url = new moodle_url("/admin/tool/lp/edittemplate.php", array('id'=>$id)); +$url = new moodle_url("/admin/tool/lp/edittemplate.php", array('id' => $id)); $PAGE->set_url($url); $PAGE->set_title($title); $PAGE->set_heading($title); diff --git a/admin/tool/lp/lang/en/tool_lp.php b/admin/tool/lp/lang/en/tool_lp.php index 2b62a9759cf..910bd8e5105 100644 --- a/admin/tool/lp/lang/en/tool_lp.php +++ b/admin/tool/lp/lang/en/tool_lp.php @@ -22,111 +22,105 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -$string['pluginname'] = 'Learning Plans'; +$string['actions'] = 'Actions'; +$string['addcompetency'] = 'Add competency'; +$string['addnewcompetency'] = 'Add new competency'; +$string['addnewcompetencyframework'] = 'Add new competency framework'; +$string['addnewplan'] = 'Add new learning plan'; +$string['addnewtemplate'] = 'Add new learning plan template'; +$string['competencies'] = 'Competencies'; +$string['competenciesforframework'] = 'Competencies for {$a}'; +$string['competencycreated'] = 'Competency created'; +$string['competencyframework'] = 'Competency framework'; +$string['competencyframeworkcreated'] = 'Competency framework created.'; +$string['competencyframeworkname'] = 'Name'; +$string['competencyframeworks'] = 'Competency Frameworks'; +$string['competencyframeworkupdated'] = 'Competency framework updated.'; +$string['competencyupdated'] = 'Competency updated'; +$string['configurescale'] = 'Configure scales'; +$string['coursecompetencies'] = 'Course competencies'; +$string['coursesusingthiscompetency'] = 'Courses using this competency'; +$string['default'] = 'Default'; +$string['deletecompetency'] = 'Delete competency \'{$a}\'?'; +$string['deletecompetencyframework'] = 'Delete competency framework \'{$a}\'?'; +$string['deleteplan'] = 'Delete plan \'{$a}\'?'; +$string['deletetemplate'] = 'Delete learning plan template \'{$a}\'?'; +$string['deletethisplan'] = 'Delete this learning plan'; +$string['description'] = 'Description'; +$string['duedate'] = 'Due date'; +$string['duedate_help'] = 'The date that a learning plan should be completed by.'; +$string['editcompetency'] = 'Edit competency'; +$string['editcompetencyframework'] = 'Edit competency framework'; +$string['editplan'] = 'Edit learning plan'; +$string['edittemplate'] = 'Edit learning plan template'; +$string['editthisplan'] = 'Edit this learning plan'; +$string['erroreditingmodifiedplan'] = 'You can not edit a learning plan modified by another user if you don\'t have +tool/lp:planmanage or tool/lp:planmanageown capabilities.'; +$string['errorplanstatus'] = 'Learning plans \'{$a}\' status unknown'; +$string['hidden'] = 'Hidden'; +$string['hiddenhint'] = '(hidden)'; +$string['idnumber'] = 'Id number'; +$string['itemstoadd'] = 'Items to add'; +$string['learningplans'] = 'Learning plans'; +$string['linkcompetencies'] = 'Link competencies'; +$string['linkcoursecompetencies'] = 'Link course competencies'; +$string['linkedcourses'] = 'Linked courses'; +$string['linktemplatecompetencies'] = 'Link template competencies'; +$string['listcompetencyframeworkscaption'] = 'List of competency frameworks'; +$string['listplanscaption'] = 'List of learning plans'; +$string['listtemplatescaption'] = 'List of learning plan templates'; +$string['locatecompetency'] = 'Locate competency'; +$string['lp:competencymanage'] = 'Manage competency frameworks'; +$string['lp:competencyread'] = 'View competency frameworks'; +$string['lp:coursecompetencymanage'] = 'Manage course competencies'; +$string['lp:coursecompetencyread'] = 'View course competencies'; $string['lp:plancreatedraft'] = 'Create draft learning plans'; $string['lp:planmanageall'] = 'Manage learning plans'; $string['lp:planmanageown'] = 'Manage own learning plans'; $string['lp:planviewall'] = 'View all learning plans'; $string['lp:planviewown'] = 'View own learning plans'; -$string['lp:competencymanage'] = 'Manage competency frameworks'; -$string['lp:competencyread'] = 'View competency frameworks'; -$string['lp:coursecompetencymanage'] = 'Manage course competencies'; -$string['lp:coursecompetencyread'] = 'View course competencies'; $string['lp:templatemanage'] = 'Manage templates'; $string['lp:templateread'] = 'View template'; -$string['competencies'] = 'Competencies'; -$string['competenciesforframework'] = 'Competencies for {$a}'; -$string['competencyframeworks'] = 'Competency Frameworks'; -$string['configurescale'] = 'Configure scales'; -$string['addnewcompetencyframework'] = 'Add new competency framework'; -$string['addnewplan'] = 'Add new learning plan'; -$string['addnewtemplate'] = 'Add new learning plan template'; -$string['addnewcompetency'] = 'Add new competency'; -$string['addnewplan'] = 'Add new learning plan'; -$string['addcompetency'] = 'Add competency'; -$string['default'] = 'Default'; -$string['editcompetencyframework'] = 'Edit competency framework'; -$string['erroreditingmodifiedplan'] = 'You can not edit a learning plan modified by another user if you don\'t have tool/lp:planmanage or tool/lp:planmanageown capabilities.'; -$string['errorplanstatus'] = 'Learning plans \'{$a}\' status unknown'; -$string['listcompetencyframeworkscaption'] = 'List of competency frameworks'; -$string['listtemplatescaption'] = 'List of learning plan templates'; -$string['listplanscaption'] = 'List of learning plans'; -$string['competencyframeworkname'] = 'Name'; -$string['actions'] = 'Actions'; -$string['status'] = 'Status'; -$string['notemplates'] = 'No learning plan templates have been created yet.'; -$string['nocompetencyframeworks'] = 'No competency frameworks have been created yet.'; -$string['nocompetencies'] = 'No competencies have been created in this framework.'; -$string['nocompetenciesincourse'] = 'No competencies have been linked to this course.'; -$string['nouserplans'] = 'No learning plans have been created yet.'; -$string['nocompetenciesintemplate'] = 'No competencies have been linked to this template.'; -$string['proficient'] = 'Proficient'; - -$string['shortname'] = 'Name'; -$string['savechanges'] = 'Save changes'; -$string['scale'] = 'Scale'; -$string['scalevalue'] = 'Scale value'; -$string['scale_help'] = 'A scale determines how proficiency is measured in a competency. After selecting a scale, configure the scale, setting one of the scale values as default and marking all scale values that are deemed proficient.'; -$string['description'] = 'Description'; -$string['visible'] = 'Visible'; -$string['visible_help'] = 'A competency framework can be hidden from teachers. This could be useful if a framework is still in the process of being developed.'; -$string['idnumber'] = 'Id number'; -$string['competencyframework'] = 'Competency framework'; -$string['parentcompetency'] = 'Parent competency'; -$string['competencyframeworkcreated'] = 'Competency framework created.'; -$string['competencyframeworkupdated'] = 'Competency framework updated.'; -$string['editcompetencyframework'] = 'Edit competency framework'; -$string['editplan'] = 'Edit learning plan'; -$string['editthisplan'] = 'Edit this learning plan'; -$string['deletethisplan'] = 'Delete this learning plan'; -$string['hiddenhint'] = '(hidden)'; -$string['movecompetencyframework'] = 'Move competency framework'; -$string['movetonewparent'] = 'Relocate'; -$string['moveframeworkafter'] = 'Move competency framework after \'{$a}\''; -$string['selectedcompetency'] = 'Selected competency'; -$string['nocompetencyselected'] = 'No competency selected'; -$string['plancreated'] = 'Learning plan created'; -$string['planupdated'] = 'Learning plan updated'; -$string['planname'] = 'Name'; -$string['plandescription'] = 'Description'; -$string['planstatusdraft'] = 'Draft'; -$string['planstatusactive'] = 'Active'; -$string['planstatuscomplete'] = 'Complete'; -$string['search'] = 'Search...'; -$string['competencycreated'] = 'Competency created'; -$string['competencyupdated'] = 'Competency updated'; -$string['hidden'] = 'Hidden'; -$string['editcompetency'] = 'Edit competency'; -$string['confirm'] = 'Confirm'; -$string['delete'] = 'Delete'; -$string['deletecompetency'] = 'Delete competency \'{$a}\'?'; -$string['deletecompetencyframework'] = 'Delete competency framework \'{$a}\'?'; -$string['deleteplan'] = 'Delete plan \'{$a}\'?'; -$string['cancel'] = 'Cancel'; -$string['move'] = 'Move'; -$string['movecompetency'] = 'Move competency: {$a}'; -$string['selectcompetencymovetarget'] = 'Select a location to move this competency to:'; -$string['coursecompetencies'] = 'Course competencies'; -$string['linkcompetencies'] = 'Link competencies'; -$string['linkcoursecompetencies'] = 'Link course competencies'; -$string['linktemplatecompetencies'] = 'Link template competencies'; $string['managecompetenciesandframeworks'] = 'Manage competencies and frameworks'; -$string['locatecompetency'] = 'Locate competency'; -$string['itemstoadd'] = 'Items to add'; -$string['linkedcourses'] = 'Linked courses'; -$string['nolinkedcourses'] = 'No courses are using this competency'; -$string['coursesusingthiscompetency'] = 'Courses using this competency'; -$string['learningplans'] = 'Learning plans'; -$string['plantemplate'] = 'Select template'; -$string['plantemplate_help'] = 'A learning plan created from a template will contain a list of competencies that match the template. Updates to the template will be reflected in any plan created from that template.'; +$string['move'] = 'Move'; $string['movecompetency'] = 'Move competency'; $string['movecompetencyafter'] = 'Move competency after \'{$a}\''; +$string['movecompetencyframework'] = 'Move competency framework'; +$string['moveframeworkafter'] = 'Move competency framework after \'{$a}\''; +$string['movetonewparent'] = 'Relocate'; +$string['nocompetencies'] = 'No competencies have been created in this framework.'; +$string['nocompetenciesincourse'] = 'No competencies have been linked to this course.'; +$string['nocompetenciesintemplate'] = 'No competencies have been linked to this template.'; +$string['nocompetencyframeworks'] = 'No competency frameworks have been created yet.'; +$string['nocompetencyselected'] = 'No competency selected'; +$string['nolinkedcourses'] = 'No courses are using this competency'; +$string['notemplates'] = 'No learning plan templates have been created yet.'; +$string['nouserplans'] = 'No learning plans have been created yet.'; +$string['parentcompetency'] = 'Parent competency'; +$string['plancreated'] = 'Learning plan created'; +$string['plandescription'] = 'Description'; +$string['planname'] = 'Name'; +$string['planstatusactive'] = 'Active'; +$string['planstatuscomplete'] = 'Complete'; +$string['planstatusdraft'] = 'Draft'; +$string['plantemplate'] = 'Select template'; +$string['plantemplate_help'] = 'A learning plan created from a template will contain a list of competencies that match the template. Updates to the template will be reflected in any plan created from that template.'; +$string['planupdated'] = 'Learning plan updated'; +$string['pluginname'] = 'Learning Plans'; +$string['proficient'] = 'Proficient'; +$string['savechanges'] = 'Save changes'; +$string['scale'] = 'Scale'; +$string['scale_help'] = 'A scale determines how proficiency is measured in a competency. After selecting a scale, configure the scale, setting one of the scale values as default and marking all scale values that are deemed proficient.'; +$string['scalevalue'] = 'Scale value'; +$string['search'] = 'Search...'; +$string['selectcompetencymovetarget'] = 'Select a location to move this competency to:'; +$string['selectedcompetency'] = 'Selected competency'; +$string['shortname'] = 'Name'; +$string['status'] = 'Status'; $string['templatecompetencies'] = 'Template competencies'; -$string['templates'] = 'Learning plan templates'; -$string['templatename'] = 'Name'; $string['templatecreated'] = 'Learning plan template created'; +$string['templatename'] = 'Name'; +$string['templates'] = 'Learning plan templates'; $string['templateupdated'] = 'Learning plan template updated'; -$string['edittemplate'] = 'Edit learning plan template'; -$string['deletetemplate'] = 'Delete learning plan template \'{$a}\'?'; -$string['duedate'] = 'Due date'; -$string['duedate_help'] = 'The date that a learning plan should be completed by.'; +$string['visible'] = 'Visible'; +$string['visible_help'] = 'A competency framework can be hidden from teachers. This could be useful if a framework is still in the process of being developed.'; diff --git a/admin/tool/lp/templates/manage_competency_frameworks_page.mustache b/admin/tool/lp/templates/manage_competency_frameworks_page.mustache index 25184205762..a65892d2e84 100644 --- a/admin/tool/lp/templates/manage_competency_frameworks_page.mustache +++ b/admin/tool/lp/templates/manage_competency_frameworks_page.mustache @@ -56,12 +56,12 @@ diff --git a/admin/tool/lp/templates/manage_templates_page.mustache b/admin/tool/lp/templates/manage_templates_page.mustache index f69394635b1..c3a61b31da3 100644 --- a/admin/tool/lp/templates/manage_templates_page.mustache +++ b/admin/tool/lp/templates/manage_templates_page.mustache @@ -54,12 +54,12 @@ diff --git a/admin/tool/lp/tests/externallib_test.php b/admin/tool/lp/tests/externallib_test.php index 975eeced525..6b4f5e60d85 100644 --- a/admin/tool/lp/tests/externallib_test.php +++ b/admin/tool/lp/tests/externallib_test.php @@ -13,6 +13,13 @@ // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +/** + * External learning plans webservice API tests. + * + * @package tool_lp + * @copyright 2015 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ defined('MOODLE_INTERNAL') || die(); @@ -196,7 +203,8 @@ class tool_lp_external_testcase extends externallib_advanced_testcase { $result = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true); $result = (object) external_api::clean_returnvalue(external::create_competency_framework_returns(), $result); - $result = external::update_competency_framework($result->id, 'shortname2', 'idnumber2', 'description2', FORMAT_PLAIN, false); + $result = external::update_competency_framework($result->id, 'shortname2', + 'idnumber2', 'description2', FORMAT_PLAIN, false); $result = external_api::clean_returnvalue(external::update_competency_framework_returns(), $result); $this->assertTrue($result); @@ -212,7 +220,8 @@ class tool_lp_external_testcase extends externallib_advanced_testcase { $result = (object) external_api::clean_returnvalue(external::create_competency_framework_returns(), $result); $this->setUser($this->user); - $result = external::update_competency_framework($result->id, 'shortname2', 'idnumber2', 'description2', FORMAT_PLAIN, false); + $result = external::update_competency_framework($result->id, 'shortname2', + 'idnumber2', 'description2', FORMAT_PLAIN, false); } /** @@ -373,7 +382,8 @@ class tool_lp_external_testcase extends externallib_advanced_testcase { $framework = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true); $framework = (object) external_api::clean_returnvalue(external::create_competency_framework_returns(), $framework); $this->setExpectedException('invalid_parameter_exception'); - $competency = external::create_competency('shortname', 'id;"number', 'de<>\\..scription', FORMAT_HTML, true, $framework->id, 0); + $competency = external::create_competency('shortname', 'id;"number', + 'de<>\\..scription', FORMAT_HTML, true, $framework->id, 0); } /** @@ -594,12 +604,14 @@ class tool_lp_external_testcase extends externallib_advanced_testcase { $syscontext = context_system::instance(); $this->setUser($this->creator); - $plan0 = external::create_plan('Complete plan', 'A description', FORMAT_HTML, $this->creator->id, 0, plan::STATUS_COMPLETE, 0); + $plan0 = external::create_plan('Complete plan', 'A description', + FORMAT_HTML, $this->creator->id, 0, plan::STATUS_COMPLETE, 0); $this->setUser($this->user); try { - $plan1 = external::create_plan('Draft plan (they can not with the default capabilities)', 'A description', FORMAT_HTML, $this->user->id, 0, plan::STATUS_DRAFT, 0); + $plan1 = external::create_plan('Draft plan (they can not with the default capabilities)', + 'A description', FORMAT_HTML, $this->user->id, 0, plan::STATUS_DRAFT, 0); $this->fail('Exception expected due to not permissions to create draft plans'); } catch (moodle_exception $e) { $this->assertEquals('nopermissions', $e->errorcode); @@ -613,13 +625,15 @@ class tool_lp_external_testcase extends externallib_advanced_testcase { $plan2 = external::create_plan('Draft plan', 'A description', FORMAT_HTML, $this->user->id, 0, plan::STATUS_DRAFT, 0); try { - $plan3 = external::create_plan('Active plan (they can not)', 'A description', FORMAT_HTML, $this->user->id, 0, plan::STATUS_ACTIVE, 0); + $plan3 = external::create_plan('Active plan (they can not)', 'A description', + FORMAT_HTML, $this->user->id, 0, plan::STATUS_ACTIVE, 0); $this->fail('Exception expected due to not permissions to create active plans'); } catch (moodle_exception $e) { $this->assertEquals('nopermissions', $e->errorcode); } try { - $plan3 = external::update_plan($plan2['id'], 'Updated active plan', 'A description', FORMAT_HTML, $this->user->id, 0, plan::STATUS_COMPLETE, 0); + $plan3 = external::update_plan($plan2['id'], 'Updated active plan', 'A description', + FORMAT_HTML, $this->user->id, 0, plan::STATUS_COMPLETE, 0); $this->fail('Exception expected due to not permissions to update plans to complete status'); } catch (moodle_exception $e) { $this->assertEquals('nopermissions', $e->errorcode); @@ -631,14 +645,16 @@ class tool_lp_external_testcase extends externallib_advanced_testcase { $plan3 = external::create_plan('Active plan', 'A description', FORMAT_HTML, $this->user->id, 0, plan::STATUS_ACTIVE, 0); $plan4 = external::create_plan('Complete plan', 'A description', FORMAT_HTML, $this->user->id, 0, plan::STATUS_COMPLETE, 0); try { - $plan4 = external::create_plan('Plan for another user', 'A description', FORMAT_HTML, $this->creator->id, 0, plan::STATUS_COMPLETE, 0); + $plan4 = external::create_plan('Plan for another user', 'A description', + FORMAT_HTML, $this->creator->id, 0, plan::STATUS_COMPLETE, 0); $this->fail('Exception expected due to not permissions to manage other users plans'); } catch (moodle_exception $e) { $this->assertEquals('nopermissions', $e->errorcode); } try { - $plan0 = external::update_plan($plan0['id'], 'Can not update other users plans', 'A description', FORMAT_HTML, $this->user->id, 0, plan::STATUS_ACTIVE, 0); + $plan0 = external::update_plan($plan0['id'], 'Can not update other users plans', + 'A description', FORMAT_HTML, $this->user->id, 0, plan::STATUS_ACTIVE, 0); } catch (moodle_exception $e) { $this->assertEquals('nopermissions', $e->errorcode); } @@ -648,7 +664,8 @@ class tool_lp_external_testcase extends externallib_advanced_testcase { accesslib_clear_all_caches_for_unit_testing(); try { - $plan1 = external::update_plan($plan2['id'], 'Can not be updated even if they created it', 'A description', FORMAT_HTML, $this->user->id, 0, plan::STATUS_COMPLETE, 0); + $plan1 = external::update_plan($plan2['id'], 'Can not be updated even if they created it', + 'A description', FORMAT_HTML, $this->user->id, 0, plan::STATUS_COMPLETE, 0); $this->fail('Exception expected due to not permissions to create draft plan'); } catch (moodle_exception $e) { $this->assertEquals('nopermissions', $e->errorcode); @@ -663,9 +680,12 @@ class tool_lp_external_testcase extends externallib_advanced_testcase { $syscontext = context_system::instance(); - $plan1 = external::create_plan('Plan draft by creator', 'A description', FORMAT_HTML, $this->user->id, 0, plan::STATUS_DRAFT, 0); - $plan2 = external::create_plan('Plan active by creator', 'A description', FORMAT_HTML, $this->user->id, 0, plan::STATUS_ACTIVE, 0); - $plan3 = external::create_plan('Plan complete by creator', 'A description', FORMAT_HTML, $this->user->id, 0, plan::STATUS_COMPLETE, 0); + $plan1 = external::create_plan('Plan draft by creator', 'A description', + FORMAT_HTML, $this->user->id, 0, plan::STATUS_DRAFT, 0); + $plan2 = external::create_plan('Plan active by creator', 'A description', + FORMAT_HTML, $this->user->id, 0, plan::STATUS_ACTIVE, 0); + $plan3 = external::create_plan('Plan complete by creator', 'A description', + FORMAT_HTML, $this->user->id, 0, plan::STATUS_COMPLETE, 0); $this->assertEquals((Array)$plan1, external::read_plan($plan1['id'])); $this->assertEquals((Array)$plan2, external::read_plan($plan2['id']));