MDL-50608 tool_lp: Code cleanup

This commit is contained in:
Ankit Agarwal
2016-04-18 10:58:33 +08:00
committed by Frederic Massart
parent 556838950f
commit b17d3d10d7
36 changed files with 811 additions and 594 deletions
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1 +1 @@
define(["jquery","core/templates","core/ajax","core/notification","core/str"],function(a,b,c,d,e){var f=0,g=function(c,d){a('[data-region="managecompetencies"]').replaceWith(c),b.runTemplateJS(d)},h=function(a){b.render("tool_lp/manage_competency_frameworks_page",a).done(g).fail(d.exception)},i=function(){var a=c.call([{methodname:"tool_lp_delete_competency_framework",args:{id:f}},{methodname:"tool_lp_data_for_competency_frameworks_manage_page",args:[]}]);a[1].done(h).fail(d.exception)},j=function(b){b.preventDefault();var g=a(this).attr("data-frameworkid");f=g;var h=c.call([{methodname:"tool_lp_read_competency_framework",args:{id:f}}]);h[0].done(function(a){e.get_strings([{key:"confirm",component:"tool_lp"},{key:"deletecompetencyframework",component:"tool_lp",param:a.shortname},{key:"delete",component:"tool_lp"},{key:"cancel",component:"tool_lp"}]).done(function(a){d.confirm(a[0],a[1],a[2],a[3],i)}).fail(d.exception)}).fail(d.exception)};return{deleteHandler:j}});
define(["jquery","core/templates","core/ajax","core/notification","core/str"],function(a,b,c,d,e){var f=0,g=function(c,d){a('[data-region="managecompetencies"]').replaceWith(c),b.runTemplateJS(d)},h=function(a){b.render("tool_lp/manage_competency_frameworks_page",a).done(g).fail(d.exception)},i=function(){var a=c.call([{methodname:"tool_lp_delete_competency_framework",args:{id:f}},{methodname:"tool_lp_data_for_competency_frameworks_manage_page",args:[]}]);a[1].done(h).fail(d.exception)},j=function(b){b.preventDefault();var g=a(this).attr("data-frameworkid");f=g;var h=c.call([{methodname:"tool_lp_read_competency_framework",args:{id:f}}]);h[0].done(function(a){e.get_strings([{key:"confirm",component:"moodle"},{key:"deletecompetencyframework",component:"tool_lp",param:a.shortname},{key:"delete",component:"moodle"},{key:"cancel",component:"moodle"}]).done(function(a){d.confirm(a[0],a[1],a[2],a[3],i)}).fail(d.exception)}).fail(d.exception)};return{deleteHandler:j}});
+1 -1
View File
@@ -1 +1 @@
define(["jquery","core/templates","core/ajax","core/notification","core/str"],function(a,b,c,d,e){var f=0,g=0,h=function(c,d){a('[data-region="plans"]').replaceWith(c),b.runTemplateJS(d)},i=function(a){b.render("tool_lp/plans_page",a).done(h).fail(d.exception)},j=function(){var a=c.call([{methodname:"tool_lp_delete_plan",args:{id:f}},{methodname:"tool_lp_data_for_plans_page",args:{userid:g}}]);a[1].done(i).fail(d.exception)},k=function(b){b.preventDefault();var g=a(this).attr("data-planid");f=g;var h=c.call([{methodname:"tool_lp_read_plan",args:{id:f}}]);h[0].done(function(a){e.get_strings([{key:"confirm",component:"tool_lp"},{key:"deleteplan",component:"tool_lp",param:a.name},{key:"delete",component:"tool_lp"},{key:"cancel",component:"tool_lp"}]).done(function(a){d.confirm(a[0],a[1],a[2],a[3],j)}).fail(d.exception)}).fail(d.exception)};return{init:function(){a('[data-region="plans"]').on("click",'[data-action="deleteplan"]',k),g=a('[data-region="plans"]').attr("data-userid")}}});
define(["jquery","core/templates","core/ajax","core/notification","core/str"],function(a,b,c,d,e){var f=0,g=0,h=function(c,d){a('[data-region="plans"]').replaceWith(c),b.runTemplateJS(d)},i=function(a){b.render("tool_lp/plans_page",a).done(h).fail(d.exception)},j=function(){var a=c.call([{methodname:"tool_lp_delete_plan",args:{id:f}},{methodname:"tool_lp_data_for_plans_page",args:{userid:g}}]);a[1].done(i).fail(d.exception)},k=function(b){b.preventDefault(),f=a(this).attr("data-planid");var g=c.call([{methodname:"tool_lp_read_plan",args:{id:f}}]);g[0].done(function(a){e.get_strings([{key:"confirm",component:"moodle"},{key:"deleteplan",component:"tool_lp",param:a.name},{key:"delete",component:"moodle"},{key:"cancel",component:"moodle"}]).done(function(a){d.confirm(a[0],a[1],a[2],a[3],j)}).fail(d.exception)}).fail(d.exception)};return{init:function(){a('[data-region="plans"]').on("click",'[data-action="deleteplan"]',k),g=a('[data-region="plans"]').attr("data-userid")}}});
+1 -1
View File
@@ -1 +1 @@
define(["jquery","core/templates","core/ajax","core/notification","core/str"],function(a,b,c,d,e){var f=0,g=function(c,d){a('[data-region="managetemplates"]').replaceWith(c),b.runTemplateJS(d)},h=function(a){b.render("tool_lp/manage_templates_page",a).done(g).fail(d.exception)},i=function(){var a=c.call([{methodname:"tool_lp_delete_template",args:{id:f}},{methodname:"tool_lp_data_for_templates_manage_page",args:[]}]);a[1].done(h).fail(d.exception)},j=function(b){b.preventDefault();var g=a(this).attr("data-templateid");f=g;var h=c.call([{methodname:"tool_lp_read_template",args:{id:f}}]);h[0].done(function(a){e.get_strings([{key:"confirm",component:"tool_lp"},{key:"deletetemplate",component:"tool_lp",param:a.shortname},{key:"delete",component:"tool_lp"},{key:"cancel",component:"tool_lp"}]).done(function(a){d.confirm(a[0],a[1],a[2],a[3],i)}).fail(d.exception)}).fail(d.exception)};return{deleteHandler:j}});
define(["jquery","core/templates","core/ajax","core/notification","core/str"],function(a,b,c,d,e){var f=0,g=function(c,d){a('[data-region="managetemplates"]').replaceWith(c),b.runTemplateJS(d)},h=function(a){b.render("tool_lp/manage_templates_page",a).done(g).fail(d.exception)},i=function(){var a=c.call([{methodname:"tool_lp_delete_template",args:{id:f}},{methodname:"tool_lp_data_for_templates_manage_page",args:[]}]);a[1].done(h).fail(d.exception)},j=function(b){b.preventDefault();var g=a(this).attr("data-templateid");f=g;var h=c.call([{methodname:"tool_lp_read_template",args:{id:f}}]);h[0].done(function(a){e.get_strings([{key:"confirm",component:"moodle"},{key:"deletetemplate",component:"tool_lp",param:a.shortname},{key:"delete",component:"moodle"},{key:"cancel",component:"moodle"}]).done(function(a){d.confirm(a[0],a[1],a[2],a[3],i)}).fail(d.exception)}).fail(d.exception)};return{deleteHandler:j}});
+2 -2
View File
@@ -90,8 +90,8 @@ define(['jquery',
* Handle a drop from a drag/drop operation.
*
* @method handleDrop
* @param {Node} drag The dragged node.
* @param {Node} drop The dropped on node.
* @param {DOMNode} drag The dragged node.
* @param {DOMNode} drop The dropped on node.
*/
competencies.prototype.handleDrop = function(drag, drop) {
var fromid = $(drag).data('id');
+7 -9
View File
@@ -57,8 +57,7 @@ define(['jquery',
params.parentid = parent.id;
}
var queryparams = $.param(params);
var actionurl = url.relativeUrl('/admin/tool/lp/editcompetency.php?' + queryparams);
window.location = actionurl;
window.location = url.relativeUrl('/admin/tool/lp/editcompetency.php?' + queryparams);
};
/**
@@ -89,7 +88,7 @@ define(['jquery',
/**
* A move competency popup was opened - initialise the aria tree in it.
* @method initMovePopup
* @param {dialogue} The tool_lp/dialogue that was created.
* @param {dialogue} popup The tool_lp/dialogue that was created.
*/
var initMovePopup = function(popup) {
new Ariatree('[data-enhance=movetree]', function(target) {
@@ -165,7 +164,7 @@ define(['jquery',
str.get_strings([
{ key: 'movecompetency', component: 'tool_lp', param: competency.shortname },
{ key: 'move', component: 'tool_lp' },
{ key: 'cancel', component: 'tool_lp' }
{ key: 'cancel', component: 'moodle' }
]).done(function (strings) {
var context = {
@@ -203,8 +202,7 @@ define(['jquery',
};
var queryparams = $.param(params);
var actionurl = url.relativeUrl('/admin/tool/lp/editcompetency.php?' + queryparams);
window.location = actionurl;
window.location = url.relativeUrl('/admin/tool/lp/editcompetency.php?' + queryparams);
};
/**
@@ -331,10 +329,10 @@ define(['jquery',
.done(function(html) {
str.get_strings([
{ key: 'confirm', component: 'tool_lp' },
{ key: 'confirm', component: 'moodle' },
{ key: 'deletecompetency', component: 'tool_lp', param: html },
{ key: 'delete', component: 'tool_lp' },
{ key: 'cancel', component: 'tool_lp' }
{ key: 'delete', component: 'moodle' },
{ key: 'cancel', component: 'moodle' }
]).done(function (strings) {
notification.confirm(
strings[0], // Confirm.
+3 -3
View File
@@ -82,10 +82,10 @@ define(['jquery', 'core/templates', 'core/ajax', 'core/notification', 'core/str'
requests[0].done(function(framework) {
str.get_strings([
{ key: 'confirm', component: 'tool_lp' },
{ key: 'confirm', component: 'moodle' },
{ key: 'deletecompetencyframework', component: 'tool_lp', param: framework.shortname },
{ key: 'delete', component: 'tool_lp' },
{ key: 'cancel', component: 'tool_lp' }
{ key: 'delete', component: 'moodle' },
{ key: 'cancel', component: 'moodle' }
]).done(function (strings) {
notification.confirm(
strings[0], // Confirm.
+5 -6
View File
@@ -74,9 +74,8 @@ define(['jquery', 'core/templates', 'core/ajax', 'core/notification', 'core/str'
*/
var confirmDelete = function(e) {
e.preventDefault();
var id = $(this).attr('data-planid');
planid = id;
planid = $(this).attr('data-planid');
var requests = ajax.call([{
methodname: 'tool_lp_read_plan',
@@ -85,10 +84,10 @@ define(['jquery', 'core/templates', 'core/ajax', 'core/notification', 'core/str'
requests[0].done(function(plan) {
str.get_strings([
{ key: 'confirm', component: 'tool_lp' },
{ key: 'confirm', component: 'moodle' },
{ key: 'deleteplan', component: 'tool_lp', param: plan.name },
{ key: 'delete', component: 'tool_lp' },
{ key: 'cancel', component: 'tool_lp' }
{ key: 'delete', component: 'moodle' },
{ key: 'cancel', component: 'moodle' }
]).done(function (strings) {
notification.confirm(
strings[0], // Confirm.
+3 -3
View File
@@ -86,10 +86,10 @@ define(['jquery', 'core/templates', 'core/ajax', 'core/notification', 'core/str'
requests[0].done(function(template) {
str.get_strings([
{ key: 'confirm', component: 'tool_lp' },
{ key: 'confirm', component: 'moodle' },
{ key: 'deletetemplate', component: 'tool_lp', param: template.shortname },
{ key: 'delete', component: 'tool_lp' },
{ key: 'cancel', component: 'tool_lp' }
{ key: 'delete', component: 'moodle' },
{ key: 'cancel', component: 'moodle' }
]).done(function (strings) {
notification.confirm(
strings[0], // Confirm.
+8 -7
View File
@@ -205,7 +205,9 @@ class api {
*
* Requires tool/lp:competencymanage capability at the system context.
*
* @param stdClass $record The new details for the competency. Note - must contain an id that points to the competency to update.
* @param stdClass $record The new details for the competency.
* Note - must contain an id that points to the competency to update.
*
* @return boolean
*/
public static function update_competency($record) {
@@ -404,10 +406,10 @@ class api {
foreach ($all as $id => $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', '');
}
+14 -10
View File
@@ -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;
@@ -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();
}
}
+2 -2
View File
@@ -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;
+103 -32
View File
@@ -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(
+2 -2
View File
@@ -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);
}
}
@@ -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);
}
}
+3 -3
View File
@@ -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);
}
}
@@ -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) {
@@ -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) {
@@ -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) {
@@ -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) {
+7 -6
View File
@@ -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);
+12 -6
View File
@@ -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);
}
@@ -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) {
+15 -10
View File
@@ -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()) {
+93 -7
View File
@@ -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);
-2
View File
@@ -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();
}
}
+69 -69
View File
@@ -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'
),
);
+270 -270
View File
@@ -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',
)
);
+6 -5
View File
@@ -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();
+1 -1
View File
@@ -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);
+1 -1
View File
@@ -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);
+89 -95
View File
@@ -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.';
@@ -56,12 +56,12 @@
<ul class="dropdown-menu">
<li>
<a href="{{pluginbaseurl}}/editcompetencyframework.php?id={{id}}">
{{#pix}}t/edit{{/pix}} {{#str}}edit, tool_lp{{/str}}
{{#pix}}t/edit{{/pix}} {{#str}}edit{{/str}}
</a>
</li>
<li>
<a data-action="deletecompetencyframework" data-frameworkid="{{id}}" href="#">
{{#pix}}t/delete{{/pix}} {{#str}}delete, tool_lp{{/str}}
{{#pix}}t/delete{{/pix}} {{#str}}delete{{/str}}
</a>
</li>
</ul>
@@ -54,12 +54,12 @@
<ul class="dropdown-menu">
<li>
<a href="{{pluginbaseurl}}/edittemplate.php?id={{id}}">
{{#pix}}t/edit{{/pix}} {{#str}}edit, tool_lp{{/str}}
{{#pix}}t/edit{{/pix}} {{#str}}edit{{/str}}
</a>
</li>
<li>
<a data-action="deletetemplate" data-templateid="{{id}}" href="#">
{{#pix}}t/delete{{/pix}} {{#str}}delete, tool_lp{{/str}}
{{#pix}}t/delete{{/pix}} {{#str}}delete{{/str}}
</a>
</li>
</ul>
+33 -13
View File
@@ -13,6 +13,13 @@
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* 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<a href="">', 'id;"number', 'de<>\\..scription', FORMAT_HTML, true, $framework->id, 0);
$competency = external::create_competency('shortname<a href="">', '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']));