mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
MDL-51025 tool_lp: Frameworks can be created on a category level
This commit is contained in:
parent
4511b7d694
commit
2de75345bb
31 changed files with 523 additions and 409 deletions
2
admin/tool/lp/amd/build/competencies.min.js
vendored
2
admin/tool/lp/amd/build/competencies.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -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:"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}});
|
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="managecompetencies"]').replaceWith(c),b.runTemplateJS(d)},i=function(a){b.render("tool_lp/manage_competency_frameworks_page",a).done(h).fail(d.exception)},j=function(){var a=c.call([{methodname:"tool_lp_delete_competency_framework",args:{id:g}},{methodname:"tool_lp_data_for_competency_frameworks_manage_page",args:{pagecontextid:f}}]);a[1].done(i).fail(d.exception)},k=function(b){b.preventDefault();var f=a(this).attr("data-frameworkid");g=f;var h=c.call([{methodname:"tool_lp_read_competency_framework",args:{id:g}}]);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],j)}).fail(d.exception)}).fail(d.exception)};return{deleteHandler:k,init:function(a){f=a}}});
|
1
admin/tool/lp/amd/build/frameworkmove.min.js
vendored
1
admin/tool/lp/amd/build/frameworkmove.min.js
vendored
|
@ -1 +0,0 @@
|
||||||
define(["jquery","core/str","core/notification","core/ajax","tool_lp/dragdrop-reorder"],function(a,b,c,d,e){var f=function(b,e){var f=a(b).data("frameworkid"),g=a(e).data("frameworkid"),h=d.call([{methodname:"tool_lp_reorder_competency_framework",args:{from:f,to:g}}]);h[0].fail(c.exception)};return{init:function(){b.get_string("movecompetencyframework","tool_lp").done(function(a){e.dragdrop("movecompetencyframework",a,{identifier:"movecompetencyframework",component:"tool_lp"},{identifier:"movecompetencyframeworkafter",component:"tool_lp"},"drag-samenode","drag-parentnode","drag-handlecontainer",f)}).fail(c.exception)}}});
|
|
|
@ -37,13 +37,20 @@ define(['jquery',
|
||||||
* @param {Number} itemid
|
* @param {Number} itemid
|
||||||
* @param {String} itemtype
|
* @param {String} itemtype
|
||||||
*/
|
*/
|
||||||
var competencies = function(itemid, itemtype) {
|
var competencies = function(itemid, itemtype, pagectxid) {
|
||||||
this.itemid = itemid;
|
this.itemid = itemid;
|
||||||
this.itemtype = itemtype;
|
this.itemtype = itemtype;
|
||||||
|
this.pageContextId = pagectxid;
|
||||||
this.selectedCompetency = 0;
|
this.selectedCompetency = 0;
|
||||||
var localthis = this;
|
var localthis = this;
|
||||||
var loadframeworks = ajax.call([
|
var loadframeworks = ajax.call([
|
||||||
{ methodname: 'tool_lp_list_competency_frameworks', args: { filters: {}, sort: 'sortorder' } }
|
{ methodname: 'tool_lp_list_competency_frameworks', args: {
|
||||||
|
sort: 'shortname',
|
||||||
|
context: {
|
||||||
|
contextid: this.pageContextId,
|
||||||
|
},
|
||||||
|
includes: 'parents'
|
||||||
|
}}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
loadframeworks[0].done(function(frameworks) {
|
loadframeworks[0].done(function(frameworks) {
|
||||||
|
|
|
@ -40,6 +40,8 @@ define(['jquery',
|
||||||
var moveSource = null;
|
var moveSource = null;
|
||||||
/** @var {Node} moveTarget - The end of a drag operation */
|
/** @var {Node} moveTarget - The end of a drag operation */
|
||||||
var moveTarget = null;
|
var moveTarget = null;
|
||||||
|
/** @var {Number} pageContextId The page context ID. */
|
||||||
|
var pageContextId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Respond to choosing the "Add" menu item for the selected node in the tree.
|
* Respond to choosing the "Add" menu item for the selected node in the tree.
|
||||||
|
@ -49,7 +51,8 @@ define(['jquery',
|
||||||
var parent = $('[data-region="competencyactions"]').data('competency');
|
var parent = $('[data-region="competencyactions"]').data('competency');
|
||||||
|
|
||||||
var params = {
|
var params = {
|
||||||
competencyframeworkid : treeModel.getCompetencyFrameworkId()
|
competencyframeworkid : treeModel.getCompetencyFrameworkId(),
|
||||||
|
pagecontextid: pageContextId
|
||||||
};
|
};
|
||||||
|
|
||||||
if (parent !== null) {
|
if (parent !== null) {
|
||||||
|
@ -198,7 +201,8 @@ define(['jquery',
|
||||||
var params = {
|
var params = {
|
||||||
competencyframeworkid : treeModel.getCompetencyFrameworkId(),
|
competencyframeworkid : treeModel.getCompetencyFrameworkId(),
|
||||||
id : competency.id,
|
id : competency.id,
|
||||||
parentid: competency.parentid
|
parentid: competency.parentid,
|
||||||
|
pagecontextid: pageContextId
|
||||||
};
|
};
|
||||||
|
|
||||||
var queryparams = $.param(params);
|
var queryparams = $.param(params);
|
||||||
|
@ -400,9 +404,11 @@ define(['jquery',
|
||||||
*
|
*
|
||||||
* @method init
|
* @method init
|
||||||
* @param {Object} model The tree model provides some useful functions for loading and searching competencies.
|
* @param {Object} model The tree model provides some useful functions for loading and searching competencies.
|
||||||
|
* @param {Number} pagectxid The page context ID.
|
||||||
*/
|
*/
|
||||||
init: function(model) {
|
init: function(model, pagectxid) {
|
||||||
treeModel = model;
|
treeModel = model;
|
||||||
|
pageContextId = pagectxid;
|
||||||
|
|
||||||
$('[data-region="competencyactions"]').on('click', addHandler);
|
$('[data-region="competencyactions"]').on('click', addHandler);
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,9 @@
|
||||||
define(['jquery', 'core/templates', 'core/ajax', 'core/notification', 'core/str'], function($, templates, ajax, notification, str) {
|
define(['jquery', 'core/templates', 'core/ajax', 'core/notification', 'core/str'], function($, templates, ajax, notification, str) {
|
||||||
// Private variables and functions.
|
// Private variables and functions.
|
||||||
|
|
||||||
|
/** @var {Number} pagecontextid The id of the context */
|
||||||
|
var pagecontextid = 0;
|
||||||
|
|
||||||
/** @var {Number} frameworkid The id of the framework */
|
/** @var {Number} frameworkid The id of the framework */
|
||||||
var frameworkid = 0;
|
var frameworkid = 0;
|
||||||
|
|
||||||
|
@ -60,7 +63,7 @@ define(['jquery', 'core/templates', 'core/ajax', 'core/notification', 'core/str'
|
||||||
args: { id: frameworkid }
|
args: { id: frameworkid }
|
||||||
}, {
|
}, {
|
||||||
methodname: 'tool_lp_data_for_competency_frameworks_manage_page',
|
methodname: 'tool_lp_data_for_competency_frameworks_manage_page',
|
||||||
args: []
|
args: { pagecontextid: pagecontextid }
|
||||||
}]);
|
}]);
|
||||||
requests[1].done(reloadList).fail(notification.exception);
|
requests[1].done(reloadList).fail(notification.exception);
|
||||||
};
|
};
|
||||||
|
@ -108,6 +111,15 @@ define(['jquery', 'core/templates', 'core/ajax', 'core/notification', 'core/str'
|
||||||
* @method deleteHandler
|
* @method deleteHandler
|
||||||
* @param {Event} e
|
* @param {Event} e
|
||||||
*/
|
*/
|
||||||
deleteHandler: confirmDelete
|
deleteHandler: confirmDelete,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialise the module.
|
||||||
|
* @method init
|
||||||
|
* @param {Number} contextid The context id of the page.
|
||||||
|
*/
|
||||||
|
init: function(contextid) {
|
||||||
|
pagecontextid = contextid;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,74 +0,0 @@
|
||||||
// This file is part of Moodle - http://moodle.org/
|
|
||||||
//
|
|
||||||
// Moodle is free software: you can redistribute it and/or modify
|
|
||||||
// it under the terms of the GNU General Public License as published by
|
|
||||||
// the Free Software Foundation, either version 3 of the License, or
|
|
||||||
// (at your option) any later version.
|
|
||||||
//
|
|
||||||
// Moodle is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU General Public License
|
|
||||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Move competency frameworks via ajax.
|
|
||||||
*
|
|
||||||
* @module tool_lp/frameworkmove
|
|
||||||
* @package tool_lp
|
|
||||||
* @copyright 2015 Damyon Wiese <damyon@moodle.com>
|
|
||||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
||||||
*/
|
|
||||||
define(['jquery',
|
|
||||||
'core/str',
|
|
||||||
'core/notification',
|
|
||||||
'core/ajax',
|
|
||||||
'tool_lp/dragdrop-reorder'],
|
|
||||||
function($, str, notification, ajax, dragdrop) {
|
|
||||||
// Private variables and functions.
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle a drop on a node.
|
|
||||||
*
|
|
||||||
* @method handleDrop
|
|
||||||
* @param {DOMNode} drag
|
|
||||||
* @param {DOMNode} drop
|
|
||||||
*/
|
|
||||||
var handleDrop = function(drag, drop) {
|
|
||||||
var from = $(drag).data('frameworkid');
|
|
||||||
var to = $(drop).data('frameworkid');
|
|
||||||
|
|
||||||
var requests = ajax.call([{
|
|
||||||
methodname: 'tool_lp_reorder_competency_framework',
|
|
||||||
args: { from: from, to: to }
|
|
||||||
}]);
|
|
||||||
requests[0].fail(notification.exception);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
return /** @alias module:tool_lp/frameworkmove */ {
|
|
||||||
// Public variables and functions.
|
|
||||||
/**
|
|
||||||
* Initialise this plugin. It loads some strings, then adds the drag/drop functions.
|
|
||||||
* @method init
|
|
||||||
*/
|
|
||||||
init: function() {
|
|
||||||
// Init this module.
|
|
||||||
str.get_string('movecompetencyframework', 'tool_lp').done(
|
|
||||||
function(movestring) {
|
|
||||||
dragdrop.dragdrop('movecompetencyframework',
|
|
||||||
movestring,
|
|
||||||
{ identifier: 'movecompetencyframework', component: 'tool_lp'},
|
|
||||||
{ identifier: 'movecompetencyframeworkafter', component: 'tool_lp'},
|
|
||||||
'drag-samenode',
|
|
||||||
'drag-parentnode',
|
|
||||||
'drag-handlecontainer',
|
|
||||||
handleDrop);
|
|
||||||
}
|
|
||||||
).fail(notification.exception);
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
});
|
|
|
@ -24,6 +24,8 @@
|
||||||
namespace tool_lp;
|
namespace tool_lp;
|
||||||
|
|
||||||
use stdClass;
|
use stdClass;
|
||||||
|
use context;
|
||||||
|
use context_helper;
|
||||||
use context_system;
|
use context_system;
|
||||||
use context_course;
|
use context_course;
|
||||||
use context_user;
|
use context_user;
|
||||||
|
@ -47,11 +49,12 @@ class api {
|
||||||
* @return competency
|
* @return competency
|
||||||
*/
|
*/
|
||||||
public static function create_competency(stdClass $record) {
|
public static function create_competency(stdClass $record) {
|
||||||
|
$competency = new competency(0, $record);
|
||||||
|
|
||||||
// First we do a permissions check.
|
// First we do a permissions check.
|
||||||
require_capability('tool/lp:competencymanage', context_system::instance());
|
require_capability('tool/lp:competencymanage', $competency->get_framework()->get_context());
|
||||||
|
|
||||||
// OK - all set.
|
// OK - all set.
|
||||||
$competency = new competency(0, $record);
|
|
||||||
$id = $competency->create();
|
$id = $competency->create();
|
||||||
return $competency;
|
return $competency;
|
||||||
}
|
}
|
||||||
|
@ -65,11 +68,12 @@ class api {
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static function delete_competency($id) {
|
public static function delete_competency($id) {
|
||||||
|
$competency = new competency($id);
|
||||||
|
|
||||||
// First we do a permissions check.
|
// First we do a permissions check.
|
||||||
require_capability('tool/lp:competencymanage', context_system::instance());
|
require_capability('tool/lp:competencymanage', $competency->get_framework()->get_context());
|
||||||
|
|
||||||
// OK - all set.
|
// OK - all set.
|
||||||
$competency = new competency();
|
|
||||||
$competency->set_id($id);
|
$competency->set_id($id);
|
||||||
return $competency->delete();
|
return $competency->delete();
|
||||||
}
|
}
|
||||||
|
@ -83,12 +87,11 @@ class api {
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static function move_down_competency($id) {
|
public static function move_down_competency($id) {
|
||||||
// First we do a permissions check.
|
|
||||||
require_capability('tool/lp:competencymanage', context_system::instance());
|
|
||||||
|
|
||||||
// Check the current one too.
|
|
||||||
$current = new competency($id);
|
$current = new competency($id);
|
||||||
|
|
||||||
|
// First we do a permissions check.
|
||||||
|
require_capability('tool/lp:competencymanage', $current->get_framework()->get_context());
|
||||||
|
|
||||||
$max = self::count_competencies(array('parentid' => $current->get_parentid(),
|
$max = self::count_competencies(array('parentid' => $current->get_parentid(),
|
||||||
'competencyframeworkid' => $current->get_competencyframeworkid()));
|
'competencyframeworkid' => $current->get_competencyframeworkid()));
|
||||||
if ($max > 0) {
|
if ($max > 0) {
|
||||||
|
@ -124,12 +127,11 @@ class api {
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static function move_up_competency($id) {
|
public static function move_up_competency($id) {
|
||||||
// First we do a permissions check.
|
|
||||||
require_capability('tool/lp:competencymanage', context_system::instance());
|
|
||||||
|
|
||||||
// Check the current one too.
|
|
||||||
$current = new competency($id);
|
$current = new competency($id);
|
||||||
|
|
||||||
|
// First we do a permissions check.
|
||||||
|
require_capability('tool/lp:competencymanage', $current->get_framework()->get_context());
|
||||||
|
|
||||||
$sortorder = $current->get_sortorder();
|
$sortorder = $current->get_sortorder();
|
||||||
if ($sortorder == 0) {
|
if ($sortorder == 0) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -161,13 +163,14 @@ class api {
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static function set_parent_competency($id, $newparentid) {
|
public static function set_parent_competency($id, $newparentid) {
|
||||||
|
$current = new competency($id);
|
||||||
|
|
||||||
// First we do a permissions check.
|
// First we do a permissions check.
|
||||||
require_capability('tool/lp:competencymanage', context_system::instance());
|
require_capability('tool/lp:competencymanage', $current->get_framework()->get_context());
|
||||||
|
|
||||||
// This will throw an exception if the parent does not exist.
|
// This will throw an exception if the parent does not exist.
|
||||||
|
|
||||||
// Check the current one too.
|
// Check the current one too.
|
||||||
$current = new competency($id);
|
|
||||||
$parentframeworkid = $current->get_competencyframeworkid();
|
$parentframeworkid = $current->get_competencyframeworkid();
|
||||||
$parentpath = '/0/';
|
$parentpath = '/0/';
|
||||||
if ($newparentid) {
|
if ($newparentid) {
|
||||||
|
@ -211,17 +214,20 @@ class api {
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static function update_competency($record) {
|
public static function update_competency($record) {
|
||||||
|
$current = new competency($record->id);
|
||||||
|
|
||||||
// First we do a permissions check.
|
// First we do a permissions check.
|
||||||
require_capability('tool/lp:competencymanage', context_system::instance());
|
require_capability('tool/lp:competencymanage', $current->get_framework()->get_context());
|
||||||
|
|
||||||
// Some things should not be changed in an update - they should use a more specific method.
|
// Some things should not be changed in an update - they should use a more specific method.
|
||||||
$current = new competency($record->id);
|
|
||||||
$record->sortorder = $current->get_sortorder();
|
$record->sortorder = $current->get_sortorder();
|
||||||
$record->parentid = $current->get_parentid();
|
$record->parentid = $current->get_parentid();
|
||||||
$record->competencyframeworkid = $current->get_competencyframeworkid();
|
$record->competencyframeworkid = $current->get_competencyframeworkid();
|
||||||
|
|
||||||
// OK - all set.
|
|
||||||
$competency = new competency(0, $record);
|
$competency = new competency(0, $record);
|
||||||
|
require_capability('tool/lp:competencymanage', $competency->get_framework()->get_context());
|
||||||
|
|
||||||
|
// OK - all set.
|
||||||
return $competency->update();
|
return $competency->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,14 +240,16 @@ class api {
|
||||||
* @return stdClass
|
* @return stdClass
|
||||||
*/
|
*/
|
||||||
public static function read_competency($id) {
|
public static function read_competency($id) {
|
||||||
|
$competency = new competency($id);
|
||||||
|
|
||||||
// First we do a permissions check.
|
// First we do a permissions check.
|
||||||
$context = context_system::instance();
|
$context = $competency->get_framework()->get_context();
|
||||||
if (!has_any_capability(array('tool/lp:competencyread', 'tool/lp:competencymanage'), $context)) {
|
if (!has_any_capability(array('tool/lp:competencyread', 'tool/lp:competencymanage'), $context)) {
|
||||||
throw new required_capability_exception($context, 'tool/lp:competencyread', 'nopermissions', '');
|
throw new required_capability_exception($context, 'tool/lp:competencyread', 'nopermissions', '');
|
||||||
}
|
}
|
||||||
|
|
||||||
// OK - all set.
|
// OK - all set.
|
||||||
return new competency($id);
|
return $competency;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -254,8 +262,10 @@ class api {
|
||||||
* @return array of competencies
|
* @return array of competencies
|
||||||
*/
|
*/
|
||||||
public static function search_competencies($textsearch, $competencyframeworkid) {
|
public static function search_competencies($textsearch, $competencyframeworkid) {
|
||||||
|
$framework = new competency_framework($competencyframeworkid);
|
||||||
|
|
||||||
// First we do a permissions check.
|
// First we do a permissions check.
|
||||||
$context = context_system::instance();
|
$context = $framework->get_context();
|
||||||
if (!has_any_capability(array('tool/lp:competencyread', 'tool/lp:competencymanage'), $context)) {
|
if (!has_any_capability(array('tool/lp:competencyread', 'tool/lp:competencymanage'), $context)) {
|
||||||
throw new required_capability_exception($context, 'tool/lp:competencyread', 'nopermissions', '');
|
throw new required_capability_exception($context, 'tool/lp:competencyread', 'nopermissions', '');
|
||||||
}
|
}
|
||||||
|
@ -268,7 +278,7 @@ class api {
|
||||||
/**
|
/**
|
||||||
* Perform a search based on the provided filters and return a paginated list of records.
|
* Perform a search based on the provided filters and return a paginated list of records.
|
||||||
*
|
*
|
||||||
* Requires tool/lp:competencyread capability at the system context.
|
* Requires tool/lp:competencyread capability at some context.
|
||||||
*
|
*
|
||||||
* @param array $filters A list of filters to apply to the list.
|
* @param array $filters A list of filters to apply to the list.
|
||||||
* @param string $sort The column to sort on
|
* @param string $sort The column to sort on
|
||||||
|
@ -278,8 +288,14 @@ class api {
|
||||||
* @return array of competencies
|
* @return array of competencies
|
||||||
*/
|
*/
|
||||||
public static function list_competencies($filters, $sort = '', $order = 'ASC', $skip = 0, $limit = 0) {
|
public static function list_competencies($filters, $sort = '', $order = 'ASC', $skip = 0, $limit = 0) {
|
||||||
|
if (!isset($filters['competencyframeworkid'])) {
|
||||||
|
$context = context_system::instance();
|
||||||
|
} else {
|
||||||
|
$framework = new competency_framework($filters['competencyframeworkid']);
|
||||||
|
$context = $framework->get_context();
|
||||||
|
}
|
||||||
|
|
||||||
// First we do a permissions check.
|
// First we do a permissions check.
|
||||||
$context = context_system::instance();
|
|
||||||
if (!has_any_capability(array('tool/lp:competencyread', 'tool/lp:competencymanage'), $context)) {
|
if (!has_any_capability(array('tool/lp:competencyread', 'tool/lp:competencymanage'), $context)) {
|
||||||
throw new required_capability_exception($context, 'tool/lp:competencyread', 'nopermissions', '');
|
throw new required_capability_exception($context, 'tool/lp:competencyread', 'nopermissions', '');
|
||||||
}
|
}
|
||||||
|
@ -292,14 +308,20 @@ class api {
|
||||||
/**
|
/**
|
||||||
* Perform a search based on the provided filters and return a paginated list of records.
|
* Perform a search based on the provided filters and return a paginated list of records.
|
||||||
*
|
*
|
||||||
* Requires tool/lp:competencyread capability at the system context.
|
* Requires tool/lp:competencyread capability at some context.
|
||||||
*
|
*
|
||||||
* @param array $filters A list of filters to apply to the list.
|
* @param array $filters A list of filters to apply to the list.
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public static function count_competencies($filters) {
|
public static function count_competencies($filters) {
|
||||||
|
if (!isset($filters['competencyframeworkid'])) {
|
||||||
|
$context = context_system::instance();
|
||||||
|
} else {
|
||||||
|
$framework = new competency_framework($filters['competencyframeworkid']);
|
||||||
|
$context = $framework->get_context();
|
||||||
|
}
|
||||||
|
|
||||||
// First we do a permissions check.
|
// First we do a permissions check.
|
||||||
$context = context_system::instance();
|
|
||||||
if (!has_any_capability(array('tool/lp:competencyread', 'tool/lp:competencymanage'), $context)) {
|
if (!has_any_capability(array('tool/lp:competencyread', 'tool/lp:competencymanage'), $context)) {
|
||||||
throw new required_capability_exception($context, 'tool/lp:competencyread', 'nopermissions', '');
|
throw new required_capability_exception($context, 'tool/lp:competencyread', 'nopermissions', '');
|
||||||
}
|
}
|
||||||
|
@ -318,11 +340,8 @@ class api {
|
||||||
* @return competency_framework
|
* @return competency_framework
|
||||||
*/
|
*/
|
||||||
public static function create_framework(stdClass $record) {
|
public static function create_framework(stdClass $record) {
|
||||||
// First we do a permissions check.
|
|
||||||
require_capability('tool/lp:competencymanage', context_system::instance());
|
|
||||||
|
|
||||||
// OK - all set.
|
|
||||||
$framework = new competency_framework(0, $record);
|
$framework = new competency_framework(0, $record);
|
||||||
|
require_capability('tool/lp:competencymanage', $framework->get_context());
|
||||||
$id = $framework->create();
|
$id = $framework->create();
|
||||||
return $framework;
|
return $framework;
|
||||||
}
|
}
|
||||||
|
@ -336,12 +355,8 @@ class api {
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static function delete_framework($id) {
|
public static function delete_framework($id) {
|
||||||
// First we do a permissions check.
|
$framework = new competency_framework($id);
|
||||||
require_capability('tool/lp:competencymanage', context_system::instance());
|
require_capability('tool/lp:competencymanage', $framework->get_context());
|
||||||
|
|
||||||
// OK - all set.
|
|
||||||
$framework = new competency_framework();
|
|
||||||
$framework->set_id($id);
|
|
||||||
return $framework->delete();
|
return $framework->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -354,11 +369,13 @@ class api {
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static function update_framework($record) {
|
public static function update_framework($record) {
|
||||||
// First we do a permissions check.
|
$framework = new competency_framework($record->id);
|
||||||
require_capability('tool/lp:competencymanage', context_system::instance());
|
// Check the permissions before update.
|
||||||
|
require_capability('tool/lp:competencymanage', $framework->get_context());
|
||||||
// OK - all set.
|
if (isset($record->contextid) && $record->contextid != $framework->get_contextid()) {
|
||||||
$framework = new competency_framework(0, $record);
|
throw new coding_exception('Changing the context of an existing framework is forbidden.');
|
||||||
|
}
|
||||||
|
$framework->from_record($record);
|
||||||
return $framework->update();
|
return $framework->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -371,51 +388,11 @@ class api {
|
||||||
* @return competency_framework
|
* @return competency_framework
|
||||||
*/
|
*/
|
||||||
public static function read_framework($id) {
|
public static function read_framework($id) {
|
||||||
// First we do a permissions check.
|
$framework = new competency_framework($id);
|
||||||
$context = context_system::instance();
|
if (!has_any_capability(array('tool/lp:competencyread', 'tool/lp:competencymanage'), $framework->get_context())) {
|
||||||
if (!has_any_capability(array('tool/lp:competencyread', 'tool/lp:competencymanage'), $context)) {
|
throw new required_capability_exception($framework->get_context(), 'tool/lp:competencyread', 'nopermissions', '');
|
||||||
throw new required_capability_exception($context, 'tool/lp:competencyread', 'nopermissions', '');
|
|
||||||
}
|
}
|
||||||
|
return $framework;
|
||||||
// OK - all set.
|
|
||||||
return new competency_framework($id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Move the competency framework up or down in the display list.
|
|
||||||
*
|
|
||||||
* Requires tool/lp:competencymanage capability at the system context.
|
|
||||||
*
|
|
||||||
* @param int $frameworkidfrom The framework we are moving.
|
|
||||||
* @param int $frameworkidto Where we are moving to. If moving down, it will go after this framework,
|
|
||||||
* If moving up, it will go before this framework.
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
public static function reorder_framework($frameworkidfrom, $frameworkidto) {
|
|
||||||
require_capability('tool/lp:competencymanage', context_system::instance());
|
|
||||||
$down = true;
|
|
||||||
$frameworkfrom = new competency_framework($frameworkidfrom);
|
|
||||||
$frameworkto = new competency_framework($frameworkidto);
|
|
||||||
|
|
||||||
$all = self::list_frameworks(array(), 'sortorder', 'ASC', 0, 0);
|
|
||||||
|
|
||||||
if ($frameworkfrom->get_sortorder() > $frameworkto->get_sortorder()) {
|
|
||||||
// We are moving down, so put it after the "to" item.
|
|
||||||
$down = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($all as $id => $framework) {
|
|
||||||
$sort = $framework->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()) {
|
|
||||||
$framework->set_sortorder($framework->get_sortorder() + 1);
|
|
||||||
$framework->update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$frameworkfrom->set_sortorder($frameworkto->get_sortorder());
|
|
||||||
return $frameworkfrom->update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -423,23 +400,62 @@ class api {
|
||||||
*
|
*
|
||||||
* Requires tool/lp:competencyread capability at the system context.
|
* Requires tool/lp:competencyread capability at the system context.
|
||||||
*
|
*
|
||||||
* @param array $filters A list of filters to apply to the list.
|
|
||||||
* @param string $sort The column to sort on
|
* @param string $sort The column to sort on
|
||||||
* @param string $order ('ASC' or 'DESC')
|
* @param string $order ('ASC' or 'DESC')
|
||||||
* @param int $skip Number of records to skip (pagination)
|
* @param int $skip Number of records to skip (pagination)
|
||||||
* @param int $limit Max of records to return (pagination)
|
* @param int $limit Max of records to return (pagination)
|
||||||
|
* @param context $context The parent context of the frameworks.
|
||||||
|
* @param string $includes Defines what other contexts to fetch frameworks from.
|
||||||
|
* Accepted values are:
|
||||||
|
* - children: All descendants
|
||||||
|
* - parents: All parents, grand parents, etc...
|
||||||
|
* - self: Context passed only.
|
||||||
* @return array of competency_framework
|
* @return array of competency_framework
|
||||||
*/
|
*/
|
||||||
public static function list_frameworks($filters, $sort, $order, $skip, $limit) {
|
public static function list_frameworks($sort, $order, $skip, $limit, $context, $includes = 'children') {
|
||||||
|
global $DB;
|
||||||
|
|
||||||
|
if (!in_array($includes, array('children', 'parents', 'self'))) {
|
||||||
|
throw new coding_exception('Invalid parameter value for \'includes\'.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get all the other relevant contexts.
|
||||||
|
$contexts = array($context->id => $context);
|
||||||
|
|
||||||
|
if ($includes == 'children') {
|
||||||
|
$params = array('coursecatlevel' => CONTEXT_COURSECAT, 'path' => $context->path . '/%');
|
||||||
|
$pathlike = $DB->sql_like('path', ':path');
|
||||||
|
$sql = "contextlevel = :coursecatlevel AND $pathlike";
|
||||||
|
$rs = $DB->get_recordset_select('context', $sql, $params);
|
||||||
|
foreach ($rs as $record) {
|
||||||
|
$ctxid = $record->id;
|
||||||
|
context_helper::preload_from_record($record);
|
||||||
|
$contexts[$ctxid] = context::instance_by_id($ctxid);
|
||||||
|
}
|
||||||
|
$rs->close();
|
||||||
|
|
||||||
|
} else if ($includes == 'parents') {
|
||||||
|
$children = $context->get_parent_contexts();
|
||||||
|
foreach ($children as $ctx) {
|
||||||
|
$contexts[$ctx->id] = $ctx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// First we do a permissions check.
|
// First we do a permissions check.
|
||||||
$context = context_system::instance();
|
foreach ($contexts as $key => $ctx) {
|
||||||
if (!has_any_capability(array('tool/lp:competencyread', 'tool/lp:competencymanage'), $context)) {
|
if (!has_any_capability(array('tool/lp:competencyread', 'tool/lp:competencymanage'), $ctx)) {
|
||||||
throw new required_capability_exception($context, 'tool/lp:competencyread', 'nopermissions', '');
|
unset($contexts[$key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($contexts)) {
|
||||||
|
throw new required_capability_exception($context, 'tool/lp:competencyread', 'nopermissions', '');
|
||||||
}
|
}
|
||||||
|
|
||||||
// OK - all set.
|
// OK - all set.
|
||||||
$framework = new competency_framework();
|
$framework = new competency_framework();
|
||||||
return $framework->get_records($filters, $sort, $order, $skip, $limit);
|
list($insql, $inparams) = $DB->get_in_or_equal(array_keys($contexts), SQL_PARAMS_NAMED);
|
||||||
|
return $framework->get_records_select("contextid $insql", $inparams, $sort, '*', $skip, $limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -214,6 +214,15 @@ class competency extends persistent {
|
||||||
$this->path = $path;
|
$this->path = $path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the competencyframeworkid
|
||||||
|
*
|
||||||
|
* @return int The competency framework id.
|
||||||
|
*/
|
||||||
|
public function get_framework() {
|
||||||
|
return new competency_framework($this->get_competencyframeworkid());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the competencyframeworkid
|
* Get the competencyframeworkid
|
||||||
*
|
*
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
namespace tool_lp;
|
namespace tool_lp;
|
||||||
|
|
||||||
use stdClass;
|
use stdClass;
|
||||||
|
use context;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class for loading/storing competency frameworks from the DB.
|
* Class for loading/storing competency frameworks from the DB.
|
||||||
|
@ -57,6 +58,9 @@ class competency_framework extends persistent {
|
||||||
/** @var string $scaleconfiguration scale information relevant to this framework*/
|
/** @var string $scaleconfiguration scale information relevant to this framework*/
|
||||||
private $scaleconfiguration = '';
|
private $scaleconfiguration = '';
|
||||||
|
|
||||||
|
/** @var int $contextid The context ID in which the framework is set. */
|
||||||
|
private $contextid = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method that provides the table name matching this class.
|
* Method that provides the table name matching this class.
|
||||||
*
|
*
|
||||||
|
@ -173,6 +177,24 @@ class competency_framework extends persistent {
|
||||||
$this->visible = $visible;
|
$this->visible = $visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the context.
|
||||||
|
*
|
||||||
|
* @return context The context
|
||||||
|
*/
|
||||||
|
public function get_context() {
|
||||||
|
return context::instance_by_id($this->contextid);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the contextid.
|
||||||
|
*
|
||||||
|
* @return string The contextid
|
||||||
|
*/
|
||||||
|
public function get_contextid() {
|
||||||
|
return $this->contextid;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the scale ID.
|
* Get the scale ID.
|
||||||
*
|
*
|
||||||
|
@ -252,6 +274,9 @@ class competency_framework extends persistent {
|
||||||
if (isset($record->usermodified)) {
|
if (isset($record->usermodified)) {
|
||||||
$this->set_usermodified($record->usermodified);
|
$this->set_usermodified($record->usermodified);
|
||||||
}
|
}
|
||||||
|
if (isset($record->contextid)) {
|
||||||
|
$this->contextid = $record->contextid;
|
||||||
|
}
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,6 +300,7 @@ class competency_framework extends persistent {
|
||||||
$record->timecreated = $this->get_timecreated();
|
$record->timecreated = $this->get_timecreated();
|
||||||
$record->timemodified = $this->get_timemodified();
|
$record->timemodified = $this->get_timemodified();
|
||||||
$record->usermodified = $this->get_usermodified();
|
$record->usermodified = $this->get_usermodified();
|
||||||
|
$record->contextid = $this->get_contextid();
|
||||||
|
|
||||||
return $record;
|
return $record;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ namespace tool_lp;
|
||||||
require_once("$CFG->libdir/externallib.php");
|
require_once("$CFG->libdir/externallib.php");
|
||||||
require_once("$CFG->libdir/grade/grade_scale.php");
|
require_once("$CFG->libdir/grade/grade_scale.php");
|
||||||
|
|
||||||
|
use context;
|
||||||
use external_api;
|
use external_api;
|
||||||
use external_function_parameters;
|
use external_function_parameters;
|
||||||
use external_value;
|
use external_value;
|
||||||
|
@ -90,6 +91,36 @@ class external extends external_api {
|
||||||
return new external_function_parameters($params);
|
return new external_function_parameters($params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a prepared structure to use a context parameters.
|
||||||
|
* @return external_single_structure
|
||||||
|
*/
|
||||||
|
protected static function get_context_parameters() {
|
||||||
|
$id = new external_value(
|
||||||
|
PARAM_INT,
|
||||||
|
'Context ID. Either use this value, or level and instanceid.',
|
||||||
|
VALUE_DEFAULT,
|
||||||
|
0
|
||||||
|
);
|
||||||
|
$level = new external_value(
|
||||||
|
PARAM_ALPHA,
|
||||||
|
'Context level. To be used with instanceid.',
|
||||||
|
VALUE_DEFAULT,
|
||||||
|
''
|
||||||
|
);
|
||||||
|
$instanceid = new external_value(
|
||||||
|
PARAM_INT,
|
||||||
|
'Context instance ID. To be used with level',
|
||||||
|
VALUE_DEFAULT,
|
||||||
|
0
|
||||||
|
);
|
||||||
|
return new external_single_structure(array(
|
||||||
|
'contextid' => $id,
|
||||||
|
'contextlevel' => $level,
|
||||||
|
'instanceid' => $instanceid,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns description of a generic count_x() parameters.
|
* Returns description of a generic count_x() parameters.
|
||||||
*
|
*
|
||||||
|
@ -216,6 +247,7 @@ class external extends external_api {
|
||||||
'description' => $description,
|
'description' => $description,
|
||||||
'descriptionformat' => $descriptionformat,
|
'descriptionformat' => $descriptionformat,
|
||||||
'visible' => $visible,
|
'visible' => $visible,
|
||||||
|
'context' => self::get_context_parameters(),
|
||||||
);
|
);
|
||||||
return new external_function_parameters($params);
|
return new external_function_parameters($params);
|
||||||
}
|
}
|
||||||
|
@ -238,7 +270,8 @@ class external extends external_api {
|
||||||
* @param bool $visible Is this framework visible.
|
* @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) {
|
public static function create_competency_framework($shortname, $idnumber, $description, $descriptionformat, $visible,
|
||||||
|
$context) {
|
||||||
$params = self::validate_parameters(self::create_competency_framework_parameters(),
|
$params = self::validate_parameters(self::create_competency_framework_parameters(),
|
||||||
array(
|
array(
|
||||||
'shortname' => $shortname,
|
'shortname' => $shortname,
|
||||||
|
@ -246,10 +279,17 @@ class external extends external_api {
|
||||||
'description' => $description,
|
'description' => $description,
|
||||||
'descriptionformat' => $descriptionformat,
|
'descriptionformat' => $descriptionformat,
|
||||||
'visible' => $visible,
|
'visible' => $visible,
|
||||||
|
'context' => $context,
|
||||||
));
|
));
|
||||||
|
|
||||||
$params = (object) $params;
|
|
||||||
|
|
||||||
|
$context = self::get_context_from_params($params['context']);
|
||||||
|
self::validate_context($context);
|
||||||
|
|
||||||
|
unset($params['context']);
|
||||||
|
$params['contextid'] = $context->id;
|
||||||
|
|
||||||
|
$params = (object) $params;
|
||||||
$result = api::create_framework($params);
|
$result = api::create_framework($params);
|
||||||
return $result->to_record();
|
return $result->to_record();
|
||||||
}
|
}
|
||||||
|
@ -466,7 +506,46 @@ class external extends external_api {
|
||||||
* @return \external_function_parameters
|
* @return \external_function_parameters
|
||||||
*/
|
*/
|
||||||
public static function list_competency_frameworks_parameters() {
|
public static function list_competency_frameworks_parameters() {
|
||||||
return self::list_parameters_structure();
|
$sort = new external_value(
|
||||||
|
PARAM_ALPHANUMEXT,
|
||||||
|
'Column to sort by.',
|
||||||
|
VALUE_DEFAULT,
|
||||||
|
''
|
||||||
|
);
|
||||||
|
$order = new external_value(
|
||||||
|
PARAM_ALPHA,
|
||||||
|
'Sort direction. Should be either ASC or DESC',
|
||||||
|
VALUE_DEFAULT,
|
||||||
|
''
|
||||||
|
);
|
||||||
|
$skip = new external_value(
|
||||||
|
PARAM_INT,
|
||||||
|
'Skip this number of records before returning results',
|
||||||
|
VALUE_DEFAULT,
|
||||||
|
0
|
||||||
|
);
|
||||||
|
$limit = new external_value(
|
||||||
|
PARAM_INT,
|
||||||
|
'Return this number of records at most.',
|
||||||
|
VALUE_DEFAULT,
|
||||||
|
0
|
||||||
|
);
|
||||||
|
$includes = new external_value(
|
||||||
|
PARAM_ALPHA,
|
||||||
|
'What other contextes to fetch the frameworks from. (children, parents, self)',
|
||||||
|
VALUE_DEFAULT,
|
||||||
|
'children'
|
||||||
|
);
|
||||||
|
|
||||||
|
$params = array(
|
||||||
|
'sort' => $sort,
|
||||||
|
'order' => $order,
|
||||||
|
'skip' => $skip,
|
||||||
|
'limit' => $limit,
|
||||||
|
'context' => self::get_context_parameters(),
|
||||||
|
'includes' => $includes
|
||||||
|
);
|
||||||
|
return new external_function_parameters($params);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -485,39 +564,37 @@ class external extends external_api {
|
||||||
* @param string $order
|
* @param string $order
|
||||||
* @param string $skip
|
* @param string $skip
|
||||||
* @param int $limit
|
* @param int $limit
|
||||||
|
* @param array $context
|
||||||
|
* @param bool $includes
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
* @throws \required_capability_exception
|
* @throws \required_capability_exception
|
||||||
* @throws invalid_parameter_exception
|
* @throws invalid_parameter_exception
|
||||||
*/
|
*/
|
||||||
public static function list_competency_frameworks($filters, $sort, $order, $skip, $limit) {
|
public static function list_competency_frameworks($sort, $order, $skip, $limit, $context, $includes) {
|
||||||
$params = self::validate_parameters(self::list_competency_frameworks_parameters(),
|
$params = self::validate_parameters(self::list_competency_frameworks_parameters(),
|
||||||
array(
|
array(
|
||||||
'filters' => $filters,
|
|
||||||
'sort' => $sort,
|
'sort' => $sort,
|
||||||
'order' => $order,
|
'order' => $order,
|
||||||
'skip' => $skip,
|
'skip' => $skip,
|
||||||
'limit' => $limit
|
'limit' => $limit,
|
||||||
|
'context' => $context,
|
||||||
|
'includes' => $includes
|
||||||
));
|
));
|
||||||
|
|
||||||
|
$context = self::get_context_from_params($params['context']);
|
||||||
|
self::validate_context($context);
|
||||||
|
|
||||||
if ($params['order'] !== '' && $params['order'] !== 'ASC' && $params['order'] !== 'DESC') {
|
if ($params['order'] !== '' && $params['order'] !== 'ASC' && $params['order'] !== 'DESC') {
|
||||||
throw new invalid_parameter_exception('Invalid order param. Must be ASC, DESC or empty.');
|
throw new invalid_parameter_exception('Invalid order param. Must be ASC, DESC or empty.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$safefilters = array();
|
$results = api::list_frameworks($params['sort'],
|
||||||
$validcolumns = array('id', 'shortname', 'description', 'sortorder', 'idnumber', 'visible');
|
$params['order'],
|
||||||
foreach ($params['filters'] as $filter) {
|
$params['skip'],
|
||||||
if (!in_array($filter->column, $validcolumns)) {
|
$params['limit'],
|
||||||
throw new invalid_parameter_exception('Filter column was invalid');
|
$context,
|
||||||
}
|
$params['includes']);
|
||||||
$safefilters[$filter->column] = $filter->value;
|
|
||||||
}
|
|
||||||
|
|
||||||
$results = api::list_frameworks($safefilters,
|
|
||||||
$params['sort'],
|
|
||||||
$params['order'],
|
|
||||||
$params['skip'],
|
|
||||||
$params['limit']);
|
|
||||||
$records = array();
|
$records = array();
|
||||||
foreach ($results as $result) {
|
foreach ($results as $result) {
|
||||||
$record = $result->to_record();
|
$record = $result->to_record();
|
||||||
|
@ -601,8 +678,7 @@ class external extends external_api {
|
||||||
* @return \external_function_parameters
|
* @return \external_function_parameters
|
||||||
*/
|
*/
|
||||||
public static function data_for_competency_frameworks_manage_page_parameters() {
|
public static function data_for_competency_frameworks_manage_page_parameters() {
|
||||||
// No params required.
|
$params = array('pagecontext' => self::get_context_parameters());
|
||||||
$params = array();
|
|
||||||
return new external_function_parameters($params);
|
return new external_function_parameters($params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -619,10 +695,19 @@ class external extends external_api {
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static function data_for_competency_frameworks_manage_page() {
|
public static function data_for_competency_frameworks_manage_page($pagecontext) {
|
||||||
global $PAGE;
|
global $PAGE;
|
||||||
|
|
||||||
$renderable = new output\manage_competency_frameworks_page();
|
$params = self::validate_parameters(
|
||||||
|
self::data_for_competency_frameworks_manage_page_parameters(),
|
||||||
|
array(
|
||||||
|
'pagecontext' => $pagecontext
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$context = self::get_context_from_params($params['pagecontext']);
|
||||||
|
self::validate_context($context);
|
||||||
|
|
||||||
|
$renderable = new output\manage_competency_frameworks_page($context);
|
||||||
$renderer = $PAGE->get_renderer('tool_lp');
|
$renderer = $PAGE->get_renderer('tool_lp');
|
||||||
|
|
||||||
$data = $renderable->export_for_template($renderer);
|
$data = $renderable->export_for_template($renderer);
|
||||||
|
@ -649,62 +734,6 @@ class external extends external_api {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Move a competency framework and adjust sort order of all affected.
|
|
||||||
*
|
|
||||||
* @return \external_function_parameters
|
|
||||||
*/
|
|
||||||
public static function reorder_competency_framework_parameters() {
|
|
||||||
$from = new external_value(
|
|
||||||
PARAM_INT,
|
|
||||||
'Framework id to reorder.',
|
|
||||||
VALUE_REQUIRED
|
|
||||||
);
|
|
||||||
$to = new external_value(
|
|
||||||
PARAM_INT,
|
|
||||||
'Framework id to move to.',
|
|
||||||
VALUE_REQUIRED
|
|
||||||
);
|
|
||||||
$params = array(
|
|
||||||
'from' => $from,
|
|
||||||
'to' => $to
|
|
||||||
);
|
|
||||||
return new external_function_parameters($params);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Expose to AJAX
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
public static function reorder_competency_framework_is_allowed_from_ajax() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Move this competency_framework to a new relative sort order.
|
|
||||||
*
|
|
||||||
* @param int $from
|
|
||||||
* @param int $to
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
public static function reorder_competency_framework($from, $to) {
|
|
||||||
$params = self::validate_parameters(self::reorder_competency_framework_parameters(),
|
|
||||||
array(
|
|
||||||
'from' => $from,
|
|
||||||
'to' => $to
|
|
||||||
));
|
|
||||||
return api::reorder_framework($params['from'], $params['to']);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns description of reorder_competency_framework return value.
|
|
||||||
*
|
|
||||||
* @return \external_description
|
|
||||||
*/
|
|
||||||
public static function reorder_competency_framework_returns() {
|
|
||||||
return new external_value(PARAM_BOOL, 'True if this framework was moved.');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the external structure of a full competency record.
|
* Returns the external structure of a full competency record.
|
||||||
*
|
*
|
||||||
|
@ -1342,7 +1371,7 @@ class external extends external_api {
|
||||||
|
|
||||||
$framework = new competency_framework($params['competencyframeworkid']);
|
$framework = new competency_framework($params['competencyframeworkid']);
|
||||||
|
|
||||||
$renderable = new output\manage_competencies_page($framework, $params['search']);
|
$renderable = new output\manage_competencies_page($framework, $params['search'], $framework->get_context());
|
||||||
$renderer = $PAGE->get_renderer('tool_lp');
|
$renderer = $PAGE->get_renderer('tool_lp');
|
||||||
|
|
||||||
$data = $renderable->export_for_template($renderer);
|
$data = $renderable->export_for_template($renderer);
|
||||||
|
|
|
@ -47,7 +47,8 @@ class competency_framework extends moodleform {
|
||||||
global $PAGE;
|
global $PAGE;
|
||||||
|
|
||||||
$mform = $this->_form;
|
$mform = $this->_form;
|
||||||
$id = $this->_customdata;
|
$id = $this->_customdata['id'];
|
||||||
|
$context = $this->_customdata['context'];
|
||||||
|
|
||||||
$mform->addElement('hidden', 'id');
|
$mform->addElement('hidden', 'id');
|
||||||
$mform->setType('id', PARAM_INT);
|
$mform->setType('id', PARAM_INT);
|
||||||
|
@ -81,6 +82,9 @@ class competency_framework extends moodleform {
|
||||||
$mform->setDefault('visible', true);
|
$mform->setDefault('visible', true);
|
||||||
$mform->addHelpButton('visible', 'visible', 'tool_lp');
|
$mform->addHelpButton('visible', 'visible', 'tool_lp');
|
||||||
|
|
||||||
|
$mform->addElement('static', 'context', get_string('context', 'core_role'));
|
||||||
|
$mform->setDefault('context', $context->get_context_name());
|
||||||
|
|
||||||
$this->add_action_buttons(true, get_string('savechanges', 'tool_lp'));
|
$this->add_action_buttons(true, get_string('savechanges', 'tool_lp'));
|
||||||
|
|
||||||
if (!empty($id)) {
|
if (!empty($id)) {
|
||||||
|
|
|
@ -43,6 +43,9 @@ class course_competencies_page implements renderable, templatable {
|
||||||
/** @var int $courseid Course id for this page. */
|
/** @var int $courseid Course id for this page. */
|
||||||
protected $courseid = null;
|
protected $courseid = null;
|
||||||
|
|
||||||
|
/** @var context $context The context for this page. */
|
||||||
|
protected $context = null;
|
||||||
|
|
||||||
/** @var \tool_lp\competency[] $competencies List of competencies. */
|
/** @var \tool_lp\competency[] $competencies List of competencies. */
|
||||||
protected $competencies = array();
|
protected $competencies = array();
|
||||||
|
|
||||||
|
@ -60,12 +63,24 @@ class course_competencies_page implements renderable, templatable {
|
||||||
* @param int $courseid The course record for this page.
|
* @param int $courseid The course record for this page.
|
||||||
*/
|
*/
|
||||||
public function __construct($courseid) {
|
public function __construct($courseid) {
|
||||||
$context = context_course::instance($courseid);
|
$this->context = context_course::instance($courseid);
|
||||||
$this->courseid = $courseid;
|
$this->courseid = $courseid;
|
||||||
$this->competencies = api::list_competencies_in_course($courseid);
|
$this->competencies = api::list_competencies_in_course($courseid);
|
||||||
$this->canmanagecompetencyframeworks = has_capability('tool/lp:competencymanage', context_system::instance());
|
$this->canmanagecoursecompetencies = has_capability('tool/lp:coursecompetencymanage', $this->context);
|
||||||
$this->canmanagecoursecompetencies = has_capability('tool/lp:coursecompetencymanage', $context);
|
|
||||||
$this->manageurl = new moodle_url('/admin/tool/lp/competencyframeworks.php');
|
// Check the lowest level in which the user can manage the competencies.
|
||||||
|
$this->manageurl = null;
|
||||||
|
$this->canmanagecompetencyframeworks = false;
|
||||||
|
$contexts = array_reverse($this->context->get_parent_contexts(true));
|
||||||
|
foreach ($contexts as $context) {
|
||||||
|
$canmanage = has_capability('tool/lp:competencymanage', $context);
|
||||||
|
if ($canmanage) {
|
||||||
|
$this->manageurl = new moodle_url('/admin/tool/lp/competencyframeworks.php',
|
||||||
|
array('pagecontextid' => $context->id));
|
||||||
|
$this->canmanagecompetencyframeworks = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -77,6 +92,7 @@ class course_competencies_page implements renderable, templatable {
|
||||||
public function export_for_template(renderer_base $output) {
|
public function export_for_template(renderer_base $output) {
|
||||||
$data = new stdClass();
|
$data = new stdClass();
|
||||||
$data->courseid = $this->courseid;
|
$data->courseid = $this->courseid;
|
||||||
|
$data->pagecontextid = $this->context->id;
|
||||||
$data->competencies = array();
|
$data->competencies = array();
|
||||||
foreach ($this->competencies as $competency) {
|
foreach ($this->competencies as $competency) {
|
||||||
$record = $competency->to_record();
|
$record = $competency->to_record();
|
||||||
|
@ -84,7 +100,10 @@ class course_competencies_page implements renderable, templatable {
|
||||||
}
|
}
|
||||||
$data->canmanagecompetencyframeworks = $this->canmanagecompetencyframeworks;
|
$data->canmanagecompetencyframeworks = $this->canmanagecompetencyframeworks;
|
||||||
$data->canmanagecoursecompetencies = $this->canmanagecoursecompetencies;
|
$data->canmanagecoursecompetencies = $this->canmanagecoursecompetencies;
|
||||||
$data->manageurl = $this->manageurl->out(true);
|
$data->manageurl = null;
|
||||||
|
if ($this->canmanagecompetencyframeworks) {
|
||||||
|
$data->manageurl = $this->manageurl->out(true);
|
||||||
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,14 +55,19 @@ class manage_competencies_page implements renderable, templatable {
|
||||||
/** @var moodle_url $pluginurlbase Base url to use constructing links. */
|
/** @var moodle_url $pluginurlbase Base url to use constructing links. */
|
||||||
protected $pluginbaseurl = null;
|
protected $pluginbaseurl = null;
|
||||||
|
|
||||||
|
/** @var context $pagecontext The page context. */
|
||||||
|
protected $pagecontext = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct this renderable.
|
* Construct this renderable.
|
||||||
*
|
*
|
||||||
* @param \tool_lp\competency_framework $framework Competency framework.
|
* @param \tool_lp\competency_framework $framework Competency framework.
|
||||||
* @param string $search Search string.
|
* @param string $search Search string.
|
||||||
|
* @param context $pagecontext The page context.
|
||||||
*/
|
*/
|
||||||
public function __construct($framework, $search) {
|
public function __construct($framework, $search, $pagecontext) {
|
||||||
$this->framework = $framework;
|
$this->framework = $framework;
|
||||||
|
$this->pagecontext = $pagecontext;
|
||||||
$this->search = $search;
|
$this->search = $search;
|
||||||
$addpage = new single_button(
|
$addpage = new single_button(
|
||||||
new moodle_url('/admin/tool/lp/editcompetencyframework.php'),
|
new moodle_url('/admin/tool/lp/editcompetencyframework.php'),
|
||||||
|
@ -72,8 +77,7 @@ class manage_competencies_page implements renderable, templatable {
|
||||||
|
|
||||||
$this->competencies = api::search_competencies($search, $framework->get_id());
|
$this->competencies = api::search_competencies($search, $framework->get_id());
|
||||||
|
|
||||||
$context = context_system::instance();
|
$this->canmanage = has_capability('tool/lp:competencymanage', $framework->get_context());
|
||||||
$this->canmanage = has_capability('tool/lp:competencymanage', $context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -107,6 +111,7 @@ class manage_competencies_page implements renderable, templatable {
|
||||||
$data->canmanage = $this->canmanage;
|
$data->canmanage = $this->canmanage;
|
||||||
$data->competencies = array();
|
$data->competencies = array();
|
||||||
$data->search = $this->search;
|
$data->search = $this->search;
|
||||||
|
$data->pagecontextid = $this->pagecontext->id;
|
||||||
|
|
||||||
foreach ($this->competencies as $competency) {
|
foreach ($this->competencies as $competency) {
|
||||||
if ($competency->get_parentid() == 0) {
|
if ($competency->get_parentid() == 0) {
|
||||||
|
|
|
@ -29,6 +29,7 @@ use renderer_base;
|
||||||
use single_button;
|
use single_button;
|
||||||
use stdClass;
|
use stdClass;
|
||||||
use moodle_url;
|
use moodle_url;
|
||||||
|
use context;
|
||||||
use context_system;
|
use context_system;
|
||||||
use tool_lp\api;
|
use tool_lp\api;
|
||||||
|
|
||||||
|
@ -40,6 +41,9 @@ use tool_lp\api;
|
||||||
*/
|
*/
|
||||||
class manage_competency_frameworks_page implements renderable, templatable {
|
class manage_competency_frameworks_page implements renderable, templatable {
|
||||||
|
|
||||||
|
/** @var context The context in which everything is happening. */
|
||||||
|
protected $pagecontext;
|
||||||
|
|
||||||
/** @var array $navigation List of links to display on the page. Each link contains a url and a title. */
|
/** @var array $navigation List of links to display on the page. Each link contains a url and a title. */
|
||||||
protected $navigation = array();
|
protected $navigation = array();
|
||||||
|
|
||||||
|
@ -55,17 +59,17 @@ class manage_competency_frameworks_page implements renderable, templatable {
|
||||||
/**
|
/**
|
||||||
* Construct this renderable.
|
* Construct this renderable.
|
||||||
*/
|
*/
|
||||||
public function __construct() {
|
public function __construct(context $pagecontext) {
|
||||||
|
$this->pagecontext = $pagecontext;
|
||||||
|
|
||||||
$addpage = new single_button(
|
$addpage = new single_button(
|
||||||
new moodle_url('/admin/tool/lp/editcompetencyframework.php'),
|
new moodle_url('/admin/tool/lp/editcompetencyframework.php', array('pagecontextid' => $this->pagecontext->id)),
|
||||||
get_string('addnewcompetencyframework', 'tool_lp')
|
get_string('addnewcompetencyframework', 'tool_lp'),
|
||||||
|
'get'
|
||||||
);
|
);
|
||||||
$this->navigation[] = $addpage;
|
$this->navigation[] = $addpage;
|
||||||
|
|
||||||
$this->competencyframeworks = api::list_frameworks(array(), 'sortorder', 'ASC', 0, 0);
|
$this->competencyframeworks = api::list_frameworks('shortname', 'ASC', 0, 0, $this->pagecontext);
|
||||||
|
|
||||||
$context = context_system::instance();
|
|
||||||
$this->canmanage = has_capability('tool/lp:competencymanage', $context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -76,12 +80,14 @@ class manage_competency_frameworks_page implements renderable, templatable {
|
||||||
*/
|
*/
|
||||||
public function export_for_template(renderer_base $output) {
|
public function export_for_template(renderer_base $output) {
|
||||||
$data = new stdClass();
|
$data = new stdClass();
|
||||||
$data->canmanage = $this->canmanage;
|
|
||||||
$data->competencyframeworks = array();
|
$data->competencyframeworks = array();
|
||||||
|
$data->pagecontextid = $this->pagecontext->id;
|
||||||
foreach ($this->competencyframeworks as $framework) {
|
foreach ($this->competencyframeworks as $framework) {
|
||||||
$record = $framework->to_record();
|
$record = $framework->to_record();
|
||||||
$filters = array('competencyframeworkid' => $framework->get_id());
|
$filters = array('competencyframeworkid' => $framework->get_id());
|
||||||
|
$record->canmanage = has_capability('tool/lp:competencymanage', $framework->get_context());
|
||||||
$record->competencies_count = api::count_competencies($filters);
|
$record->competencies_count = api::count_competencies($filters);
|
||||||
|
$record->context_name = $framework->get_context()->get_context_name();
|
||||||
$data->competencyframeworks[] = $record;
|
$data->competencyframeworks[] = $record;
|
||||||
}
|
}
|
||||||
$data->pluginbaseurl = (new moodle_url('/admin/tool/lp'))->out(true);
|
$data->pluginbaseurl = (new moodle_url('/admin/tool/lp'))->out(true);
|
||||||
|
|
|
@ -264,9 +264,7 @@ abstract class persistent {
|
||||||
public function get_records_select($select, $params = null, $sort = '', $fields = '*', $limitfrom = 0, $limitnum = 0) {
|
public function get_records_select($select, $params = null, $sort = '', $fields = '*', $limitfrom = 0, $limitnum = 0) {
|
||||||
global $DB;
|
global $DB;
|
||||||
|
|
||||||
if (!$records = $DB->get_records_select($this->get_table_name(), $select, $params, $sort, $fields, $limitfrom, $limitnum)) {
|
$records = $DB->get_records_select($this->get_table_name(), $select, $params, $sort, $fields, $limitfrom, $limitnum);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// We return class instances.
|
// We return class instances.
|
||||||
$instances = array();
|
$instances = array();
|
||||||
|
|
|
@ -25,17 +25,28 @@
|
||||||
require_once(__DIR__ . '/../../../config.php');
|
require_once(__DIR__ . '/../../../config.php');
|
||||||
require_once($CFG->libdir.'/adminlib.php');
|
require_once($CFG->libdir.'/adminlib.php');
|
||||||
|
|
||||||
admin_externalpage_setup('toollpcompetencies');
|
|
||||||
|
|
||||||
$id = required_param('competencyframeworkid', PARAM_INT);
|
$id = required_param('competencyframeworkid', PARAM_INT);
|
||||||
|
$pagecontextid = required_param('pagecontextid', PARAM_INT); // Reference to the context we came from.
|
||||||
$search = optional_param('search', '', PARAM_RAW);
|
$search = optional_param('search', '', PARAM_RAW);
|
||||||
|
|
||||||
|
require_login();
|
||||||
|
|
||||||
|
$pagecontext = context::instance_by_id($pagecontextid);
|
||||||
$framework = \tool_lp\api::read_framework($id);
|
$framework = \tool_lp\api::read_framework($id);
|
||||||
|
$context = $framework->get_context();
|
||||||
|
require_capability('tool/lp:competencymanage', $context);
|
||||||
|
|
||||||
$title = get_string('competencies', 'tool_lp');
|
$title = get_string('competencies', 'tool_lp');
|
||||||
$pagetitle = get_string('competenciesforframework', 'tool_lp', $framework->get_shortname());
|
$pagetitle = get_string('competenciesforframework', 'tool_lp', $framework->get_shortname());
|
||||||
|
|
||||||
// Set up the page.
|
// Set up the page.
|
||||||
$url = new moodle_url("/admin/tool/lp/competencies.php", array('competencyframeworkid' => $framework->get_id()));
|
$url = new moodle_url("/admin/tool/lp/competencies.php", array('competencyframeworkid' => $framework->get_id(),
|
||||||
|
'pagecontextid' => $pagecontextid));
|
||||||
|
$frameworksurl = new moodle_url('/admin/tool/lp/competencyframeworks.php', array('pagecontextid' => $pagecontextid));
|
||||||
|
|
||||||
|
$PAGE->navigation->override_active_url($frameworksurl);
|
||||||
|
$PAGE->set_context($pagecontext);
|
||||||
|
$PAGE->set_pagelayout('admin');
|
||||||
$PAGE->set_url($url);
|
$PAGE->set_url($url);
|
||||||
$PAGE->navbar->add($framework->get_shortname(), $url);
|
$PAGE->navbar->add($framework->get_shortname(), $url);
|
||||||
$PAGE->set_title($title);
|
$PAGE->set_title($title);
|
||||||
|
@ -44,7 +55,7 @@ $output = $PAGE->get_renderer('tool_lp');
|
||||||
echo $output->header();
|
echo $output->header();
|
||||||
echo $output->heading($pagetitle);
|
echo $output->heading($pagetitle);
|
||||||
|
|
||||||
$page = new \tool_lp\output\manage_competencies_page($framework, $search);
|
$page = new \tool_lp\output\manage_competencies_page($framework, $search, $pagecontext);
|
||||||
echo $output->render($page);
|
echo $output->render($page);
|
||||||
|
|
||||||
echo $output->footer();
|
echo $output->footer();
|
||||||
|
|
|
@ -25,12 +25,21 @@
|
||||||
require_once(__DIR__ . '/../../../config.php');
|
require_once(__DIR__ . '/../../../config.php');
|
||||||
require_once($CFG->libdir.'/adminlib.php');
|
require_once($CFG->libdir.'/adminlib.php');
|
||||||
|
|
||||||
admin_externalpage_setup('toollpcompetencies');
|
$pagecontextid = required_param('pagecontextid', PARAM_INT);
|
||||||
|
$context = context::instance_by_id($pagecontextid);
|
||||||
|
|
||||||
|
$url = new moodle_url("/admin/tool/lp/competencyframeworks.php");
|
||||||
|
$url->param('pagecontextid', $pagecontextid);
|
||||||
|
|
||||||
|
require_login();
|
||||||
|
require_capability('tool/lp:competencymanage', $context);
|
||||||
|
|
||||||
$title = get_string('competencies', 'tool_lp');
|
$title = get_string('competencies', 'tool_lp');
|
||||||
$pagetitle = get_string('competencyframeworks', 'tool_lp');
|
$pagetitle = get_string('competencyframeworks', 'tool_lp');
|
||||||
|
|
||||||
// Set up the page.
|
// Set up the page.
|
||||||
$url = new moodle_url("/admin/tool/lp/competencyframeworks.php");
|
$PAGE->set_context($context);
|
||||||
|
$PAGE->set_pagelayout('admin');
|
||||||
$PAGE->set_url($url);
|
$PAGE->set_url($url);
|
||||||
$PAGE->set_title($title);
|
$PAGE->set_title($title);
|
||||||
$PAGE->set_heading($title);
|
$PAGE->set_heading($title);
|
||||||
|
@ -38,7 +47,7 @@ $output = $PAGE->get_renderer('tool_lp');
|
||||||
echo $output->header();
|
echo $output->header();
|
||||||
echo $output->heading($pagetitle);
|
echo $output->heading($pagetitle);
|
||||||
|
|
||||||
$page = new \tool_lp\output\manage_competency_frameworks_page();
|
$page = new \tool_lp\output\manage_competency_frameworks_page($context);
|
||||||
echo $output->render($page);
|
echo $output->render($page);
|
||||||
|
|
||||||
echo $output->footer();
|
echo $output->footer();
|
||||||
|
|
|
@ -30,14 +30,14 @@ $capabilities = array(
|
||||||
|
|
||||||
'tool/lp:competencymanage' => array(
|
'tool/lp:competencymanage' => array(
|
||||||
'captype' => 'write',
|
'captype' => 'write',
|
||||||
'contextlevel' => CONTEXT_SYSTEM,
|
'contextlevel' => CONTEXT_COURSECAT,
|
||||||
'archetypes' => array(
|
'archetypes' => array(
|
||||||
),
|
'manager' => CAP_ALLOW
|
||||||
'clonepermissionsfrom' => 'moodle/site:config'
|
)
|
||||||
),
|
),
|
||||||
'tool/lp:competencyread' => array(
|
'tool/lp:competencyread' => array(
|
||||||
'captype' => 'read',
|
'captype' => 'read',
|
||||||
'contextlevel' => CONTEXT_SYSTEM,
|
'contextlevel' => CONTEXT_COURSECAT,
|
||||||
'archetypes' => array(
|
'archetypes' => array(
|
||||||
'user' => CAP_ALLOW
|
'user' => CAP_ALLOW
|
||||||
),
|
),
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<XMLDB PATH="admin/tool/lp/db" VERSION="20150813" COMMENT="XMLDB file for Moodle admin/tool/lp"
|
<XMLDB PATH="admin/tool/lp/db" VERSION="20150814" COMMENT="XMLDB file for Moodle admin/tool/lp"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:noNamespaceSchemaLocation="../../../../lib/xmldb/xmldb.xsd"
|
xsi:noNamespaceSchemaLocation="../../../../lib/xmldb/xmldb.xsd"
|
||||||
>
|
>
|
||||||
|
@ -31,6 +31,7 @@
|
||||||
<FIELDS>
|
<FIELDS>
|
||||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
|
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
|
||||||
<FIELD NAME="shortname" TYPE="char" LENGTH="100" NOTNULL="false" SEQUENCE="false" COMMENT="Short name for the competency framework."/>
|
<FIELD NAME="shortname" TYPE="char" LENGTH="100" NOTNULL="false" SEQUENCE="false" COMMENT="Short name for the competency framework."/>
|
||||||
|
<FIELD NAME="contextid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
|
||||||
<FIELD NAME="idnumber" TYPE="char" LENGTH="100" NOTNULL="false" SEQUENCE="false" COMMENT="Unique idnumber for this competency framework."/>
|
<FIELD NAME="idnumber" TYPE="char" LENGTH="100" NOTNULL="false" SEQUENCE="false" COMMENT="Unique idnumber for this competency framework."/>
|
||||||
<FIELD NAME="description" TYPE="text" NOTNULL="false" SEQUENCE="false" COMMENT="Description of this competency framework"/>
|
<FIELD NAME="description" TYPE="text" NOTNULL="false" SEQUENCE="false" COMMENT="Description of this competency framework"/>
|
||||||
<FIELD NAME="descriptionformat" TYPE="int" LENGTH="4" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="The format of the description field"/>
|
<FIELD NAME="descriptionformat" TYPE="int" LENGTH="4" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="The format of the description field"/>
|
||||||
|
|
|
@ -65,5 +65,21 @@ function xmldb_tool_lp_upgrade($oldversion) {
|
||||||
upgrade_plugin_savepoint(true, 2015052404, 'tool', 'lp');
|
upgrade_plugin_savepoint(true, 2015052404, 'tool', 'lp');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($oldversion < 2015052405) {
|
||||||
|
|
||||||
|
// Define field contextid to be added to tool_lp_competency_framework.
|
||||||
|
$table = new xmldb_table('tool_lp_competency_framework');
|
||||||
|
$field = new xmldb_field('contextid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null,
|
||||||
|
context_system::instance()->id, 'id');
|
||||||
|
|
||||||
|
// Conditionally launch add field contextid.
|
||||||
|
if (!$dbman->field_exists($table, $field)) {
|
||||||
|
$dbman->add_field($table, $field);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lp savepoint reached.
|
||||||
|
upgrade_plugin_savepoint(true, 2015052405, 'tool', 'lp');
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,25 +25,27 @@
|
||||||
require_once(__DIR__ . '/../../../config.php');
|
require_once(__DIR__ . '/../../../config.php');
|
||||||
require_once($CFG->libdir.'/adminlib.php');
|
require_once($CFG->libdir.'/adminlib.php');
|
||||||
|
|
||||||
admin_externalpage_setup('toollpcompetencies');
|
|
||||||
|
|
||||||
$title = get_string('competencies', 'tool_lp');
|
$title = get_string('competencies', 'tool_lp');
|
||||||
$id = optional_param('id', 0, PARAM_INT);
|
$id = optional_param('id', 0, PARAM_INT);
|
||||||
$competencyframeworkid = required_param('competencyframeworkid', PARAM_INT);
|
$competencyframeworkid = required_param('competencyframeworkid', PARAM_INT);
|
||||||
|
$pagecontextid = required_param('pagecontextid', PARAM_INT); // Reference to the context we came from.
|
||||||
$parentid = optional_param('parentid', 0, PARAM_INT);
|
$parentid = optional_param('parentid', 0, PARAM_INT);
|
||||||
|
|
||||||
|
require_login();
|
||||||
|
$pagecontext = context::instance_by_id($pagecontextid);
|
||||||
|
|
||||||
if (empty($id)) {
|
if (empty($id)) {
|
||||||
$pagetitle = get_string('addnewcompetency', 'tool_lp');
|
$pagetitle = get_string('addnewcompetency', 'tool_lp');
|
||||||
} else {
|
} else {
|
||||||
$pagetitle = get_string('editcompetency', 'tool_lp');
|
$pagetitle = get_string('editcompetency', 'tool_lp');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up the page.
|
// Set up the page.
|
||||||
$params = array('id' => $id, 'competencyframeworkid' => $competencyframeworkid, 'parentid' => $parentid);
|
$url = new moodle_url("/admin/tool/lp/editcompetency.php", array('id' => $id, 'competencyframeworkid' => $competencyframeworkid,
|
||||||
$url = new moodle_url("/admin/tool/lp/editcompetency.php", $params);
|
'parentid' => $parentid, 'pagecontextid' => $pagecontextid));
|
||||||
$PAGE->set_url($url);
|
$frameworksurl = new moodle_url('/admin/tool/lp/competencyframeworks.php', array('pagecontextid' => $pagecontextid));
|
||||||
$PAGE->set_title($title);
|
$frameworkurl = new moodle_url('/admin/tool/lp/competencies.php', array('competencyframeworkid' => $competencyframeworkid,
|
||||||
$PAGE->set_heading($title);
|
'pagecontextid' => $pagecontextid));
|
||||||
$output = $PAGE->get_renderer('tool_lp');
|
|
||||||
|
|
||||||
$competencyframework = \tool_lp\api::read_framework($competencyframeworkid);
|
$competencyframework = \tool_lp\api::read_framework($competencyframeworkid);
|
||||||
$parent = null;
|
$parent = null;
|
||||||
|
@ -51,10 +53,20 @@ if ($parentid) {
|
||||||
$parent = \tool_lp\api::read_competency($parentid);
|
$parent = \tool_lp\api::read_competency($parentid);
|
||||||
}
|
}
|
||||||
|
|
||||||
$form = new \tool_lp\form\competency(null, array('id' => $id, 'competencyframework' => $competencyframework, 'parent' => $parent));
|
$PAGE->navigation->override_active_url($frameworksurl);
|
||||||
|
$PAGE->set_context($pagecontext);
|
||||||
|
$PAGE->set_pagelayout('admin');
|
||||||
|
$PAGE->set_url($url);
|
||||||
|
$PAGE->set_title($title);
|
||||||
|
$PAGE->set_heading($title);
|
||||||
|
$PAGE->navbar->add($competencyframework->get_shortname(), $frameworkurl);
|
||||||
|
$output = $PAGE->get_renderer('tool_lp');
|
||||||
|
|
||||||
|
$form = new \tool_lp\form\competency($url->out(false), array('id' => $id, 'competencyframework' => $competencyframework,
|
||||||
|
'parent' => $parent));
|
||||||
|
|
||||||
if ($form->is_cancelled()) {
|
if ($form->is_cancelled()) {
|
||||||
redirect(new moodle_url('/admin/tool/lp/competencies.php', array('competencyframeworkid' => $competencyframeworkid)));
|
redirect($frameworkurl);
|
||||||
}
|
}
|
||||||
|
|
||||||
echo $output->header();
|
echo $output->header();
|
||||||
|
@ -71,14 +83,12 @@ if ($data) {
|
||||||
require_sesskey();
|
require_sesskey();
|
||||||
\tool_lp\api::create_competency($data);
|
\tool_lp\api::create_competency($data);
|
||||||
echo $output->notification(get_string('competencycreated', 'tool_lp'), 'notifysuccess');
|
echo $output->notification(get_string('competencycreated', 'tool_lp'), 'notifysuccess');
|
||||||
echo $output->continue_button(new moodle_url('/admin/tool/lp/competencies.php',
|
echo $output->continue_button($frameworkurl);
|
||||||
array('competencyframeworkid' => $competencyframeworkid)));
|
|
||||||
} else {
|
} else {
|
||||||
require_sesskey();
|
require_sesskey();
|
||||||
\tool_lp\api::update_competency($data);
|
\tool_lp\api::update_competency($data);
|
||||||
echo $output->notification(get_string('competencyupdated', 'tool_lp'), 'notifysuccess');
|
echo $output->notification(get_string('competencyupdated', 'tool_lp'), 'notifysuccess');
|
||||||
echo $output->continue_button(new moodle_url('/admin/tool/lp/competencies.php',
|
echo $output->continue_button($frameworkurl);
|
||||||
array('competencyframeworkid' => $competencyframeworkid)));
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$form->display();
|
$form->display();
|
||||||
|
|
|
@ -25,26 +25,45 @@
|
||||||
require_once(__DIR__ . '/../../../config.php');
|
require_once(__DIR__ . '/../../../config.php');
|
||||||
require_once($CFG->libdir.'/adminlib.php');
|
require_once($CFG->libdir.'/adminlib.php');
|
||||||
|
|
||||||
admin_externalpage_setup('toollpcompetencies');
|
$id = optional_param('id', 0, PARAM_INT);
|
||||||
|
$pagecontextid = required_param('pagecontextid', PARAM_INT); // Reference to where we can from.
|
||||||
|
|
||||||
|
if (!empty($id)) {
|
||||||
|
// Always use the context from the framework when it exists.
|
||||||
|
$framework = new \tool_lp\competency_framework($id);
|
||||||
|
$context = $framework->get_context();
|
||||||
|
} else {
|
||||||
|
$context = context::instance_by_id($pagecontextid);
|
||||||
|
}
|
||||||
|
|
||||||
|
// We check that we have the permission to edit this framework, in its own context.
|
||||||
|
require_login();
|
||||||
|
require_capability('tool/lp:competencymanage', $context);
|
||||||
|
|
||||||
|
// We keep the original context in the URLs, so that we remain in the same context.
|
||||||
|
$url = new moodle_url("/admin/tool/lp/editcompetencyframework.php", array('id' => $id, 'pagecontextid' => $pagecontextid));
|
||||||
|
$frameworksurl = new moodle_url('/admin/tool/lp/competencyframeworks.php', array('pagecontextid' => $pagecontextid));
|
||||||
|
$formurl = new moodle_url("/admin/tool/lp/editcompetencyframework.php", array('pagecontextid' => $pagecontextid));
|
||||||
|
|
||||||
$title = get_string('competencies', 'tool_lp');
|
$title = get_string('competencies', 'tool_lp');
|
||||||
$id = optional_param('id', 0, PARAM_INT);
|
|
||||||
if (empty($id)) {
|
if (empty($id)) {
|
||||||
$pagetitle = get_string('addnewcompetencyframework', 'tool_lp');
|
$pagetitle = get_string('addnewcompetencyframework', 'tool_lp');
|
||||||
} else {
|
} else {
|
||||||
$pagetitle = get_string('editcompetencyframework', 'tool_lp');
|
$pagetitle = get_string('editcompetencyframework', 'tool_lp');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up the page.
|
// Set up the page.
|
||||||
$url = new moodle_url("/admin/tool/lp/editcompetencyframework.php", array('id' => $id));
|
$PAGE->navigation->override_active_url($frameworksurl);
|
||||||
|
$PAGE->set_context(context::instance_by_id($pagecontextid));
|
||||||
|
$PAGE->set_pagelayout('admin');
|
||||||
$PAGE->set_url($url);
|
$PAGE->set_url($url);
|
||||||
$PAGE->set_title($title);
|
$PAGE->set_title($title);
|
||||||
$PAGE->set_heading($title);
|
$PAGE->set_heading($title);
|
||||||
$output = $PAGE->get_renderer('tool_lp');
|
$output = $PAGE->get_renderer('tool_lp');
|
||||||
|
$form = new \tool_lp\form\competency_framework($formurl->out(false), array('id' => $id, 'context' => $context));
|
||||||
$form = new \tool_lp\form\competency_framework(null, $id);
|
|
||||||
|
|
||||||
if ($form->is_cancelled()) {
|
if ($form->is_cancelled()) {
|
||||||
redirect(new moodle_url('/admin/tool/lp/competencyframeworks.php'));
|
redirect($frameworksurl);
|
||||||
}
|
}
|
||||||
|
|
||||||
echo $output->header();
|
echo $output->header();
|
||||||
|
@ -59,14 +78,15 @@ if ($data) {
|
||||||
if (empty($data->id)) {
|
if (empty($data->id)) {
|
||||||
// Create new framework.
|
// Create new framework.
|
||||||
require_sesskey();
|
require_sesskey();
|
||||||
|
$data->contextid = $context->id;
|
||||||
\tool_lp\api::create_framework($data);
|
\tool_lp\api::create_framework($data);
|
||||||
echo $output->notification(get_string('competencyframeworkcreated', 'tool_lp'), 'notifysuccess');
|
echo $output->notification(get_string('competencyframeworkcreated', 'tool_lp'), 'notifysuccess');
|
||||||
echo $output->continue_button('/admin/tool/lp/competencyframeworks.php');
|
echo $output->continue_button($frameworksurl);
|
||||||
} else {
|
} else {
|
||||||
require_sesskey();
|
require_sesskey();
|
||||||
\tool_lp\api::update_framework($data);
|
\tool_lp\api::update_framework($data);
|
||||||
echo $output->notification(get_string('competencyframeworkupdated', 'tool_lp'), 'notifysuccess');
|
echo $output->notification(get_string('competencyframeworkupdated', 'tool_lp'), 'notifysuccess');
|
||||||
echo $output->continue_button('/admin/tool/lp/competencyframeworks.php');
|
echo $output->continue_button($frameworksurl);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$form->display();
|
$form->display();
|
||||||
|
|
|
@ -29,7 +29,7 @@ defined('MOODLE_INTERNAL') || die;
|
||||||
$temp = new admin_externalpage(
|
$temp = new admin_externalpage(
|
||||||
'toollpcompetencies',
|
'toollpcompetencies',
|
||||||
get_string('competencyframeworks', 'tool_lp'),
|
get_string('competencyframeworks', 'tool_lp'),
|
||||||
new moodle_url('/admin/tool/lp/competencyframeworks.php'),
|
new moodle_url('/admin/tool/lp/competencyframeworks.php', array('pagecontextid' => context_system::instance()->id)),
|
||||||
'tool/lp:competencymanage'
|
'tool/lp:competencymanage'
|
||||||
);
|
);
|
||||||
$ADMIN->add('root', $temp, 'badges');
|
$ADMIN->add('root', $temp, 'badges');
|
||||||
|
|
|
@ -51,6 +51,6 @@
|
||||||
</div>
|
</div>
|
||||||
{{#js}}
|
{{#js}}
|
||||||
require(['tool_lp/competencies'], function(mod) {
|
require(['tool_lp/competencies'], function(mod) {
|
||||||
(new mod({{courseid}}, 'course'));
|
(new mod({{courseid}}, 'course', {{pagecontextid}}));
|
||||||
});
|
});
|
||||||
{{/js}}
|
{{/js}}
|
||||||
|
|
|
@ -107,7 +107,7 @@ require(['tool_lp/tree', 'tool_lp/competencytree', 'tool_lp/competencyactions' ]
|
||||||
|
|
||||||
treeModel.init({{framework.id}});
|
treeModel.init({{framework.id}});
|
||||||
|
|
||||||
actions.init(treeModel);
|
actions.init(treeModel, {{pagecontextid}});
|
||||||
|
|
||||||
var competencytree = new ariatree('[data-enhance=tree]', actions.selectionChanged);
|
var competencytree = new ariatree('[data-enhance=tree]', actions.selectionChanged);
|
||||||
|
|
||||||
|
|
|
@ -40,14 +40,16 @@
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="col">{{#str}}competencyframeworkname, tool_lp{{/str}}</th>
|
<th scope="col">{{#str}}competencyframeworkname, tool_lp{{/str}}</th>
|
||||||
<th scope="col">{{#str}}competencies, tool_lp{{/str}}</th>
|
<th scope="col">{{#str}}competencies, tool_lp{{/str}}</th>
|
||||||
|
<th scope="col">{{#str}}context, core_role{{/str}}</th>
|
||||||
<th scope="col">{{#str}}actions, tool_lp{{/str}}</th>
|
<th scope="col">{{#str}}actions, tool_lp{{/str}}</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody class="drag-parentnode">
|
<tbody class="drag-parentnode">
|
||||||
{{#competencyframeworks}}
|
{{#competencyframeworks}}
|
||||||
<tr class="drag-samenode" data-frameworkid="{{id}}">
|
<tr class="drag-samenode" data-frameworkid="{{id}}">
|
||||||
<td><span class="drag-handlecontainer"></span><span><a href="{{pluginbaseurl}}/competencies.php?competencyframeworkid={{id}}">{{shortname}} {{idnumber}}</a></span> {{^visible}}{{#str}}hiddenhint, tool_lp{{/str}}{{/visible}}</td>
|
<td><span class="drag-handlecontainer"></span><span><a href="{{pluginbaseurl}}/competencies.php?competencyframeworkid={{id}}&pagecontextid={{pagecontextid}}">{{shortname}} {{idnumber}}</a></span> {{^visible}}{{#str}}hiddenhint, tool_lp{{/str}}{{/visible}}</td>
|
||||||
<td>{{competencies_count}}</td>
|
<td>{{competencies_count}}</td>
|
||||||
|
<td>{{context_name}}</td>
|
||||||
<td>
|
<td>
|
||||||
{{#canmanage}}
|
{{#canmanage}}
|
||||||
<ul title="{{#str}}edit{{/str}}" class="competencyframeworkactions">
|
<ul title="{{#str}}edit{{/str}}" class="competencyframeworkactions">
|
||||||
|
@ -55,12 +57,12 @@
|
||||||
<a href="#">{{#str}}edit{{/str}}</a><b class="caret"></b>
|
<a href="#">{{#str}}edit{{/str}}</a><b class="caret"></b>
|
||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu">
|
||||||
<li>
|
<li>
|
||||||
<a href="{{pluginbaseurl}}/editcompetencyframework.php?id={{id}}">
|
<a href="{{pluginbaseurl}}/editcompetencyframework.php?id={{id}}&pagecontextid={{pagecontextid}}">
|
||||||
{{#pix}}t/edit{{/pix}} {{#str}}edit{{/str}}
|
{{#pix}}t/edit{{/pix}} {{#str}}edit{{/str}}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a data-action="deletecompetencyframework" data-frameworkid="{{id}}" href="#">
|
<a data-action="deletecompetencyframework" href="#" data-frameworkid="{{id}}">
|
||||||
{{#pix}}t/delete{{/pix}} {{#str}}delete{{/str}}
|
{{#pix}}t/delete{{/pix}} {{#str}}delete{{/str}}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
@ -88,11 +90,10 @@
|
||||||
{{#js}}
|
{{#js}}
|
||||||
// Initialise the JS.
|
// Initialise the JS.
|
||||||
require(['tool_lp/frameworkdelete',
|
require(['tool_lp/frameworkdelete',
|
||||||
'tool_lp/menubar',
|
'tool_lp/menubar'],
|
||||||
'tool_lp/frameworkmove'],
|
function(deleteMod, menubar) {
|
||||||
function(deleteMod, menubar, moveMod) {
|
|
||||||
|
|
||||||
moveMod.init();
|
deleteMod.init({{pagecontextid}});
|
||||||
|
|
||||||
menubar.enhance('.competencyframeworkactions', {
|
menubar.enhance('.competencyframeworkactions', {
|
||||||
"[data-action='deletecompetencyframework']": deleteMod.deleteHandler
|
"[data-action='deletecompetencyframework']": deleteMod.deleteHandler
|
||||||
|
|
|
@ -89,7 +89,8 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
||||||
public function test_create_competency_frameworks_with_read_permissions() {
|
public function test_create_competency_frameworks_with_read_permissions() {
|
||||||
$this->setExpectedException('required_capability_exception');
|
$this->setExpectedException('required_capability_exception');
|
||||||
$this->setUser($this->user);
|
$this->setUser($this->user);
|
||||||
$result = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true);
|
$result = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true,
|
||||||
|
array('contextid' => context_system::instance()->id));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -97,7 +98,8 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
||||||
*/
|
*/
|
||||||
public function test_create_competency_frameworks_with_manage_permissions() {
|
public function test_create_competency_frameworks_with_manage_permissions() {
|
||||||
$this->setUser($this->creator);
|
$this->setUser($this->creator);
|
||||||
$result = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true);
|
$result = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true,
|
||||||
|
array('contextid' => context_system::instance()->id));
|
||||||
$result = (object) external_api::clean_returnvalue(external::create_competency_framework_returns(), $result);
|
$result = (object) external_api::clean_returnvalue(external::create_competency_framework_returns(), $result);
|
||||||
|
|
||||||
$this->assertGreaterThan(0, $result->timecreated);
|
$this->assertGreaterThan(0, $result->timecreated);
|
||||||
|
@ -116,7 +118,8 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
||||||
public function test_create_competency_frameworks_with_nasty_data() {
|
public function test_create_competency_frameworks_with_nasty_data() {
|
||||||
$this->setUser($this->creator);
|
$this->setUser($this->creator);
|
||||||
$this->setExpectedException('invalid_parameter_exception');
|
$this->setExpectedException('invalid_parameter_exception');
|
||||||
$result = external::create_competency_framework('short<a href="">', 'id;"number', 'de<>\\..scription', FORMAT_HTML, true);
|
$result = external::create_competency_framework('short<a href="">', 'id;"number', 'de<>\\..scription', FORMAT_HTML, true,
|
||||||
|
array('contextid' => context_system::instance()->id));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -124,7 +127,8 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
||||||
*/
|
*/
|
||||||
public function test_read_competency_frameworks_with_manage_permissions() {
|
public function test_read_competency_frameworks_with_manage_permissions() {
|
||||||
$this->setUser($this->creator);
|
$this->setUser($this->creator);
|
||||||
$result = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true);
|
$result = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true,
|
||||||
|
array('contextid' => context_system::instance()->id));
|
||||||
$result = (object) external_api::clean_returnvalue(external::create_competency_framework_returns(), $result);
|
$result = (object) external_api::clean_returnvalue(external::create_competency_framework_returns(), $result);
|
||||||
|
|
||||||
$id = $result->id;
|
$id = $result->id;
|
||||||
|
@ -146,7 +150,8 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
||||||
*/
|
*/
|
||||||
public function test_read_competency_frameworks_with_read_permissions() {
|
public function test_read_competency_frameworks_with_read_permissions() {
|
||||||
$this->setUser($this->creator);
|
$this->setUser($this->creator);
|
||||||
$result = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true);
|
$result = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true,
|
||||||
|
array('contextid' => context_system::instance()->id));
|
||||||
$result = (object) external_api::clean_returnvalue(external::create_competency_framework_returns(), $result);
|
$result = (object) external_api::clean_returnvalue(external::create_competency_framework_returns(), $result);
|
||||||
|
|
||||||
// Switch users to someone with less permissions.
|
// Switch users to someone with less permissions.
|
||||||
|
@ -170,7 +175,8 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
||||||
*/
|
*/
|
||||||
public function test_delete_competency_frameworks_with_manage_permissions() {
|
public function test_delete_competency_frameworks_with_manage_permissions() {
|
||||||
$this->setUser($this->creator);
|
$this->setUser($this->creator);
|
||||||
$result = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true);
|
$result = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true,
|
||||||
|
array('contextid' => context_system::instance()->id));
|
||||||
$result = (object) external_api::clean_returnvalue(external::create_competency_framework_returns(), $result);
|
$result = (object) external_api::clean_returnvalue(external::create_competency_framework_returns(), $result);
|
||||||
|
|
||||||
$id = $result->id;
|
$id = $result->id;
|
||||||
|
@ -186,7 +192,8 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
||||||
public function test_delete_competency_frameworks_with_read_permissions() {
|
public function test_delete_competency_frameworks_with_read_permissions() {
|
||||||
$this->setExpectedException('required_capability_exception');
|
$this->setExpectedException('required_capability_exception');
|
||||||
$this->setUser($this->creator);
|
$this->setUser($this->creator);
|
||||||
$result = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true);
|
$result = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true,
|
||||||
|
array('contextid' => context_system::instance()->id));
|
||||||
$result = (object) external_api::clean_returnvalue(external::create_competency_framework_returns(), $result);
|
$result = (object) external_api::clean_returnvalue(external::create_competency_framework_returns(), $result);
|
||||||
|
|
||||||
$id = $result->id;
|
$id = $result->id;
|
||||||
|
@ -200,7 +207,8 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
||||||
*/
|
*/
|
||||||
public function test_update_competency_frameworks_with_manage_permissions() {
|
public function test_update_competency_frameworks_with_manage_permissions() {
|
||||||
$this->setUser($this->creator);
|
$this->setUser($this->creator);
|
||||||
$result = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true);
|
$result = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true,
|
||||||
|
array('contextid' => context_system::instance()->id));
|
||||||
$result = (object) external_api::clean_returnvalue(external::create_competency_framework_returns(), $result);
|
$result = (object) external_api::clean_returnvalue(external::create_competency_framework_returns(), $result);
|
||||||
|
|
||||||
$result = external::update_competency_framework($result->id, 'shortname2',
|
$result = external::update_competency_framework($result->id, 'shortname2',
|
||||||
|
@ -216,7 +224,8 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
||||||
public function test_update_competency_frameworks_with_read_permissions() {
|
public function test_update_competency_frameworks_with_read_permissions() {
|
||||||
$this->setExpectedException('required_capability_exception');
|
$this->setExpectedException('required_capability_exception');
|
||||||
$this->setUser($this->creator);
|
$this->setUser($this->creator);
|
||||||
$result = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true);
|
$result = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true,
|
||||||
|
array('contextid' => context_system::instance()->id));
|
||||||
$result = (object) external_api::clean_returnvalue(external::create_competency_framework_returns(), $result);
|
$result = (object) external_api::clean_returnvalue(external::create_competency_framework_returns(), $result);
|
||||||
|
|
||||||
$this->setUser($this->user);
|
$this->setUser($this->user);
|
||||||
|
@ -229,16 +238,20 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
||||||
*/
|
*/
|
||||||
public function test_list_and_count_competency_frameworks_with_manage_permissions() {
|
public function test_list_and_count_competency_frameworks_with_manage_permissions() {
|
||||||
$this->setUser($this->creator);
|
$this->setUser($this->creator);
|
||||||
$result = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true);
|
$result = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true,
|
||||||
$result = external::create_competency_framework('shortname2', 'idnumber2', 'description', FORMAT_HTML, true);
|
array('contextid' => context_system::instance()->id));
|
||||||
$result = external::create_competency_framework('shortname3', 'idnumber3', 'description', FORMAT_HTML, true);
|
$result = external::create_competency_framework('shortname2', 'idnumber2', 'description', FORMAT_HTML, true,
|
||||||
|
array('contextid' => context_system::instance()->id));
|
||||||
|
$result = external::create_competency_framework('shortname3', 'idnumber3', 'description', FORMAT_HTML, true,
|
||||||
|
array('contextid' => context_system::instance()->id));
|
||||||
|
|
||||||
$result = external::count_competency_frameworks(array());
|
$result = external::count_competency_frameworks(array());
|
||||||
$result = external_api::clean_returnvalue(external::count_competency_frameworks_returns(), $result);
|
$result = external_api::clean_returnvalue(external::count_competency_frameworks_returns(), $result);
|
||||||
|
|
||||||
$this->assertEquals($result, 3);
|
$this->assertEquals($result, 3);
|
||||||
|
|
||||||
$result = external::list_competency_frameworks(array(), 'shortname', 'ASC', 0, 10);
|
$result = external::list_competency_frameworks('shortname', 'ASC', 0, 10,
|
||||||
|
array('contextid' => context_system::instance()->id), 'self');
|
||||||
$result = external_api::clean_returnvalue(external::list_competency_frameworks_returns(), $result);
|
$result = external_api::clean_returnvalue(external::list_competency_frameworks_returns(), $result);
|
||||||
|
|
||||||
$this->assertEquals(count($result), 3);
|
$this->assertEquals(count($result), 3);
|
||||||
|
@ -259,9 +272,12 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
||||||
*/
|
*/
|
||||||
public function test_list_and_count_competency_frameworks_with_read_permissions() {
|
public function test_list_and_count_competency_frameworks_with_read_permissions() {
|
||||||
$this->setUser($this->creator);
|
$this->setUser($this->creator);
|
||||||
$result = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true);
|
$result = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true,
|
||||||
$result = external::create_competency_framework('shortname2', 'idnumber2', 'description', FORMAT_HTML, true);
|
array('contextid' => context_system::instance()->id));
|
||||||
$result = external::create_competency_framework('shortname3', 'idnumber3', 'description', FORMAT_HTML, true);
|
$result = external::create_competency_framework('shortname2', 'idnumber2', 'description', FORMAT_HTML, true,
|
||||||
|
array('contextid' => context_system::instance()->id));
|
||||||
|
$result = external::create_competency_framework('shortname3', 'idnumber3', 'description', FORMAT_HTML, true,
|
||||||
|
array('contextid' => context_system::instance()->id));
|
||||||
|
|
||||||
$this->setUser($this->user);
|
$this->setUser($this->user);
|
||||||
$result = external::count_competency_frameworks(array());
|
$result = external::count_competency_frameworks(array());
|
||||||
|
@ -269,7 +285,8 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
||||||
|
|
||||||
$this->assertEquals($result, 3);
|
$this->assertEquals($result, 3);
|
||||||
|
|
||||||
$result = external::list_competency_frameworks(array(), 'shortname', 'ASC', 0, 10);
|
$result = external::list_competency_frameworks('shortname', 'ASC', 0, 10,
|
||||||
|
array('contextid' => context_system::instance()->id), 'self');
|
||||||
$result = external_api::clean_returnvalue(external::list_competency_frameworks_returns(), $result);
|
$result = external_api::clean_returnvalue(external::list_competency_frameworks_returns(), $result);
|
||||||
|
|
||||||
$this->assertEquals(count($result), 3);
|
$this->assertEquals(count($result), 3);
|
||||||
|
@ -285,67 +302,13 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
||||||
$this->assertEquals(true, $result->visible);
|
$this->assertEquals(true, $result->visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Test we can re-order competency frameworks.
|
|
||||||
*/
|
|
||||||
public function test_reorder_competency_framework() {
|
|
||||||
$this->setUser($this->creator);
|
|
||||||
$f1 = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true);
|
|
||||||
$f2 = external::create_competency_framework('shortname2', 'idnumber2', 'description', FORMAT_HTML, true);
|
|
||||||
$f3 = external::create_competency_framework('shortname3', 'idnumber3', 'description', FORMAT_HTML, true);
|
|
||||||
$f4 = external::create_competency_framework('shortname4', 'idnumber4', 'description', FORMAT_HTML, true);
|
|
||||||
$f5 = external::create_competency_framework('shortname5', 'idnumber5', 'description', FORMAT_HTML, true);
|
|
||||||
$f6 = external::create_competency_framework('shortname6', 'idnumber6', 'description', FORMAT_HTML, true);
|
|
||||||
|
|
||||||
// This is a move up.
|
|
||||||
$result = external::reorder_competency_framework($f5->id, $f2->id);
|
|
||||||
$result = external::list_competency_frameworks(array(), 'sortorder', 'ASC', 0, 10);
|
|
||||||
$result = external_api::clean_returnvalue(external::list_competency_frameworks_returns(), $result);
|
|
||||||
|
|
||||||
$r1 = (object) $result[0];
|
|
||||||
$r2 = (object) $result[1];
|
|
||||||
$r3 = (object) $result[2];
|
|
||||||
$r4 = (object) $result[3];
|
|
||||||
$r5 = (object) $result[4];
|
|
||||||
$r6 = (object) $result[5];
|
|
||||||
|
|
||||||
$this->assertEquals($f1->id, $r1->id);
|
|
||||||
$this->assertEquals($f5->id, $r2->id);
|
|
||||||
$this->assertEquals($f2->id, $r3->id);
|
|
||||||
$this->assertEquals($f3->id, $r4->id);
|
|
||||||
$this->assertEquals($f4->id, $r5->id);
|
|
||||||
$this->assertEquals($f6->id, $r6->id);
|
|
||||||
|
|
||||||
// This is a move down.
|
|
||||||
$result = external::reorder_competency_framework($f5->id, $f4->id);
|
|
||||||
$result = external::list_competency_frameworks(array(), 'sortorder', 'ASC', 0, 10);
|
|
||||||
$result = external_api::clean_returnvalue(external::list_competency_frameworks_returns(), $result);
|
|
||||||
|
|
||||||
$r1 = (object) $result[0];
|
|
||||||
$r2 = (object) $result[1];
|
|
||||||
$r3 = (object) $result[2];
|
|
||||||
$r4 = (object) $result[3];
|
|
||||||
$r5 = (object) $result[4];
|
|
||||||
$r6 = (object) $result[5];
|
|
||||||
|
|
||||||
$this->assertEquals($f1->id, $r1->id);
|
|
||||||
$this->assertEquals($f2->id, $r2->id);
|
|
||||||
$this->assertEquals($f3->id, $r3->id);
|
|
||||||
$this->assertEquals($f4->id, $r4->id);
|
|
||||||
$this->assertEquals($f5->id, $r5->id);
|
|
||||||
$this->assertEquals($f6->id, $r6->id);
|
|
||||||
|
|
||||||
$this->setExpectedException('required_capability_exception');
|
|
||||||
$this->setUser($this->user);
|
|
||||||
$result = external::reorder_competency_framework($f5->id, $f4->id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test we can't create a competency with only read permissions.
|
* Test we can't create a competency with only read permissions.
|
||||||
*/
|
*/
|
||||||
public function test_create_competency_with_read_permissions() {
|
public function test_create_competency_with_read_permissions() {
|
||||||
$this->setExpectedException('required_capability_exception');
|
$this->setExpectedException('required_capability_exception');
|
||||||
$framework = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true);
|
$framework = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true,
|
||||||
|
array('contextid' => context_system::instance()->id));
|
||||||
$framework = (object) external_api::clean_returnvalue(external::create_competency_framework_returns(), $framework);
|
$framework = (object) external_api::clean_returnvalue(external::create_competency_framework_returns(), $framework);
|
||||||
$this->setUser($this->user);
|
$this->setUser($this->user);
|
||||||
$competency = external::create_competency('shortname', 'idnumber', 'description', FORMAT_HTML, true, $framework->id, 0);
|
$competency = external::create_competency('shortname', 'idnumber', 'description', FORMAT_HTML, true, $framework->id, 0);
|
||||||
|
@ -356,7 +319,8 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
||||||
*/
|
*/
|
||||||
public function test_create_competency_with_manage_permissions() {
|
public function test_create_competency_with_manage_permissions() {
|
||||||
$this->setUser($this->creator);
|
$this->setUser($this->creator);
|
||||||
$framework = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true);
|
$framework = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true,
|
||||||
|
array('contextid' => context_system::instance()->id));
|
||||||
$framework = (object) external_api::clean_returnvalue(external::create_competency_framework_returns(), $framework);
|
$framework = (object) external_api::clean_returnvalue(external::create_competency_framework_returns(), $framework);
|
||||||
|
|
||||||
$competency = external::create_competency('shortname', 'idnumber', 'description', FORMAT_HTML, true, $framework->id, 0);
|
$competency = external::create_competency('shortname', 'idnumber', 'description', FORMAT_HTML, true, $framework->id, 0);
|
||||||
|
@ -379,7 +343,8 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
||||||
*/
|
*/
|
||||||
public function test_create_competency_with_nasty_data() {
|
public function test_create_competency_with_nasty_data() {
|
||||||
$this->setUser($this->creator);
|
$this->setUser($this->creator);
|
||||||
$framework = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true);
|
$framework = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true,
|
||||||
|
array('contextid' => context_system::instance()->id));
|
||||||
$framework = (object) external_api::clean_returnvalue(external::create_competency_framework_returns(), $framework);
|
$framework = (object) external_api::clean_returnvalue(external::create_competency_framework_returns(), $framework);
|
||||||
$this->setExpectedException('invalid_parameter_exception');
|
$this->setExpectedException('invalid_parameter_exception');
|
||||||
$competency = external::create_competency('shortname<a href="">', 'id;"number',
|
$competency = external::create_competency('shortname<a href="">', 'id;"number',
|
||||||
|
@ -391,7 +356,8 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
||||||
*/
|
*/
|
||||||
public function test_read_competencies_with_manage_permissions() {
|
public function test_read_competencies_with_manage_permissions() {
|
||||||
$this->setUser($this->creator);
|
$this->setUser($this->creator);
|
||||||
$framework = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true);
|
$framework = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true,
|
||||||
|
array('contextid' => context_system::instance()->id));
|
||||||
$framework = (object) external_api::clean_returnvalue(external::create_competency_framework_returns(), $framework);
|
$framework = (object) external_api::clean_returnvalue(external::create_competency_framework_returns(), $framework);
|
||||||
$result = external::create_competency('shortname', 'idnumber', 'description', FORMAT_HTML, true, $framework->id, 0);
|
$result = external::create_competency('shortname', 'idnumber', 'description', FORMAT_HTML, true, $framework->id, 0);
|
||||||
$result = (object) external_api::clean_returnvalue(external::create_competency_returns(), $result);
|
$result = (object) external_api::clean_returnvalue(external::create_competency_returns(), $result);
|
||||||
|
@ -417,7 +383,8 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
||||||
*/
|
*/
|
||||||
public function test_read_competencies_with_read_permissions() {
|
public function test_read_competencies_with_read_permissions() {
|
||||||
$this->setUser($this->creator);
|
$this->setUser($this->creator);
|
||||||
$framework = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true);
|
$framework = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true,
|
||||||
|
array('contextid' => context_system::instance()->id));
|
||||||
$framework = (object) external_api::clean_returnvalue(external::create_competency_framework_returns(), $framework);
|
$framework = (object) external_api::clean_returnvalue(external::create_competency_framework_returns(), $framework);
|
||||||
$result = external::create_competency('shortname', 'idnumber', 'description', FORMAT_HTML, true, $framework->id, 0);
|
$result = external::create_competency('shortname', 'idnumber', 'description', FORMAT_HTML, true, $framework->id, 0);
|
||||||
$result = (object) external_api::clean_returnvalue(external::create_competency_returns(), $result);
|
$result = (object) external_api::clean_returnvalue(external::create_competency_returns(), $result);
|
||||||
|
@ -445,7 +412,8 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
||||||
*/
|
*/
|
||||||
public function test_delete_competency_with_manage_permissions() {
|
public function test_delete_competency_with_manage_permissions() {
|
||||||
$this->setUser($this->creator);
|
$this->setUser($this->creator);
|
||||||
$framework = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true);
|
$framework = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true,
|
||||||
|
array('contextid' => context_system::instance()->id));
|
||||||
$framework = (object) external_api::clean_returnvalue(external::create_competency_framework_returns(), $framework);
|
$framework = (object) external_api::clean_returnvalue(external::create_competency_framework_returns(), $framework);
|
||||||
$result = external::create_competency('shortname', 'idnumber', 'description', FORMAT_HTML, true, $framework->id, 0);
|
$result = external::create_competency('shortname', 'idnumber', 'description', FORMAT_HTML, true, $framework->id, 0);
|
||||||
$result = (object) external_api::clean_returnvalue(external::create_competency_returns(), $result);
|
$result = (object) external_api::clean_returnvalue(external::create_competency_returns(), $result);
|
||||||
|
@ -463,7 +431,8 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
||||||
public function test_delete_competency_with_read_permissions() {
|
public function test_delete_competency_with_read_permissions() {
|
||||||
$this->setExpectedException('required_capability_exception');
|
$this->setExpectedException('required_capability_exception');
|
||||||
$this->setUser($this->creator);
|
$this->setUser($this->creator);
|
||||||
$framework = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true);
|
$framework = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true,
|
||||||
|
array('contextid' => context_system::instance()->id));
|
||||||
$framework = (object) external_api::clean_returnvalue(external::create_competency_framework_returns(), $framework);
|
$framework = (object) external_api::clean_returnvalue(external::create_competency_framework_returns(), $framework);
|
||||||
$result = external::create_competency('shortname', 'idnumber', 'description', FORMAT_HTML, true, $framework->id, 0);
|
$result = external::create_competency('shortname', 'idnumber', 'description', FORMAT_HTML, true, $framework->id, 0);
|
||||||
$result = (object) external_api::clean_returnvalue(external::create_competency_returns(), $result);
|
$result = (object) external_api::clean_returnvalue(external::create_competency_returns(), $result);
|
||||||
|
@ -479,7 +448,8 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
||||||
*/
|
*/
|
||||||
public function test_update_competency_with_manage_permissions() {
|
public function test_update_competency_with_manage_permissions() {
|
||||||
$this->setUser($this->creator);
|
$this->setUser($this->creator);
|
||||||
$framework = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true);
|
$framework = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true,
|
||||||
|
array('contextid' => context_system::instance()->id));
|
||||||
$framework = (object) external_api::clean_returnvalue(external::create_competency_framework_returns(), $framework);
|
$framework = (object) external_api::clean_returnvalue(external::create_competency_framework_returns(), $framework);
|
||||||
$result = external::create_competency('shortname', 'idnumber', 'description', FORMAT_HTML, true, $framework->id, 0);
|
$result = external::create_competency('shortname', 'idnumber', 'description', FORMAT_HTML, true, $framework->id, 0);
|
||||||
$result = (object) external_api::clean_returnvalue(external::create_competency_returns(), $result);
|
$result = (object) external_api::clean_returnvalue(external::create_competency_returns(), $result);
|
||||||
|
@ -496,7 +466,8 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
||||||
public function test_update_competency_with_read_permissions() {
|
public function test_update_competency_with_read_permissions() {
|
||||||
$this->setExpectedException('required_capability_exception');
|
$this->setExpectedException('required_capability_exception');
|
||||||
$this->setUser($this->creator);
|
$this->setUser($this->creator);
|
||||||
$framework = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true);
|
$framework = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true,
|
||||||
|
array('contextid' => context_system::instance()->id));
|
||||||
$framework = (object) external_api::clean_returnvalue(external::create_competency_framework_returns(), $framework);
|
$framework = (object) external_api::clean_returnvalue(external::create_competency_framework_returns(), $framework);
|
||||||
$result = external::create_competency('shortname', 'idnumber', 'description', FORMAT_HTML, true, $framework->id, 0);
|
$result = external::create_competency('shortname', 'idnumber', 'description', FORMAT_HTML, true, $framework->id, 0);
|
||||||
$result = (object) external_api::clean_returnvalue(external::create_competency_returns(), $result);
|
$result = (object) external_api::clean_returnvalue(external::create_competency_returns(), $result);
|
||||||
|
@ -510,7 +481,8 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
||||||
*/
|
*/
|
||||||
public function test_list_and_count_competencies_with_manage_permissions() {
|
public function test_list_and_count_competencies_with_manage_permissions() {
|
||||||
$this->setUser($this->creator);
|
$this->setUser($this->creator);
|
||||||
$framework = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true);
|
$framework = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true,
|
||||||
|
array('contextid' => context_system::instance()->id));
|
||||||
$framework = (object) external_api::clean_returnvalue(external::create_competency_framework_returns(), $framework);
|
$framework = (object) external_api::clean_returnvalue(external::create_competency_framework_returns(), $framework);
|
||||||
$result = external::create_competency('shortname', 'idnumber', 'description', FORMAT_HTML, true, $framework->id, 0);
|
$result = external::create_competency('shortname', 'idnumber', 'description', FORMAT_HTML, true, $framework->id, 0);
|
||||||
$result = external::create_competency('shortname2', 'idnumber2', 'description2', FORMAT_HTML, true, $framework->id, 0);
|
$result = external::create_competency('shortname2', 'idnumber2', 'description2', FORMAT_HTML, true, $framework->id, 0);
|
||||||
|
@ -521,7 +493,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
||||||
|
|
||||||
$this->assertEquals($result, 3);
|
$this->assertEquals($result, 3);
|
||||||
|
|
||||||
$result = external::list_competencies(array(), 'shortname', 'ASC', 0, 10);
|
array('id' => $result = external::list_competencies(array(), 'shortname', 'ASC', 0, 10, context_system::instance()->id));
|
||||||
$result = external_api::clean_returnvalue(external::list_competencies_returns(), $result);
|
$result = external_api::clean_returnvalue(external::list_competencies_returns(), $result);
|
||||||
|
|
||||||
$this->assertEquals(count($result), 3);
|
$this->assertEquals(count($result), 3);
|
||||||
|
@ -541,7 +513,8 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
||||||
*/
|
*/
|
||||||
public function test_list_and_count_competencies_with_read_permissions() {
|
public function test_list_and_count_competencies_with_read_permissions() {
|
||||||
$this->setUser($this->creator);
|
$this->setUser($this->creator);
|
||||||
$framework = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true);
|
$framework = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true,
|
||||||
|
array('contextid' => context_system::instance()->id));
|
||||||
$framework = (object) external_api::clean_returnvalue(external::create_competency_framework_returns(), $framework);
|
$framework = (object) external_api::clean_returnvalue(external::create_competency_framework_returns(), $framework);
|
||||||
$result = external::create_competency('shortname', 'idnumber', 'description', FORMAT_HTML, true, $framework->id, 0);
|
$result = external::create_competency('shortname', 'idnumber', 'description', FORMAT_HTML, true, $framework->id, 0);
|
||||||
$result = external::create_competency('shortname2', 'idnumber2', 'description2', FORMAT_HTML, true, $framework->id, 0);
|
$result = external::create_competency('shortname2', 'idnumber2', 'description2', FORMAT_HTML, true, $framework->id, 0);
|
||||||
|
@ -554,7 +527,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
||||||
|
|
||||||
$this->assertEquals($result, 3);
|
$this->assertEquals($result, 3);
|
||||||
|
|
||||||
$result = external::list_competencies(array(), 'shortname', 'ASC', 0, 10);
|
array('id' => $result = external::list_competencies(array(), 'shortname', 'ASC', 0, 10, context_system::instance()->id));
|
||||||
$result = external_api::clean_returnvalue(external::list_competencies_returns(), $result);
|
$result = external_api::clean_returnvalue(external::list_competencies_returns(), $result);
|
||||||
|
|
||||||
$this->assertEquals(count($result), 3);
|
$this->assertEquals(count($result), 3);
|
||||||
|
@ -574,7 +547,8 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
||||||
*/
|
*/
|
||||||
public function test_search_competencies_with_read_permissions() {
|
public function test_search_competencies_with_read_permissions() {
|
||||||
$this->setUser($this->creator);
|
$this->setUser($this->creator);
|
||||||
$framework = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true);
|
$framework = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true,
|
||||||
|
array('contextid' => context_system::instance()->id));
|
||||||
$framework = (object) external_api::clean_returnvalue(external::create_competency_framework_returns(), $framework);
|
$framework = (object) external_api::clean_returnvalue(external::create_competency_framework_returns(), $framework);
|
||||||
$result = external::create_competency('shortname', 'idnumber', 'description', FORMAT_HTML, true, $framework->id, 0);
|
$result = external::create_competency('shortname', 'idnumber', 'description', FORMAT_HTML, true, $framework->id, 0);
|
||||||
$result = external::create_competency('shortname2', 'idnumber2', 'description2', FORMAT_HTML, true, $framework->id, 0);
|
$result = external::create_competency('shortname2', 'idnumber2', 'description2', FORMAT_HTML, true, $framework->id, 0);
|
||||||
|
@ -783,7 +757,8 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
||||||
$template = (object) external_api::clean_returnvalue(external::create_template_returns(), $template);
|
$template = (object) external_api::clean_returnvalue(external::create_template_returns(), $template);
|
||||||
|
|
||||||
// Create a competency.
|
// Create a competency.
|
||||||
$framework = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true);
|
$framework = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true,
|
||||||
|
array('contextid' => context_system::instance()->id));
|
||||||
$framework = (object) external_api::clean_returnvalue(external::create_competency_framework_returns(), $framework);
|
$framework = (object) external_api::clean_returnvalue(external::create_competency_framework_returns(), $framework);
|
||||||
$competency = external::create_competency('shortname', 'idnumber', 'description', FORMAT_HTML, true, $framework->id, 0);
|
$competency = external::create_competency('shortname', 'idnumber', 'description', FORMAT_HTML, true, $framework->id, 0);
|
||||||
$competency = (object) external_api::clean_returnvalue(external::create_competency_returns(), $competency);
|
$competency = (object) external_api::clean_returnvalue(external::create_competency_returns(), $competency);
|
||||||
|
@ -817,7 +792,8 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
||||||
$template = (object) external_api::clean_returnvalue(external::create_template_returns(), $template);
|
$template = (object) external_api::clean_returnvalue(external::create_template_returns(), $template);
|
||||||
|
|
||||||
// Create a competency.
|
// Create a competency.
|
||||||
$framework = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true);
|
$framework = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true,
|
||||||
|
array('contextid' => context_system::instance()->id));
|
||||||
$framework = (object) external_api::clean_returnvalue(external::create_competency_framework_returns(), $framework);
|
$framework = (object) external_api::clean_returnvalue(external::create_competency_framework_returns(), $framework);
|
||||||
$competency = external::create_competency('shortname', 'idnumber', 'description', FORMAT_HTML, true, $framework->id, 0);
|
$competency = external::create_competency('shortname', 'idnumber', 'description', FORMAT_HTML, true, $framework->id, 0);
|
||||||
$competency = (object) external_api::clean_returnvalue(external::create_competency_returns(), $competency);
|
$competency = (object) external_api::clean_returnvalue(external::create_competency_returns(), $competency);
|
||||||
|
@ -860,7 +836,8 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
||||||
$template = (object) external_api::clean_returnvalue(external::create_template_returns(), $template);
|
$template = (object) external_api::clean_returnvalue(external::create_template_returns(), $template);
|
||||||
|
|
||||||
// Create a competency framework.
|
// Create a competency framework.
|
||||||
$framework = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true);
|
$framework = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true,
|
||||||
|
array('contextid' => context_system::instance()->id));
|
||||||
$framework = (object) external_api::clean_returnvalue(external::create_competency_framework_returns(), $framework);
|
$framework = (object) external_api::clean_returnvalue(external::create_competency_framework_returns(), $framework);
|
||||||
|
|
||||||
// Create multiple competencies.
|
// Create multiple competencies.
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
defined('MOODLE_INTERNAL') || die();
|
defined('MOODLE_INTERNAL') || die();
|
||||||
|
|
||||||
$plugin->version = 2015052404; // The current plugin version (Date: YYYYMMDDXX).
|
$plugin->version = 2015052405; // The current plugin version (Date: YYYYMMDDXX).
|
||||||
$plugin->requires = 2014110400; // Requires this Moodle version.
|
$plugin->requires = 2014110400; // Requires this Moodle version.
|
||||||
$plugin->component = 'tool_lp'; // Full name of the plugin (used for diagnostics).
|
$plugin->component = 'tool_lp'; // Full name of the plugin (used for diagnostics).
|
||||||
|
|
||||||
|
|
|
@ -4679,6 +4679,13 @@ class settings_navigation extends navigation_node {
|
||||||
$categorynode->add(get_string('filters', 'admin'), $url, self::TYPE_SETTING, null, 'filters', new pix_icon('i/filter', ''));
|
$categorynode->add(get_string('filters', 'admin'), $url, self::TYPE_SETTING, null, 'filters', new pix_icon('i/filter', ''));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Competency frameworks.
|
||||||
|
if (has_capability('tool/lp:competencymanage', $catcontext)) {
|
||||||
|
$url = new moodle_url('/admin/tool/lp/competencyframeworks.php', array('pagecontextid' => $catcontext->id));
|
||||||
|
$categorynode->add(get_string('competencyframeworks', 'tool_lp'), $url, self::TYPE_SETTING, null,
|
||||||
|
'competencyframeworks', new pix_icon('i/settings', ''));
|
||||||
|
}
|
||||||
|
|
||||||
// Restore.
|
// Restore.
|
||||||
if (has_capability('moodle/restore:restorecourse', $catcontext)) {
|
if (has_capability('moodle/restore:restorecourse', $catcontext)) {
|
||||||
$url = new moodle_url('/backup/restorefile.php', array('contextid' => $catcontext->id));
|
$url = new moodle_url('/backup/restorefile.php', array('contextid' => $catcontext->id));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue