MDL-49459 Learning plans: Support for creating and editing competency frameworks.
This includes an API (\tool_lp\competency_api), a set of web services, unit tests for the web services and a nice UI built as an admin tool.
This commit is contained in:
committed by
Frederic Massart
parent
c2f30eeddb
commit
d9a39950b2
@@ -0,0 +1 @@
|
||||
define(["jquery","core/templates","core/ajax","core/notification"],function(a,b,c,d){var e=0,f=function(c,d){a('[data-region="managecompetencies"]').replaceWith(c),b.runTemplateJS(d)},g=function(a){b.render("tool_lp/manage_competency_frameworks_page",a).done(f).fail(d.exception)},h=function(){var a=c.call([{methodname:"tool_lp_delete_competency_framework",args:{id:e}},{methodname:"tool_lp_data_for_competency_frameworks_manage_page",args:[]}]);a[1].done(g).fail(d.exception)},i=function(b){b.preventDefault();var c=a(this).attr("data-frameworkid");e=c,d.confirm("Confirm",'Delete competency framework "blah"?',"Delete","Cancel",h)};return{init:function(){a('[data-region="managecompetencies"]').on("click",'[data-action="deletecompetencyframework"]',i)}}});
|
||||
@@ -0,0 +1 @@
|
||||
define(["core/dragdrop-reorder","core/str","core/notification","jquery","core/ajax"],function(a,b,c,d,e){var f=function(a,b){var f=d(a).data("frameworkid"),g=d(b).data("frameworkid"),h=e.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(b){a.dragdrop("movecompetencyframework",b,{identifier:"movecompetencyframework",component:"tool_lp"},{identifier:"movecompetencyframeworkafter",component:"tool_lp"},"drag-samenode","drag-parentnode","drag-handlecontainer",f)}).fail(c.exception)}}});
|
||||
@@ -0,0 +1,370 @@
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* Handle selection changes and actions on the competency tree.
|
||||
*
|
||||
* @module tool_lp/competencyselect
|
||||
* @package tool_lp
|
||||
* @copyright 2015 Damyon Wiese <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
define(['jquery', 'core/url', 'core/templates', 'core/notification', 'core/str', 'core/ajax', 'core/dragdrop-reorder', 'core/tree', 'core/dialogue', 'core/menu'],
|
||||
function($, url, templates, notification, str, ajax, dragdrop, ariatree, dialogue, menu) {
|
||||
|
||||
// Private variables and functions.
|
||||
var treeModel = null;
|
||||
|
||||
var moveSource = null;
|
||||
var moveTarget = null;
|
||||
|
||||
var addHandler = function(e) {
|
||||
e.preventDefault();
|
||||
var parent = $('[data-region="competencyactions"]').data('competency');
|
||||
|
||||
var params = {
|
||||
competencyframeworkid : treeModel.getCompetencyFrameworkId()
|
||||
};
|
||||
|
||||
if (parent == null) {
|
||||
// We are adding at the root node.
|
||||
} else {
|
||||
// We are adding at a sub node.
|
||||
params['parentid'] = parent.id;
|
||||
}
|
||||
var queryparams = $.param(params);
|
||||
var actionurl = url.relativeUrl('/admin/tool/lp/editcompetency.php?' + queryparams);
|
||||
window.location = actionurl;
|
||||
};
|
||||
|
||||
var doMove = function() {
|
||||
if (typeof (moveTarget) === "undefined") {
|
||||
// This is a top level node.
|
||||
moveTarget = 0;
|
||||
}
|
||||
|
||||
if (moveTarget == moveSource) {
|
||||
return;
|
||||
}
|
||||
var frameworkid = $('[data-region="filtercompetencies"]').data('frameworkid');
|
||||
var requests = ajax.call([{
|
||||
methodname: 'tool_lp_set_parent_competency',
|
||||
args: { competencyid: moveSource, parentid: moveTarget }
|
||||
}, {
|
||||
methodname: 'tool_lp_data_for_competencies_manage_page',
|
||||
args: { competencyframeworkid: frameworkid,
|
||||
search: $('[data-region="filtercompetencies"] input').val() }
|
||||
}]);
|
||||
requests[1].done(reloadPage).fail(notification.exception);
|
||||
};
|
||||
|
||||
var initMovePopup = function(popup) {
|
||||
var movetree = new ariatree('[data-enhance=movetree]', function(target) {
|
||||
moveTarget = $(target).data('id');
|
||||
});
|
||||
|
||||
var body = $(popup.getContent());
|
||||
body.on('click', '[data-action="move"]', function(e) { popup.close(); doMove() });
|
||||
body.on('click', '[data-action="cancel"]', function(e) { popup.close(); });
|
||||
};
|
||||
|
||||
var addCompetencyChildren = function(parent, competencies) {
|
||||
var i;
|
||||
|
||||
for (i = 0; i < competencies.length; i++) {
|
||||
if (competencies[i].parentid == parent.id) {
|
||||
parent.haschildren = true;
|
||||
competencies[i].children = [];
|
||||
competencies[i].haschildren = false;
|
||||
parent.children[parent.children.length] = competencies[i];
|
||||
addCompetencyChildren(competencies[i], competencies);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var moveHandler = function(e) {
|
||||
e.preventDefault();
|
||||
var competency = $('[data-region="competencyactions"]').data('competency');
|
||||
|
||||
// Remember what we are moving.
|
||||
moveSource = competency.id;
|
||||
|
||||
// Load data for the template.
|
||||
var requests = ajax.call([
|
||||
{
|
||||
methodname: 'tool_lp_search_competencies',
|
||||
args: {
|
||||
competencyframeworkid: competency.competencyframeworkid,
|
||||
searchtext: ''
|
||||
}
|
||||
},{
|
||||
methodname: 'tool_lp_read_competency_framework',
|
||||
args: {
|
||||
id: competency.competencyframeworkid
|
||||
}
|
||||
}
|
||||
]);
|
||||
|
||||
// When all data has arrived, continue.
|
||||
$.when.apply(null, requests).done(function(competencies, framework) {
|
||||
|
||||
// Expand the list of competencies into a tree.
|
||||
var i, competenciestree = [];
|
||||
for (i = 0; i < competencies.length; i++) {
|
||||
var onecompetency = competencies[i];
|
||||
if (onecompetency.parentid == 0) {
|
||||
onecompetency.children = [];
|
||||
onecompetency.haschildren = 0;
|
||||
competenciestree[competenciestree.length] = onecompetency;
|
||||
addCompetencyChildren(onecompetency, competencies);
|
||||
}
|
||||
}
|
||||
|
||||
var strings = str.get_strings([
|
||||
{ key: 'movecompetency', component: 'tool_lp', param: competency.shortname },
|
||||
{ key: 'move', component: 'tool_lp' },
|
||||
{ key: 'cancel', component: 'tool_lp' }
|
||||
]).done(function (strings) {
|
||||
|
||||
var context = {
|
||||
framework: framework,
|
||||
competencies: competenciestree
|
||||
};
|
||||
|
||||
templates.render('tool_lp/competencies_move_tree', context)
|
||||
.done(function(tree) {
|
||||
var popup = new dialogue(
|
||||
strings[0], // Move competency x.
|
||||
tree, // The move tree.
|
||||
initMovePopup
|
||||
);
|
||||
|
||||
}).fail(notification.exception);
|
||||
|
||||
}).fail(notification.exception);
|
||||
|
||||
}).fail(notification.exception);
|
||||
|
||||
};
|
||||
|
||||
var editHandler = function(e) {
|
||||
e.preventDefault();
|
||||
var competency = $('[data-region="competencyactions"]').data('competency');
|
||||
|
||||
var params = {
|
||||
competencyframeworkid : treeModel.getCompetencyFrameworkId(),
|
||||
id : competency.id,
|
||||
parentid: competency.parentid
|
||||
};
|
||||
|
||||
var queryparams = $.param(params);
|
||||
var actionurl = url.relativeUrl('/admin/tool/lp/editcompetency.php?' + queryparams);
|
||||
window.location = actionurl;
|
||||
};
|
||||
|
||||
var reloadPage = function(context) {
|
||||
templates.render('tool_lp/manage_competencies_page', context)
|
||||
.done(function(newhtml, newjs) {
|
||||
$('[data-region="managecompetencies"]').replaceWith(newhtml);
|
||||
templates.runTemplateJS(newjs);
|
||||
})
|
||||
.fail(notification.exception);
|
||||
};
|
||||
|
||||
var updateSearchHandler = function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var frameworkid = $('[data-region="filtercompetencies"]').data('frameworkid');
|
||||
|
||||
var requests = ajax.call([{
|
||||
methodname: 'tool_lp_data_for_competencies_manage_page',
|
||||
args: { competencyframeworkid: frameworkid,
|
||||
search: $('[data-region="filtercompetencies"] input').val() }
|
||||
}]);
|
||||
requests[0].done(reloadPage).fail(notification.exception);
|
||||
};
|
||||
|
||||
var moveUpHandler = function() {
|
||||
// We are chaining ajax requests here.
|
||||
var competency = $('[data-region="competencyactions"]').data('competency');
|
||||
var requests = ajax.call([{
|
||||
methodname: 'tool_lp_move_up_competency',
|
||||
args: { id: competency.id }
|
||||
}, {
|
||||
methodname: 'tool_lp_data_for_competencies_manage_page',
|
||||
args: { competencyframeworkid: competency.competencyframeworkid,
|
||||
search: $('[data-region="filtercompetencies"] input').val() }
|
||||
}]);
|
||||
requests[1].done(reloadPage).fail(notification.exception);
|
||||
};
|
||||
|
||||
var moveDownHandler = function() {
|
||||
// We are chaining ajax requests here.
|
||||
var competency = $('[data-region="competencyactions"]').data('competency');
|
||||
var requests = ajax.call([{
|
||||
methodname: 'tool_lp_move_down_competency',
|
||||
args: { id: competency.id }
|
||||
}, {
|
||||
methodname: 'tool_lp_data_for_competencies_manage_page',
|
||||
args: { competencyframeworkid: competency.competencyframeworkid,
|
||||
search: $('[data-region="filtercompetencies"] input').val() }
|
||||
}]);
|
||||
requests[1].done(reloadPage).fail(notification.exception);
|
||||
};
|
||||
|
||||
var seeCoursesHandler = function(e) {
|
||||
e.preventDefault();
|
||||
var competency = $('[data-region="competencyactions"]').data('competency');
|
||||
var localthis = this;
|
||||
|
||||
var requests = ajax.call([{
|
||||
methodname: 'tool_lp_list_courses_using_competency',
|
||||
args: { id: competency.id }
|
||||
}]);
|
||||
|
||||
requests[0].done(function(courses) {
|
||||
var context = {
|
||||
courseviewurl: url.relativeUrl('/course/view.php'),
|
||||
courses: courses
|
||||
};
|
||||
templates.render('tool_lp/linked_courses_summary', context).done(function(html) {
|
||||
str.get_string('linkedcourses', 'tool_lp').done(function (linkedcourses) {
|
||||
var popup = new dialogue(
|
||||
linkedcourses, // Title.
|
||||
html, // The linked courses.
|
||||
initMovePopup
|
||||
);
|
||||
}).fail(notification.exception);
|
||||
}).fail(notification.exception);
|
||||
}).fail(notification.exception);
|
||||
}
|
||||
|
||||
var doDelete = function() {
|
||||
// We are chaining ajax requests here.
|
||||
var competency = $('[data-region="competencyactions"]').data('competency');
|
||||
var requests = ajax.call([{
|
||||
methodname: 'tool_lp_delete_competency',
|
||||
args: { id: competency.id }
|
||||
}, {
|
||||
methodname: 'tool_lp_data_for_competencies_manage_page',
|
||||
args: { competencyframeworkid: competency.competencyframeworkid,
|
||||
search: $('[data-region="filtercompetencies"] input').val() }
|
||||
}]);
|
||||
requests[1].done(reloadPage).fail(notification.exception);
|
||||
};
|
||||
|
||||
var deleteHandler = function(e) {
|
||||
e.preventDefault();
|
||||
var competency = $('[data-region="competencyactions"]').data('competency');
|
||||
|
||||
templates.render('tool_lp/competency_summary', competency)
|
||||
.done(function(html) {
|
||||
|
||||
var strings = str.get_strings([
|
||||
{ key: 'confirm', component: 'tool_lp' },
|
||||
{ key: 'deletecompetency', component: 'tool_lp', param: html },
|
||||
{ key: 'delete', component: 'tool_lp' },
|
||||
{ key: 'cancel', component: 'tool_lp' }
|
||||
]).done(function (strings) {
|
||||
notification.confirm(
|
||||
strings[0], // Confirm.
|
||||
strings[1], // Delete competency X?
|
||||
strings[2], // Delete.
|
||||
strings[3], // Cancel.
|
||||
doDelete
|
||||
);
|
||||
}).fail(notification.exception);
|
||||
}).fail(notification.exception);
|
||||
|
||||
};
|
||||
|
||||
var dragStart = function(e) {
|
||||
e.originalEvent.dataTransfer.setData('text', $(e.target).data('id'));
|
||||
};
|
||||
|
||||
var allowDrop = function(e) {
|
||||
e.originalEvent.dataTransfer.dropEffect = 'move';
|
||||
e.preventDefault();
|
||||
};
|
||||
|
||||
var dragEnter = function(e) {
|
||||
e.preventDefault();
|
||||
$(this).addClass('currentdragtarget');
|
||||
}
|
||||
|
||||
var dragLeave = function(e) {
|
||||
e.preventDefault();
|
||||
$(this).removeClass('currentdragtarget');
|
||||
}
|
||||
|
||||
var dropOver = function(e) {
|
||||
e.preventDefault();
|
||||
moveSource = e.originalEvent.dataTransfer.getData('text');
|
||||
moveTarget = $(e.target).data('id');
|
||||
$(this).removeClass('currentdragtarget');
|
||||
|
||||
doMove();
|
||||
};
|
||||
|
||||
return {
|
||||
init: function(model) {
|
||||
treeModel = model;
|
||||
str.get_string('edit', 'core').done(function (edit) {
|
||||
menu.menu(edit, '.competencyactionsmenu');
|
||||
|
||||
$('[data-region="competencyactions"]').on('click', '[data-action="add"]', addHandler);
|
||||
$('[data-region="competencyactions"]').on('click', '[data-action="edit"]', editHandler);
|
||||
$('[data-region="competencyactions"]').on('click', '[data-action="delete"]', deleteHandler);
|
||||
$('[data-region="competencyactions"]').on('click', '[data-action="move"]', moveHandler);
|
||||
$('[data-region="competencyactions"]').on('click', '[data-action="moveup"]', moveUpHandler);
|
||||
$('[data-region="competencyactions"]').on('click', '[data-action="movedown"]', moveDownHandler);
|
||||
$('[data-region="competencyactions"]').on('click', '[data-action="linkedcourses"]', seeCoursesHandler);
|
||||
|
||||
}).fail(notification.exception);
|
||||
$('[data-region="filtercompetencies"]').on('submit', updateSearchHandler);
|
||||
// Simple html5 drag drop because we already added an accessible alternative.
|
||||
$('[data-region="managecompetencies"] li').on('dragstart', dragStart);
|
||||
$('[data-region="managecompetencies"] li').on('dragover', allowDrop);
|
||||
$('[data-region="managecompetencies"] li').on('dragenter', dragEnter);
|
||||
$('[data-region="managecompetencies"] li').on('dragleave', dragLeave);
|
||||
$('[data-region="managecompetencies"] li').on('drop', dropOver);
|
||||
},
|
||||
// Public variables and functions.
|
||||
selectionChanged: function(node) {
|
||||
var id = $(node).data('id');
|
||||
if (typeof id === "undefined") {
|
||||
// Assume this is the root of the tree.
|
||||
// Here we are only getting the text from the top of the tree, to do it we clone the tree,
|
||||
// remove all children and then call text on the result.
|
||||
$('[data-region="competencyinfo"]').html(node.clone().children().remove().end().text());
|
||||
$('[data-region="competencyactions"]').data('competency', null);
|
||||
$('[data-region="competencyactionsmenu"]').hide();
|
||||
$('[data-region="competencyactions"] [data-action="add"]').removeAttr("disabled");
|
||||
} else {
|
||||
var competency = treeModel.getCompetency(id);
|
||||
|
||||
templates.render('tool_lp/competency_summary', competency)
|
||||
.done(function(html) {
|
||||
$('[data-region="competencyinfo"]').html(html);
|
||||
}).fail(notification.exception);
|
||||
|
||||
$('[data-region="competencyactions"]').data('competency', competency);
|
||||
$('[data-region="competencyactions"] [data-action="add"]').removeAttr("disabled");
|
||||
$('[data-region="competencyactionsmenu"]').css('display', 'inline-block');
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,78 @@
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* Handle selection changes on the competency tree.
|
||||
*
|
||||
* @module tool_lp/competencyselect
|
||||
* @package tool_lp
|
||||
* @copyright 2015 Damyon Wiese <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
define(['core/ajax', 'core/notification', 'jquery'], function(ajax, notification, $) {
|
||||
// Private variables and functions.
|
||||
var competencies = [];
|
||||
|
||||
var competencyFrameworkId = 0;
|
||||
|
||||
var loadCompetencies = function(searchtext) {
|
||||
var deferred = $.Deferred();
|
||||
searchtext = '';
|
||||
var promises = ajax.call([{
|
||||
methodname: 'tool_lp_search_competencies',
|
||||
args: {
|
||||
searchtext: searchtext,
|
||||
competencyframeworkid: competencyFrameworkId
|
||||
}
|
||||
}]);
|
||||
promises[0].done(function(result) {
|
||||
competencies = [];
|
||||
var i = 0;
|
||||
for (i = 0; i < result.length; i++) {
|
||||
competencies[result[i].id] = result[i];
|
||||
}
|
||||
deferred.resolve(competencies);
|
||||
}).fail(function(exception) {
|
||||
deferred.reject(exception);
|
||||
});
|
||||
|
||||
return deferred.promise();
|
||||
};
|
||||
|
||||
|
||||
return {
|
||||
// Public variables and functions.
|
||||
init: function(id) {
|
||||
competencyFrameworkId = id;
|
||||
loadCompetencies('').fail(notification.exception);
|
||||
},
|
||||
|
||||
getCompetencyFrameworkId: function() {
|
||||
return competencyFrameworkId;
|
||||
},
|
||||
// Public variables and functions.
|
||||
getCompetency: function(id) {
|
||||
return competencies[id];
|
||||
},
|
||||
|
||||
listCompetencies: function() {
|
||||
return competencies;
|
||||
},
|
||||
|
||||
applySearch: function(searchtext) {
|
||||
return loadCompetencies(searchtext);
|
||||
}
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,262 @@
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* Handle add/remove course competency links.
|
||||
*
|
||||
* @module tool_lp/coursecompetencies
|
||||
* @package tool_lp
|
||||
* @copyright 2015 Damyon Wiese <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
define(['jquery', 'core/notification', 'core/ajax', 'core/templates', 'core/dialogue', 'core/str', 'core/tree', 'core/dragdrop-reorder'],
|
||||
function($, notification, ajax, templates, dialogue, str, ariatree, dragdrop) {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param {int} courseid
|
||||
*/
|
||||
var coursecompetencies = function(courseid) {
|
||||
this.courseid = courseid;
|
||||
this.selectedCompetency = 0;
|
||||
var localthis = this;
|
||||
var loadframeworks = ajax.call([
|
||||
{ methodname: 'tool_lp_list_competency_frameworks', args: { filters: {}, sort: 'sortorder' } }
|
||||
]);
|
||||
|
||||
loadframeworks[0].done(function(frameworks) {
|
||||
localthis.frameworks = frameworks;
|
||||
if (frameworks.length == 0) {
|
||||
templates.render('tool_lp/no_frameworks_warning', {})
|
||||
.done(function(html) {
|
||||
$('[data-region="actions"]').append(html);
|
||||
$('[data-region="actions"] button').hide();
|
||||
}).fail(notification.exception);
|
||||
return;
|
||||
}
|
||||
$('[data-region="actions"] button').show();
|
||||
localthis.registerEvents();
|
||||
localthis.registerDragDrop();
|
||||
}).fail(notification.exception);
|
||||
};
|
||||
|
||||
coursecompetencies.prototype.registerDragDrop = function() {
|
||||
var localthis = this;
|
||||
// Init this module.
|
||||
str.get_string('movecoursecompetency', 'tool_lp').done(
|
||||
function(movestring) {
|
||||
dragdrop.dragdrop('movecoursecompetency',
|
||||
movestring,
|
||||
{ identifier: 'movecoursecompetency', component: 'tool_lp'},
|
||||
{ identifier: 'movecoursecompetencyafter', component: 'tool_lp'},
|
||||
'drag-samenode',
|
||||
'drag-parentnode',
|
||||
'drag-handlecontainer',
|
||||
function(drag, drop) {
|
||||
localthis.handleDrop.call(localthis, drag, drop);
|
||||
});
|
||||
}
|
||||
).fail(notification.exception);
|
||||
|
||||
};
|
||||
|
||||
coursecompetencies.prototype.handleDrop = function(drag, drop) {
|
||||
var fromid = $(drag).data('id');
|
||||
var toid = $(drop).data('id');
|
||||
var localthis = this;
|
||||
|
||||
var requests = ajax.call([
|
||||
{ methodname: 'tool_lp_reorder_course_competency',
|
||||
args: { courseid: localthis.courseid, competencyidfrom: fromid, competencyidto: toid } }
|
||||
]);
|
||||
requests[0].fail(notification.exception);
|
||||
|
||||
};
|
||||
|
||||
coursecompetencies.prototype.applyFilter = function(e) {
|
||||
e.preventDefault();
|
||||
var localthis = this;
|
||||
var searchInput = $('[data-region="filtercompetencies"] input');
|
||||
var searchText = searchInput.val();
|
||||
var framework = $('[data-action="chooseframework"]');
|
||||
var frameworkid = framework.val();
|
||||
|
||||
this.searchCompetencies().done(function (competencies) {
|
||||
var i = 0;
|
||||
|
||||
var framework = localthis.frameworks[0];
|
||||
for (i = 0; i < localthis.frameworks.length; i++) {
|
||||
if (localthis.frameworks[i].id == frameworkid) {
|
||||
framework = localthis.frameworks[i];
|
||||
framework.selected = true;
|
||||
} else {
|
||||
localthis.frameworks[i].selected = false;
|
||||
}
|
||||
}
|
||||
framework.selected = true;
|
||||
var context = { framework: framework, frameworks: localthis.frameworks, competencies: competencies, search: searchText };
|
||||
templates.render('tool_lp/link_course_competencies', context).done(function(html) {
|
||||
$('[data-region="competencylinktree"]').replaceWith(html);
|
||||
localthis.initLinkCourseCompetencies();
|
||||
}).fail(notification.exception);;
|
||||
}).fail(notification.exception);
|
||||
};
|
||||
|
||||
coursecompetencies.prototype.initLinkCourseCompetencies = function() {
|
||||
var localthis = this;
|
||||
|
||||
var competencytree = new ariatree('[data-enhance=linktree]', function(target) {
|
||||
localthis.selectedCompetency = target.data('id');
|
||||
});
|
||||
|
||||
$('[data-action="chooseframework"]').change(function(e) {
|
||||
return localthis.applyFilter.call(localthis, e);
|
||||
});
|
||||
|
||||
$('[data-region="filtercompetencies"] button').click(function(e) {
|
||||
$(e.target).attr('disabled', 'disabled');
|
||||
return localthis.applyFilter.call(localthis, e);
|
||||
});
|
||||
|
||||
$('[data-region="competencylinktree"] [data-action="cancel"]').click(function(e) {
|
||||
$(e.target).attr('disabled', 'disabled');
|
||||
e.preventDefault();
|
||||
localthis.popup.close();
|
||||
});
|
||||
$('[data-region="competencylinktree"] [data-action="add"]').click(function(e) {
|
||||
e.preventDefault();
|
||||
if (!localthis.selectedCompetency) {
|
||||
return;
|
||||
}
|
||||
|
||||
$(e.target).attr('disabled', 'disabled');
|
||||
// Add the link and reload the page template.
|
||||
var requests = ajax.call([
|
||||
{ methodname: 'tool_lp_add_competency_to_course',
|
||||
args: { courseid: localthis.courseid, competencyid: localthis.selectedCompetency } },
|
||||
{ methodname: 'tool_lp_data_for_course_competencies_page',
|
||||
args: { courseid: localthis.courseid } }
|
||||
]);
|
||||
|
||||
requests[1].done(function(context) {
|
||||
templates.render('tool_lp/course_competencies_page', context).done(function(html, js) {
|
||||
localthis.popup.close();
|
||||
$('[data-region="coursecompetenciespage"]').replaceWith(html);
|
||||
templates.runTemplateJS(js);
|
||||
}).fail(notification.exception);
|
||||
}).fail(notification.exception);
|
||||
});
|
||||
};
|
||||
|
||||
coursecompetencies.prototype.registerEvents = function() {
|
||||
var localthis = this;
|
||||
$('[data-region="actions"] button').click(function(e) {
|
||||
return localthis.openCompetencySelector.call(localthis, e);
|
||||
});
|
||||
$('[data-action="delete-competency-link"]').click(function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var deleteid = $(e.target).closest('[data-id]').data('id');
|
||||
|
||||
// Delete the link and reload the page template.
|
||||
var requests = ajax.call([
|
||||
{ methodname: 'tool_lp_remove_competency_from_course',
|
||||
args: { courseid: localthis.courseid, competencyid: deleteid } },
|
||||
{ methodname: 'tool_lp_data_for_course_competencies_page',
|
||||
args: { courseid: localthis.courseid } }
|
||||
]);
|
||||
|
||||
requests[1].done(function(context) {
|
||||
templates.render('tool_lp/course_competencies_page', context).done(function(html, js) {
|
||||
$('[data-region="coursecompetenciespage"]').replaceWith(html);
|
||||
templates.runTemplateJS(js);
|
||||
}).fail(notification.exception);
|
||||
}).fail(notification.exception);
|
||||
});
|
||||
};
|
||||
|
||||
coursecompetencies.prototype.addCompetencyChildren = function(parent, competencies) {
|
||||
var i;
|
||||
|
||||
for (i = 0; i < competencies.length; i++) {
|
||||
if (competencies[i].parentid == parent.id) {
|
||||
parent.haschildren = true;
|
||||
competencies[i].children = [];
|
||||
competencies[i].haschildren = false;
|
||||
parent.children[parent.children.length] = competencies[i];
|
||||
this.addCompetencyChildren(competencies[i], competencies);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
coursecompetencies.prototype.searchCompetencies = function() {
|
||||
var localthis = this;
|
||||
var deferred = $.Deferred();
|
||||
var searchInput = $('[data-region="filtercompetencies"] input');
|
||||
var searchText = '';
|
||||
if (searchInput.length) {
|
||||
searchText = searchInput.val();
|
||||
}
|
||||
var framework = $('[data-action="chooseframework"]');
|
||||
var frameworkid = localthis.frameworks[0].id;
|
||||
if (framework.length) {
|
||||
var frameworkid = framework.val();
|
||||
}
|
||||
|
||||
var loadcompetencies = ajax.call([
|
||||
{ methodname: 'tool_lp_search_competencies', args: { searchtext: searchText, competencyframeworkid: frameworkid } }
|
||||
]);
|
||||
|
||||
loadcompetencies[0].done(function (competencies) {
|
||||
// Expand the list of competencies into a tree.
|
||||
var i, competenciestree = [];
|
||||
for (i = 0; i < competencies.length; i++) {
|
||||
var onecompetency = competencies[i];
|
||||
if (onecompetency.parentid == 0) {
|
||||
onecompetency.children = [];
|
||||
onecompetency.haschildren = 0;
|
||||
competenciestree[competenciestree.length] = onecompetency;
|
||||
localthis.addCompetencyChildren(onecompetency, competencies);
|
||||
}
|
||||
}
|
||||
deferred.resolve(competenciestree);
|
||||
}).fail(function (ex) { deferred.reject(ex); });
|
||||
|
||||
return deferred.promise();
|
||||
};
|
||||
|
||||
coursecompetencies.prototype.openCompetencySelector = function(e) {
|
||||
e.preventDefault();
|
||||
var localthis = this;
|
||||
|
||||
this.searchCompetencies().done(function (competencies) {
|
||||
var framework = localthis.frameworks[0];
|
||||
framework.selected = true;
|
||||
var context = { framework: framework, frameworks: localthis.frameworks, competencies: competencies, search: '' };
|
||||
templates.render('tool_lp/link_course_competencies', context).done(function(html) {
|
||||
str.get_string('linkcoursecompetencies', 'tool_lp').done(function(title) {;
|
||||
localthis.popup = new dialogue(
|
||||
title,
|
||||
html, // The link UI.
|
||||
(function() {localthis.initLinkCourseCompetencies.call(localthis)})
|
||||
);
|
||||
}).fail(notification.exception);
|
||||
}).fail(notification.exception);;
|
||||
}).fail(notification.exception);
|
||||
};
|
||||
|
||||
return /** @alias module:core/tree */ coursecompetencies;
|
||||
});
|
||||
@@ -0,0 +1,118 @@
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* Delete competency frameworks via ajax.
|
||||
*
|
||||
* @module tool_lp/frameworkdelete
|
||||
* @package tool_lp
|
||||
* @copyright 2015 Damyon Wiese <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
define(['jquery', 'core/templates', 'core/ajax', 'core/notification', 'core/str'], function($, templates, ajax, notification, str) {
|
||||
// Private variables and functions.
|
||||
|
||||
/** @var {Number} frameworkid The id of the framework */
|
||||
var frameworkid = 0;
|
||||
|
||||
/**
|
||||
* Callback to replace the dom element with the rendered template.
|
||||
*
|
||||
* @param {string} newhtml The new html to insert.
|
||||
* @param {string} newjs The new js to run.
|
||||
*/
|
||||
var updatePage = function(newhtml, newjs) {
|
||||
$('[data-region="managecompetencies"]').replaceWith(newhtml);
|
||||
templates.runTemplateJS(newjs);
|
||||
};
|
||||
|
||||
/**
|
||||
* Callback to render the page template again and update the page.
|
||||
*
|
||||
* @param {Object} context The context for the template.
|
||||
*/
|
||||
var reloadList = function(context) {
|
||||
templates.render('tool_lp/manage_competency_frameworks_page', context)
|
||||
.done(updatePage)
|
||||
.fail(notification.exception);
|
||||
};
|
||||
|
||||
/**
|
||||
* Delete a framework and reload the page.
|
||||
*/
|
||||
var doDelete = function() {
|
||||
|
||||
// We are chaining ajax requests here.
|
||||
var requests = ajax.call([{
|
||||
methodname: 'tool_lp_delete_competency_framework',
|
||||
args: { id: frameworkid }
|
||||
}, {
|
||||
methodname: 'tool_lp_data_for_competency_frameworks_manage_page',
|
||||
args: []
|
||||
}]);
|
||||
requests[1].done(reloadList).fail(notification.exception);
|
||||
};
|
||||
|
||||
/**
|
||||
* Handler for "Delete competency framework" actions.
|
||||
* @param {Event} e
|
||||
*/
|
||||
var confirmDelete = function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var id = $(this).attr('data-frameworkid');
|
||||
frameworkid = id;
|
||||
|
||||
var requests = ajax.call([{
|
||||
methodname: 'tool_lp_read_competency_framework',
|
||||
args: { id: frameworkid }
|
||||
}]);
|
||||
|
||||
requests[0].done(function(framework) {
|
||||
var strings = str.get_strings([
|
||||
{ key: 'confirm', component: 'tool_lp' },
|
||||
{ key: 'deletecompetencyframework', component: 'tool_lp', param: framework.shortname },
|
||||
{ key: 'delete', component: 'tool_lp' },
|
||||
{ key: 'cancel', component: 'tool_lp' }
|
||||
]).done(function (strings) {
|
||||
notification.confirm(
|
||||
strings[0], // Confirm.
|
||||
strings[1], // Delete competency framework X?
|
||||
strings[2], // Delete.
|
||||
strings[3], // Cancel.
|
||||
doDelete
|
||||
);
|
||||
}).fail(notification.exception);
|
||||
}).fail(notification.exception);
|
||||
|
||||
};
|
||||
|
||||
|
||||
return {
|
||||
// Public variables and functions.
|
||||
/**
|
||||
* Initialise this plugin. Just attaches some event handlers to the delete entries in the menu.
|
||||
*/
|
||||
init: function() {
|
||||
// Init this module.
|
||||
$('[data-region="managecompetencies"]').on(
|
||||
"click",
|
||||
'[data-action="deletecompetencyframework"]',
|
||||
confirmDelete
|
||||
);
|
||||
}
|
||||
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,72 @@
|
||||
// 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/frameworkdelete
|
||||
* @package tool_lp
|
||||
* @copyright 2015 Damyon Wiese <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
define(['core/dragdrop-reorder',
|
||||
'core/str',
|
||||
'core/notification',
|
||||
'jquery',
|
||||
'core/ajax'],
|
||||
function(dragdrop, str, notification, $, ajax) {
|
||||
// Private variables and functions.
|
||||
|
||||
/**
|
||||
* Handle a drop on a node.
|
||||
*
|
||||
* @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 {
|
||||
// Public variables and functions.
|
||||
/**
|
||||
* Initialise this plugin. It loads some strings, then adds the drag/drop functions.
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,118 @@
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* Delete learning plan templates via ajax.
|
||||
*
|
||||
* @module tool_lp/templatedelete
|
||||
* @package tool_lp
|
||||
* @copyright 2015 Damyon Wiese <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
define(['jquery', 'core/templates', 'core/ajax', 'core/notification', 'core/str'], function($, templates, ajax, notification, str) {
|
||||
// Private variables and functions.
|
||||
|
||||
/** @var {Number} templateid The id of the template */
|
||||
var templateid = 0;
|
||||
|
||||
/**
|
||||
* Callback to replace the dom element with the rendered template.
|
||||
*
|
||||
* @param {string} newhtml The new html to insert.
|
||||
* @param {string} newjs The new js to run.
|
||||
*/
|
||||
var updatePage = function(newhtml, newjs) {
|
||||
$('[data-region="managetemplates"]').replaceWith(newhtml);
|
||||
templates.runTemplateJS(newjs);
|
||||
};
|
||||
|
||||
/**
|
||||
* Callback to render the page template again and update the page.
|
||||
*
|
||||
* @param {Object} context The context for the template.
|
||||
*/
|
||||
var reloadList = function(context) {
|
||||
templates.render('tool_lp/manage_templates_page', context)
|
||||
.done(updatePage)
|
||||
.fail(notification.exception);
|
||||
};
|
||||
|
||||
/**
|
||||
* Delete a template and reload the page.
|
||||
*/
|
||||
var doDelete = function() {
|
||||
|
||||
// We are chaining ajax requests here.
|
||||
var requests = ajax.call([{
|
||||
methodname: 'tool_lp_delete_template',
|
||||
args: { id: templateid }
|
||||
}, {
|
||||
methodname: 'tool_lp_data_for_templates_manage_page',
|
||||
args: []
|
||||
}]);
|
||||
requests[1].done(reloadList).fail(notification.exception);
|
||||
};
|
||||
|
||||
/**
|
||||
* Handler for "Delete learning plan template" actions.
|
||||
* @param {Event} e
|
||||
*/
|
||||
var confirmDelete = function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var id = $(this).attr('data-templateid');
|
||||
templateid = id;
|
||||
|
||||
var requests = ajax.call([{
|
||||
methodname: 'tool_lp_read_template',
|
||||
args: { id: templateid }
|
||||
}]);
|
||||
|
||||
requests[0].done(function(template) {
|
||||
var strings = str.get_strings([
|
||||
{ key: 'confirm', component: 'tool_lp' },
|
||||
{ key: 'deletetemplate', component: 'tool_lp', param: template.shortname },
|
||||
{ key: 'delete', component: 'tool_lp' },
|
||||
{ key: 'cancel', component: 'tool_lp' }
|
||||
]).done(function (strings) {
|
||||
notification.confirm(
|
||||
strings[0], // Confirm.
|
||||
strings[1], // Delete learning plan template X?
|
||||
strings[2], // Delete.
|
||||
strings[3], // Cancel.
|
||||
doDelete
|
||||
);
|
||||
}).fail(notification.exception);
|
||||
}).fail(notification.exception);
|
||||
|
||||
};
|
||||
|
||||
|
||||
return {
|
||||
// Public variables and functions.
|
||||
/**
|
||||
* Initialise this plugin. Just attaches some event handlers to the delete entries in the menu.
|
||||
*/
|
||||
init: function() {
|
||||
// Init this module.
|
||||
$('[data-region="managetemplates"]').on(
|
||||
"click",
|
||||
'[data-action="deletetemplate"]',
|
||||
confirmDelete
|
||||
);
|
||||
}
|
||||
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,72 @@
|
||||
// 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 learning plan templates via ajax.
|
||||
*
|
||||
* @module tool_lp/templatedelete
|
||||
* @package tool_lp
|
||||
* @copyright 2015 Damyon Wiese <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
define(['core/dragdrop-reorder',
|
||||
'core/str',
|
||||
'core/notification',
|
||||
'jquery',
|
||||
'core/ajax'],
|
||||
function(dragdrop, str, notification, $, ajax) {
|
||||
// Private variables and functions.
|
||||
|
||||
/**
|
||||
* Handle a drop on a node.
|
||||
*
|
||||
* @param {DOMNode} drag
|
||||
* @param {DOMNode} drop
|
||||
*/
|
||||
var handleDrop = function(drag, drop) {
|
||||
var from = $(drag).data('templateid');
|
||||
var to = $(drop).data('templateid');
|
||||
|
||||
var requests = ajax.call([{
|
||||
methodname: 'tool_lp_reorder_template',
|
||||
args: { from: from, to: to }
|
||||
}]);
|
||||
requests[0].fail(notification.exception);
|
||||
|
||||
};
|
||||
|
||||
return {
|
||||
// Public variables and functions.
|
||||
/**
|
||||
* Initialise this plugin. It loads some strings, then adds the drag/drop functions.
|
||||
*/
|
||||
init: function() {
|
||||
// Init this module.
|
||||
str.get_string('movetemplate', 'tool_lp').done(
|
||||
function(movestring) {
|
||||
dragdrop.dragdrop('movetemplate',
|
||||
movestring,
|
||||
{ identifier: 'movetemplate', component: 'tool_lp'},
|
||||
{ identifier: 'movetemplateafter', component: 'tool_lp'},
|
||||
'drag-samenode',
|
||||
'drag-parentnode',
|
||||
'drag-handlecontainer',
|
||||
handleDrop);
|
||||
}
|
||||
).fail(notification.exception);
|
||||
}
|
||||
|
||||
};
|
||||
});
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,439 @@
|
||||
<?php
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* Class for loading/storing competencies from the DB.
|
||||
*
|
||||
* @package tool_lp
|
||||
* @copyright 2015 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace tool_lp;
|
||||
|
||||
use stdClass;
|
||||
use context_system;
|
||||
|
||||
/**
|
||||
* Class for loading/storing competencies from the DB.
|
||||
*
|
||||
* @copyright 2015 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class competency extends persistent {
|
||||
|
||||
/** @var string $shortname Short name for this competency */
|
||||
private $shortname = '';
|
||||
|
||||
/** @var string $idnumber Unique idnumber for this competency - must be unique within the framework if it is non-empty */
|
||||
private $idnumber = '';
|
||||
|
||||
/** @var string $description Description for this competency */
|
||||
private $description = '';
|
||||
|
||||
/** @var int $descriptionformat Format for the description */
|
||||
private $descriptionformat = 0;
|
||||
|
||||
/** @var int $sortorder A number used to influence sorting */
|
||||
private $sortorder = 0;
|
||||
|
||||
/** @var bool $visible Used to show/hide this competency */
|
||||
private $visible = true;
|
||||
|
||||
/** @var int $parentid id of the parent of this competency (0 means root competency) */
|
||||
private $parentid = 0;
|
||||
|
||||
/** @var string $path ids of all the parents up the tree separated with slashes */
|
||||
private $path = '/0/';
|
||||
|
||||
/** @var int $id of the competency framework this competency belongs to */
|
||||
private $competencyframeworkid = 0;
|
||||
|
||||
/**
|
||||
* Method that provides the table name matching this class.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_table_name() {
|
||||
return 'tool_lp_competency';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the short name.
|
||||
*
|
||||
* @return string The short name
|
||||
*/
|
||||
public function get_shortname() {
|
||||
return $this->shortname;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the short name.
|
||||
*
|
||||
* @param string $shortname The short name
|
||||
*/
|
||||
public function set_shortname($shortname) {
|
||||
$this->shortname = $shortname;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the description format.
|
||||
*
|
||||
* @return int The description format
|
||||
*/
|
||||
public function get_descriptionformat() {
|
||||
return $this->descriptionformat;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the description format
|
||||
*
|
||||
* @param int $descriptionformat The description format
|
||||
*/
|
||||
public function set_descriptionformat($descriptionformat) {
|
||||
$this->descriptionformat = $descriptionformat;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the id number.
|
||||
*
|
||||
* @return string The id number
|
||||
*/
|
||||
public function get_idnumber() {
|
||||
return $this->idnumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the id number.
|
||||
*
|
||||
* @param string $idnumber The id number
|
||||
*/
|
||||
public function set_idnumber($idnumber) {
|
||||
$this->idnumber = $idnumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the description.
|
||||
*
|
||||
* @return string The description
|
||||
*/
|
||||
public function get_description() {
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the description.
|
||||
*
|
||||
* @param string $description The description
|
||||
*/
|
||||
public function set_description($description) {
|
||||
$this->description = $description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the sort order index.
|
||||
*
|
||||
* @return string The sort order index
|
||||
*/
|
||||
public function get_sortorder() {
|
||||
return $this->sortorder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the sort order index.
|
||||
*
|
||||
* @param string $sortorder The sort order index
|
||||
*/
|
||||
public function set_sortorder($sortorder) {
|
||||
$this->sortorder = $sortorder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the visible flag.
|
||||
*
|
||||
* @return string The visible flag
|
||||
*/
|
||||
public function get_visible() {
|
||||
return $this->visible;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the visible flag.
|
||||
*
|
||||
* @param string $visible The visible flag
|
||||
*/
|
||||
public function set_visible($visible) {
|
||||
$this->visible = $visible;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the parentid
|
||||
*
|
||||
* @return int The id of the parent
|
||||
*/
|
||||
public function get_parentid() {
|
||||
return $this->parentid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the parent id
|
||||
*
|
||||
* @param int $parentid The parent id number (can be null)
|
||||
*/
|
||||
public function set_parentid($id) {
|
||||
$this->parentid = $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the path
|
||||
*
|
||||
* @return string The ids of all the parents joined with a slash.
|
||||
*/
|
||||
public function get_path() {
|
||||
return $this->path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the path.
|
||||
*
|
||||
* @param string $path The ids of all the parents joined with a slash.
|
||||
*/
|
||||
public function set_path($path) {
|
||||
$this->path = $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the competencyframeworkid
|
||||
*
|
||||
* @return int The competency framework id.
|
||||
*/
|
||||
public function get_competencyframeworkid() {
|
||||
return $this->competencyframeworkid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the competencyframeworkid.
|
||||
*
|
||||
* @param int $competencyframeworkid The competency framework id.
|
||||
*/
|
||||
public function set_competencyframeworkid($competencyframeworkid) {
|
||||
$this->competencyframeworkid = $competencyframeworkid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate this class with data from a DB record.
|
||||
*
|
||||
* @param stdClass $record A DB record.
|
||||
* @return framework
|
||||
*/
|
||||
public function from_record($record) {
|
||||
if (isset($record->id)) {
|
||||
$this->set_id($record->id);
|
||||
}
|
||||
if (isset($record->shortname)) {
|
||||
$this->set_shortname($record->shortname);
|
||||
}
|
||||
if (isset($record->idnumber)) {
|
||||
$this->set_idnumber($record->idnumber);
|
||||
}
|
||||
if (isset($record->description)) {
|
||||
$this->set_description($record->description);
|
||||
}
|
||||
if (isset($record->descriptionformat)) {
|
||||
$this->set_descriptionformat($record->descriptionformat);
|
||||
}
|
||||
if (isset($record->sortorder)) {
|
||||
$this->set_sortorder($record->sortorder);
|
||||
}
|
||||
if (isset($record->visible)) {
|
||||
$this->set_visible($record->visible);
|
||||
}
|
||||
if (isset($record->timecreated)) {
|
||||
$this->set_timecreated($record->timecreated);
|
||||
}
|
||||
if (isset($record->timemodified)) {
|
||||
$this->set_timemodified($record->timemodified);
|
||||
}
|
||||
if (isset($record->usermodified)) {
|
||||
$this->set_usermodified($record->usermodified);
|
||||
}
|
||||
if (isset($record->competencyframeworkid)) {
|
||||
$this->set_competencyframeworkid($record->competencyframeworkid);
|
||||
}
|
||||
if (isset($record->parentid)) {
|
||||
$this->set_parentid($record->parentid);
|
||||
}
|
||||
if (isset($record->path)) {
|
||||
$this->set_path($record->path);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a DB record from this class.
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function to_record() {
|
||||
$record = new stdClass();
|
||||
$record->id = $this->get_id();
|
||||
$record->shortname = $this->get_shortname();
|
||||
$record->idnumber = $this->get_idnumber();
|
||||
$record->description = $this->get_description();
|
||||
$record->descriptionformat = $this->get_descriptionformat();
|
||||
$options = array('context' => context_system::instance());
|
||||
$record->descriptionformatted = format_text($this->get_description(), $this->get_descriptionformat(), $options);
|
||||
$record->sortorder = $this->get_sortorder();
|
||||
$record->visible = $this->get_visible();
|
||||
$record->timecreated = $this->get_timecreated();
|
||||
$record->timemodified = $this->get_timemodified();
|
||||
$record->usermodified = $this->get_usermodified();
|
||||
$record->competencyframeworkid = $this->get_competencyframeworkid();
|
||||
$record->parentid = $this->get_parentid();
|
||||
$record->path = $this->get_path();
|
||||
|
||||
return $record;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a default for the sortorder field to the default create logic.
|
||||
*
|
||||
* @return persistent
|
||||
*/
|
||||
public function create() {
|
||||
if ($this->parentid) {
|
||||
// Load the parent so we can set the path.
|
||||
$parent = new competency($this->parentid);
|
||||
$this->path = $parent->path . $this->parentid . '/';
|
||||
} else {
|
||||
$this->path = '/0/';
|
||||
}
|
||||
$this->sortorder = $this->count_records(array('parentid' => $this->parentid, 'competencyframeworkid' => $this->competencyframeworkid));
|
||||
return parent::create();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix all paths when moving to a new parent.
|
||||
*
|
||||
* @return persistent
|
||||
*/
|
||||
public function update() {
|
||||
global $DB;
|
||||
|
||||
// See if the parentid changed, if so we have work to do.
|
||||
$before = new competency($this->get_id());
|
||||
if ($before->parentid != $this->parentid) {
|
||||
if ($this->parentid) {
|
||||
$parent = new competency($this->parentid);
|
||||
$this->path = $parent->path . $this->parentid . '/';
|
||||
} else {
|
||||
$this->path = '/0/';
|
||||
}
|
||||
|
||||
$search = array('parentid' => $this->parentid,
|
||||
'competencyframeworkid' => $this->competencyframeworkid);
|
||||
$this->sortorder = $this->count_records($search);
|
||||
|
||||
// We need to fix all the paths of the children.
|
||||
$like = $DB->sql_like('path', '?');
|
||||
$likesearch = $DB->sql_like_escape($before->path . $before->id . '/') . '%';
|
||||
$sql = 'UPDATE {tool_lp_competency} SET path = REPLACE(path, ?, ?) WHERE ' . $like;
|
||||
$DB->execute($sql, array($before->path . $this->id . '/', $this->path . $this->id . '/', $likesearch));
|
||||
}
|
||||
// Do the default update.
|
||||
return parent::update();
|
||||
}
|
||||
|
||||
/**
|
||||
* This does a specialised search that finds all nodes in the tree with matching text on any text like field,
|
||||
* and returns this node and all its parents in a displayable sort order.
|
||||
*
|
||||
* @param string $searchText The text to search for.
|
||||
* @param int $competencyframeworkid The competency framework to limit the search.
|
||||
* @return persistent
|
||||
*/
|
||||
public function search($searchText, $competencyframeworkid) {
|
||||
global $DB;
|
||||
|
||||
$like1 = $DB->sql_like('shortname', ':like1', false);
|
||||
$like2 = $DB->sql_like('idnumber', ':like2', false);
|
||||
$like3 = $DB->sql_like('description', ':like3', false);
|
||||
|
||||
$params = array(
|
||||
'like1' => '%' . $DB->sql_like_escape($searchText) . '%',
|
||||
'like2' => '%' . $DB->sql_like_escape($searchText) . '%',
|
||||
'like3' => '%' . $DB->sql_like_escape($searchText) . '%',
|
||||
'frameworkid' => $competencyframeworkid
|
||||
);
|
||||
|
||||
$sql = 'competencyframeworkid = :frameworkid AND ((' . $like1 . ') OR (' . $like2 . ') OR (' . $like3 . '))';
|
||||
$records = $DB->get_records_select($this->get_table_name(), $sql, $params, 'path, sortorder ASC', '*');
|
||||
|
||||
// Now get all the parents.
|
||||
$parents = array();
|
||||
foreach ($records as $record) {
|
||||
$parents = explode('/', $record->path);
|
||||
foreach ($parents as $parent) {
|
||||
$parents[intval($parent)] = true;
|
||||
}
|
||||
}
|
||||
$parents = array_keys($parents);
|
||||
|
||||
// Skip ones we already fetched.
|
||||
foreach ($parents as $idx => $parent) {
|
||||
if ($parent == 0 || isset($records[$parent])) {
|
||||
unset($parents[$idx]);
|
||||
}
|
||||
}
|
||||
|
||||
if (count($parents)) {
|
||||
list($parentsql, $parentparams) = $DB->get_in_or_equal($parents, SQL_PARAMS_NAMED);
|
||||
|
||||
$parentrecords = $DB->get_records_select($this->get_table_name(), 'id ' . $parentsql, $parentparams, 'path, sortorder ASC', '*');
|
||||
|
||||
foreach ($parentrecords as $id => $record) {
|
||||
$records[$id] = $record;
|
||||
}
|
||||
}
|
||||
|
||||
$instances = array();
|
||||
// Convert to instances of this class.
|
||||
foreach ($records as $record) {
|
||||
$newrecord = new static(0, $record);
|
||||
array_push($instances, $newrecord);
|
||||
}
|
||||
return $instances;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a competency (drastic). Will delete all child nodes in the tree.
|
||||
*
|
||||
* @return persistent
|
||||
*/
|
||||
public function delete() {
|
||||
global $DB;
|
||||
|
||||
$deletepath = $DB->sql_like_escape($this->path . $this->get_id() . '/') . '%';
|
||||
|
||||
// We need to delete all the children.
|
||||
$like = $DB->sql_like('path', ':deletepath');
|
||||
$DB->delete_records_select('tool_lp_competency', $like, array('deletepath' => $deletepath));
|
||||
|
||||
// And all the links to courses.
|
||||
$DB->delete_records('tool_lp_course_competency', array('competencyid' => $this->get_id()));
|
||||
// Do the default delete.
|
||||
return parent::delete();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,243 @@
|
||||
<?php
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* Class for loading/storing competency frameworks from the DB.
|
||||
*
|
||||
* @package tool_lp
|
||||
* @copyright 2015 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace tool_lp;
|
||||
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* Class for loading/storing competency frameworks from the DB.
|
||||
*
|
||||
* @copyright 2015 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class competency_framework extends persistent {
|
||||
|
||||
/** @var string $shortname Short name for this framework */
|
||||
private $shortname = '';
|
||||
|
||||
/** @var string $idnumber Unique idnumber for this framework - must be unique if it is non-empty */
|
||||
private $idnumber = '';
|
||||
|
||||
/** @var string $description Description for this framework */
|
||||
private $description = '';
|
||||
|
||||
/** @var int $descriptionformat Format for the description */
|
||||
private $descriptionformat = 0;
|
||||
|
||||
/** @var int $sortorder A number used to influence sorting */
|
||||
private $sortorder = 0;
|
||||
|
||||
/** @var bool $visible Used to show/hide this framework */
|
||||
private $visible = true;
|
||||
|
||||
/**
|
||||
* Method that provides the table name matching this class.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_table_name() {
|
||||
return 'tool_lp_competency_framework';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the short name.
|
||||
*
|
||||
* @return string The short name
|
||||
*/
|
||||
public function get_shortname() {
|
||||
return $this->shortname;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the short name.
|
||||
*
|
||||
* @param string $shortname The short name
|
||||
*/
|
||||
public function set_shortname($shortname) {
|
||||
$this->shortname = $shortname;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the description format.
|
||||
*
|
||||
* @return int The description format
|
||||
*/
|
||||
public function get_descriptionformat() {
|
||||
return $this->descriptionformat;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the description format
|
||||
*
|
||||
* @param int $descriptionformat The description format
|
||||
*/
|
||||
public function set_descriptionformat($descriptionformat) {
|
||||
$this->descriptionformat = $descriptionformat;
|
||||
}
|
||||
/**
|
||||
* Get the id number.
|
||||
*
|
||||
* @return string The id number
|
||||
*/
|
||||
public function get_idnumber() {
|
||||
return $this->idnumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the id number.
|
||||
*
|
||||
* @param string $idnumber The id number
|
||||
*/
|
||||
public function set_idnumber($idnumber) {
|
||||
$this->idnumber = $idnumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the description.
|
||||
*
|
||||
* @return string The description
|
||||
*/
|
||||
public function get_description() {
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the description.
|
||||
*
|
||||
* @param string $description The description
|
||||
*/
|
||||
public function set_description($description) {
|
||||
$this->description = $description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the sort order index.
|
||||
*
|
||||
* @return string The sort order index
|
||||
*/
|
||||
public function get_sortorder() {
|
||||
return $this->sortorder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the sort order index.
|
||||
*
|
||||
* @param string $sortorder The sort order index
|
||||
*/
|
||||
public function set_sortorder($sortorder) {
|
||||
$this->sortorder = $sortorder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the visible flag.
|
||||
*
|
||||
* @return string The visible flag
|
||||
*/
|
||||
public function get_visible() {
|
||||
return $this->visible;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the visible flag.
|
||||
*
|
||||
* @param string $visible The visible flag
|
||||
*/
|
||||
public function set_visible($visible) {
|
||||
$this->visible = $visible;
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate this class with data from a DB record.
|
||||
*
|
||||
* @param stdClass $record A DB record.
|
||||
* @return framework
|
||||
*/
|
||||
public function from_record($record) {
|
||||
if (isset($record->id)) {
|
||||
$this->set_id($record->id);
|
||||
}
|
||||
if (isset($record->shortname)) {
|
||||
$this->set_shortname($record->shortname);
|
||||
}
|
||||
if (isset($record->idnumber)) {
|
||||
$this->set_idnumber($record->idnumber);
|
||||
}
|
||||
if (isset($record->description)) {
|
||||
$this->set_description($record->description);
|
||||
}
|
||||
if (isset($record->descriptionformat)) {
|
||||
$this->set_descriptionformat($record->descriptionformat);
|
||||
}
|
||||
if (isset($record->sortorder)) {
|
||||
$this->set_sortorder($record->sortorder);
|
||||
}
|
||||
if (isset($record->visible)) {
|
||||
$this->set_visible($record->visible);
|
||||
}
|
||||
if (isset($record->timecreated)) {
|
||||
$this->set_timecreated($record->timecreated);
|
||||
}
|
||||
if (isset($record->timemodified)) {
|
||||
$this->set_timemodified($record->timemodified);
|
||||
}
|
||||
if (isset($record->usermodified)) {
|
||||
$this->set_usermodified($record->usermodified);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a DB record from this class.
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function to_record() {
|
||||
$record = new stdClass();
|
||||
$record->id = $this->get_id();
|
||||
$record->shortname = $this->get_shortname();
|
||||
$record->idnumber = $this->get_idnumber();
|
||||
$record->description = $this->get_description();
|
||||
$record->descriptionformat = $this->get_descriptionformat();
|
||||
$record->descriptionformatted = format_text($this->get_description(), $this->get_descriptionformat());
|
||||
$record->sortorder = $this->get_sortorder();
|
||||
$record->visible = $this->get_visible();
|
||||
$record->timecreated = $this->get_timecreated();
|
||||
$record->timemodified = $this->get_timemodified();
|
||||
$record->usermodified = $this->get_usermodified();
|
||||
|
||||
return $record;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a default for the sortorder field to the default create logic.
|
||||
*
|
||||
* @return persistent
|
||||
*/
|
||||
public function create() {
|
||||
$this->sortorder = $this->count_records();
|
||||
return parent::create();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,267 @@
|
||||
<?php
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* Class for loading/storing competencies from the DB.
|
||||
*
|
||||
* @package tool_lp
|
||||
* @copyright 2015 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace tool_lp;
|
||||
|
||||
use stdClass;
|
||||
use context_system;
|
||||
|
||||
/**
|
||||
* Class for loading/storing course_competencies from the DB.
|
||||
*
|
||||
* @copyright 2015 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class course_competency extends persistent {
|
||||
|
||||
/** @var int $courseid The course id */
|
||||
private $courseid = 0;
|
||||
|
||||
/** @var int $competencyid The competency id */
|
||||
private $competencyid = 0;
|
||||
|
||||
/** @var int $sortorder A number used to influence sorting */
|
||||
private $sortorder = 0;
|
||||
|
||||
/**
|
||||
* Method that provides the table name matching this class.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_table_name() {
|
||||
return 'tool_lp_course_competency';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the competency id
|
||||
*
|
||||
* @return int The competency id
|
||||
*/
|
||||
public function get_competencyid() {
|
||||
return $this->competencyid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the competency id
|
||||
*
|
||||
* @param int $competencyid The competency id
|
||||
*/
|
||||
public function set_competencyid($competencyid) {
|
||||
$this->competencyid = $competencyid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the sort order index.
|
||||
*
|
||||
* @return string The sort order index
|
||||
*/
|
||||
public function get_sortorder() {
|
||||
return $this->sortorder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the sort order index.
|
||||
*
|
||||
* @param string $sortorder The sort order index
|
||||
*/
|
||||
public function set_sortorder($sortorder) {
|
||||
$this->sortorder = $sortorder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the course id
|
||||
*
|
||||
* @return int The course id
|
||||
*/
|
||||
public function get_courseid() {
|
||||
return $this->courseid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the course id
|
||||
*
|
||||
* @param int $courseid The course id
|
||||
*/
|
||||
public function set_courseid($courseid) {
|
||||
$this->courseid = $courseid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate this class with data from a DB record.
|
||||
*
|
||||
* @param stdClass $record A DB record.
|
||||
* @return framework
|
||||
*/
|
||||
public function from_record($record) {
|
||||
if (isset($record->id)) {
|
||||
$this->set_id($record->id);
|
||||
}
|
||||
if (isset($record->courseid)) {
|
||||
$this->set_courseid($record->courseid);
|
||||
}
|
||||
if (isset($record->competencyid)) {
|
||||
$this->set_competencyid($record->competencyid);
|
||||
}
|
||||
if (isset($record->sortorder)) {
|
||||
$this->set_sortorder($record->sortorder);
|
||||
}
|
||||
if (isset($record->timecreated)) {
|
||||
$this->set_timecreated($record->timecreated);
|
||||
}
|
||||
if (isset($record->timemodified)) {
|
||||
$this->set_timemodified($record->timemodified);
|
||||
}
|
||||
if (isset($record->usermodified)) {
|
||||
$this->set_usermodified($record->usermodified);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a DB record from this class.
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function to_record() {
|
||||
$record = new stdClass();
|
||||
$record->id = $this->get_id();
|
||||
$record->courseid = $this->get_courseid();
|
||||
$record->competencyid = $this->get_competencyid();
|
||||
$record->sortorder = $this->get_sortorder();
|
||||
$record->timecreated = $this->get_timecreated();
|
||||
$record->timemodified = $this->get_timemodified();
|
||||
$record->usermodified = $this->get_usermodified();
|
||||
|
||||
return $record;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the course ids and visible flags that include this competency. Only the ids and visible flag are returned,
|
||||
* for the full records use list_courses.
|
||||
*
|
||||
* @param int $competencyid The competency id
|
||||
* @return int
|
||||
*/
|
||||
public function list_courses_min($competencyid) {
|
||||
global $DB;
|
||||
|
||||
$results = $DB->get_records_sql('SELECT course.id as id, course.visible as visible
|
||||
FROM {' . self::get_table_name() . '} coursecomp
|
||||
JOIN {course} course
|
||||
ON coursecomp.courseid = course.id
|
||||
WHERE coursecomp.competencyid = ? ', array($competencyid));
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return partial course records foreach course that contains this competency.
|
||||
*
|
||||
* @param int $competencyid The competency id
|
||||
* @return array[stdClass] Array of course records containg id, visible, shortname, idnumber, fullname
|
||||
*/
|
||||
public function list_courses($competencyid) {
|
||||
global $DB;
|
||||
|
||||
$results = $DB->get_records_sql('SELECT course.id, course.visible, course.shortname, course.idnumber, course.fullname
|
||||
FROM {course} course
|
||||
JOIN {' . self::get_table_name() . '} coursecomp
|
||||
ON coursecomp.courseid = course.id
|
||||
WHERE coursecomp.competencyid = ? ', array($competencyid));
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Count the competencies in this course.
|
||||
*
|
||||
* @param int $courseid The course id
|
||||
* @param bool $onlyvisible If true, only count visible competencies in this course.
|
||||
* @return int
|
||||
*/
|
||||
public function count_competencies($courseid, $onlyvisible) {
|
||||
global $DB;
|
||||
|
||||
|
||||
$sql = 'SELECT COUNT(comp.id)
|
||||
FROM {' . self::get_table_name() . '} coursecomp
|
||||
JOIN {' . competency::get_table_name() . '} comp
|
||||
ON coursecomp.competencyid = comp.id
|
||||
WHERE coursecomp.courseid = ? ';
|
||||
$params = array($courseid);
|
||||
|
||||
if ($onlyvisible) {
|
||||
$sql .= ' AND comp.visible = ?';
|
||||
$params[] = 1;
|
||||
}
|
||||
|
||||
$results = $DB->count_records_sql($sql, $params);
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* List the competencies in this course.
|
||||
*
|
||||
* @param int $courseid The course id
|
||||
* @param bool $onlyvisible If true, only count visible competencies in this course.
|
||||
* @return array[competency]
|
||||
*/
|
||||
public function list_competencies($courseid, $onlyvisible) {
|
||||
global $DB;
|
||||
|
||||
$competency = new competency();
|
||||
|
||||
$sql = 'SELECT comp.*
|
||||
FROM {' . $competency->get_table_name() . '} comp
|
||||
JOIN {' . self::get_table_name() . '} coursecomp
|
||||
ON coursecomp.competencyid = comp.id
|
||||
WHERE coursecomp.courseid = ? ORDER BY coursecomp.sortorder ASC';
|
||||
$params = array($courseid);
|
||||
|
||||
if ($onlyvisible) {
|
||||
$sql .= ' AND comp.visible = ?';
|
||||
$params[] = 1;
|
||||
}
|
||||
|
||||
$results = $DB->get_records_sql($sql, $params);
|
||||
|
||||
$instances = array();
|
||||
foreach ($results as $result) {
|
||||
array_push($instances, new competency(0, $result));
|
||||
}
|
||||
|
||||
return $instances;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a default for the sortorder field to the default create logic.
|
||||
*
|
||||
* @return persistent
|
||||
*/
|
||||
public function create() {
|
||||
$this->sortorder = $this->count_records(array('courseid' => $this->get_courseid()));
|
||||
return parent::create();
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* This file contains the form add/update a competency framework.
|
||||
*
|
||||
* @package tool_lp
|
||||
* @copyright 2015 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace tool_lp\form;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
|
||||
|
||||
use moodleform;
|
||||
use tool_lp\api;
|
||||
|
||||
require_once($CFG->libdir.'/formslib.php');
|
||||
|
||||
/**
|
||||
* Competency framework form.
|
||||
*
|
||||
* @package tool_lp
|
||||
* @copyright 2015 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class competency extends moodleform {
|
||||
|
||||
/**
|
||||
* Define the form - called by parent constructor
|
||||
*/
|
||||
public function definition() {
|
||||
$mform = $this->_form;
|
||||
$id = $this->_customdata['id'];
|
||||
$framework = $this->_customdata['competencyframework'];
|
||||
$parent = $this->_customdata['parent'];
|
||||
|
||||
$mform->addElement('hidden', 'id');
|
||||
$mform->setType('id', PARAM_INT);
|
||||
$mform->setDefault('id', 0);
|
||||
|
||||
$mform->addElement('hidden', 'parentid');
|
||||
$mform->setType('parentid', PARAM_INT);
|
||||
if ($parent) {
|
||||
$mform->setDefault('parentid', $parent->get_id());
|
||||
} else {
|
||||
$mform->setDefault('parentid', 0);
|
||||
}
|
||||
|
||||
$mform->addElement('hidden', 'competencyframeworkid');
|
||||
$mform->setType('competencyframeworkid', PARAM_INT);
|
||||
$mform->setDefault('competencyframeworkid', $framework->get_id());
|
||||
|
||||
$mform->addElement('static',
|
||||
'frameworkdesc',
|
||||
get_string('competencyframework', 'tool_lp'),
|
||||
s($framework->get_shortname()));
|
||||
if ($parent) {
|
||||
$mform->addElement('static',
|
||||
'parentdesc',
|
||||
get_string('parentcompetency', 'tool_lp'),
|
||||
s($parent->get_shortname()));
|
||||
}
|
||||
|
||||
$mform->addElement('text', 'shortname',
|
||||
get_string('shortname', 'tool_lp'));
|
||||
$mform->setType('shortname', PARAM_TEXT);
|
||||
$mform->addRule('shortname', null, 'required', null, 'client');
|
||||
$mform->addElement('editor', 'description',
|
||||
get_string('description', 'tool_lp'), array('rows'=>4));
|
||||
$mform->setType('description', PARAM_TEXT);
|
||||
$mform->addElement('text', 'idnumber',
|
||||
get_string('idnumber', 'tool_lp'));
|
||||
$mform->setType('idnumber', PARAM_TEXT);
|
||||
$mform->addElement('selectyesno', 'visible',
|
||||
get_string('visible', 'tool_lp'));
|
||||
$mform->setDefault('visible', true);
|
||||
$mform->addHelpButton('visible', 'visible', 'tool_lp');
|
||||
|
||||
$this->add_action_buttons(true, get_string('savechanges', 'tool_lp'));
|
||||
|
||||
if (!empty($id)) {
|
||||
if (!$this->is_submitted()) {
|
||||
$competency = api::read_competency($id);
|
||||
$record = $competency->to_record();
|
||||
// Massage for editor API.
|
||||
$record->description = array('text'=>$record->description, 'format'=>$record->descriptionformat);
|
||||
$this->set_data($record);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* This file contains the form add/update a competency framework.
|
||||
*
|
||||
* @package tool_lp
|
||||
* @copyright 2015 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace tool_lp\form;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
|
||||
|
||||
use moodleform;
|
||||
use tool_lp\api;
|
||||
|
||||
require_once($CFG->libdir.'/formslib.php');
|
||||
|
||||
/**
|
||||
* Competency framework form.
|
||||
*
|
||||
* @package tool_lp
|
||||
* @copyright 2015 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class competency_framework extends moodleform {
|
||||
|
||||
/**
|
||||
* Define the form - called by parent constructor
|
||||
*/
|
||||
public function definition() {
|
||||
$mform = $this->_form;
|
||||
$id = $this->_customdata;
|
||||
|
||||
$mform->addElement('hidden', 'id');
|
||||
$mform->setType('id', PARAM_INT);
|
||||
$mform->setDefault('id', 0);
|
||||
|
||||
$mform->addElement('text', 'shortname',
|
||||
get_string('shortname', 'tool_lp'));
|
||||
$mform->setType('shortname', PARAM_TEXT);
|
||||
$mform->addRule('shortname', null, 'required', null, 'client');
|
||||
$mform->addElement('editor', 'description',
|
||||
get_string('description', 'tool_lp'), array('rows'=>4));
|
||||
$mform->setType('description', PARAM_TEXT);
|
||||
$mform->addElement('text', 'idnumber',
|
||||
get_string('idnumber', 'tool_lp'));
|
||||
$mform->setType('idnumber', PARAM_TEXT);
|
||||
$mform->addElement('selectyesno', 'visible',
|
||||
get_string('visible', 'tool_lp'));
|
||||
$mform->setDefault('visible', true);
|
||||
$mform->addHelpButton('visible', 'visible', 'tool_lp');
|
||||
|
||||
$this->add_action_buttons(true, get_string('savechanges', 'tool_lp'));
|
||||
|
||||
if (!empty($id)) {
|
||||
if (!$this->is_submitted()) {
|
||||
$framework = api::read_framework($id);
|
||||
$record = $framework->to_record();
|
||||
// Massage for editor API.
|
||||
$record->description = array('text'=>$record->description, 'format'=>$record->descriptionformat);
|
||||
$this->set_data($record);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* This file contains the form add/update a competency framework.
|
||||
*
|
||||
* @package tool_lp
|
||||
* @copyright 2015 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace tool_lp\form;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
|
||||
|
||||
use moodleform;
|
||||
use tool_lp\api;
|
||||
|
||||
require_once($CFG->libdir.'/formslib.php');
|
||||
|
||||
/**
|
||||
* Learning plan template form.
|
||||
*
|
||||
* @package tool_lp
|
||||
* @copyright 2015 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class template extends moodleform {
|
||||
|
||||
/**
|
||||
* Define the form - called by parent constructor
|
||||
*/
|
||||
public function definition() {
|
||||
$mform = $this->_form;
|
||||
$id = $this->_customdata;
|
||||
|
||||
$mform->addElement('hidden', 'id');
|
||||
$mform->setType('id', PARAM_INT);
|
||||
$mform->setDefault('id', 0);
|
||||
|
||||
$mform->addElement('text', 'shortname',
|
||||
get_string('shortname', 'tool_lp'));
|
||||
$mform->setType('shortname', PARAM_TEXT);
|
||||
$mform->addRule('shortname', null, 'required', null, 'client');
|
||||
$mform->addElement('editor', 'description',
|
||||
get_string('description', 'tool_lp'), array('rows'=>4));
|
||||
$mform->setType('description', PARAM_TEXT);
|
||||
$mform->addElement('text', 'idnumber',
|
||||
get_string('idnumber', 'tool_lp'));
|
||||
$mform->setType('idnumber', PARAM_TEXT);
|
||||
$mform->addElement('selectyesno', 'visible',
|
||||
get_string('visible', 'tool_lp'));
|
||||
$mform->addElement('date_time_selector',
|
||||
'duedate',
|
||||
get_string('duedate', 'tool_lp'),
|
||||
array('optional'=>true));
|
||||
$mform->addHelpButton('duedate', 'duedate', 'tool_lp');
|
||||
|
||||
$mform->setDefault('visible', true);
|
||||
$mform->addHelpButton('visible', 'visible', 'tool_lp');
|
||||
|
||||
$this->add_action_buttons(true, get_string('savechanges', 'tool_lp'));
|
||||
|
||||
if (!empty($id)) {
|
||||
if (!$this->is_submitted()) {
|
||||
$template = api::read_template($id);
|
||||
$record = $template->to_record();
|
||||
// Massage for editor API.
|
||||
$record->description = array('text'=>$record->description, 'format'=>$record->descriptionformat);
|
||||
$this->set_data($record);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* Class containing data for course competencies page
|
||||
*
|
||||
* @package tool_lp
|
||||
* @copyright 2015 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace tool_lp\output;
|
||||
|
||||
use renderable;
|
||||
use templatable;
|
||||
use renderer_base;
|
||||
use stdClass;
|
||||
use moodle_url;
|
||||
use context_system;
|
||||
use context_course;
|
||||
use tool_lp\api;
|
||||
|
||||
/**
|
||||
* Class containing data for course competencies page
|
||||
*
|
||||
* @copyright 2015 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class course_competencies_page implements renderable, templatable {
|
||||
|
||||
/** @var stdClass $course Course record for this page. */
|
||||
var $course = null;
|
||||
|
||||
/**
|
||||
* Construct this renderable.
|
||||
* @param stdClass $course The course record for this page.
|
||||
*/
|
||||
public function __construct($courseid) {
|
||||
$context = context_course::instance($courseid);
|
||||
$this->courseid = $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', $context);
|
||||
$this->manageurl = new moodle_url('/admin/tool/lp/competencyframeworks.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* Export this data so it can be used as the context for a mustache template.
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function export_for_template(renderer_base $output) {
|
||||
$data = new stdClass();
|
||||
$data->courseid = $this->courseid;
|
||||
$data->competencies = array();
|
||||
foreach ($this->competencies as $competency) {
|
||||
$record = $competency->to_record();
|
||||
array_push($data->competencies, $record);
|
||||
}
|
||||
$data->canmanagecompetencyframeworks = $this->canmanagecompetencyframeworks;
|
||||
$data->canmanagecoursecompetencies = $this->canmanagecoursecompetencies;
|
||||
$data->manageurl = $this->manageurl->out(true);
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* Class containing data for managecompetencyframeworks page
|
||||
*
|
||||
* @package tool_lp
|
||||
* @copyright 2015 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace tool_lp\output;
|
||||
|
||||
use renderable;
|
||||
use templatable;
|
||||
use renderer_base;
|
||||
use single_button;
|
||||
use stdClass;
|
||||
use moodle_url;
|
||||
use context_system;
|
||||
use tool_lp\api;
|
||||
|
||||
/**
|
||||
* Class containing data for managecompetencies page
|
||||
*
|
||||
* @copyright 2015 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class manage_competencies_page implements renderable, templatable {
|
||||
|
||||
/** @var \tool_lp\competency_framework $framework This competency framework. */
|
||||
var $framework = null;
|
||||
|
||||
/** @var array $competencies List of competencies. */
|
||||
var $competencies = array();
|
||||
|
||||
/** @var string $search Text to search for. */
|
||||
var $search = '';
|
||||
|
||||
/** @var bool $canmanage Result of permissions checks. */
|
||||
var $canmanage = false;
|
||||
|
||||
/** @var moodle_url $pluginurlbase Base url to use constructing links. */
|
||||
var $pluginbaseurl = null;
|
||||
|
||||
/**
|
||||
* Construct this renderable.
|
||||
* @param \tool_lp\competency_framework $framework
|
||||
*/
|
||||
public function __construct($framework, $search) {
|
||||
$this->framework = $framework;
|
||||
$this->search = $search;
|
||||
$addpage = new single_button(
|
||||
new moodle_url('/admin/tool/lp/editcompetencyframework.php'),
|
||||
get_string('addnewcompetency', 'tool_lp')
|
||||
);
|
||||
$this->navigation[] = $addpage;
|
||||
|
||||
$this->competencies = api::search_competencies($search, $framework->get_id());
|
||||
|
||||
$context = context_system::instance();
|
||||
$this->canmanage = has_capability('tool/lp:competencymanage', $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively build up the tree of nodes.
|
||||
*
|
||||
* @param stdClass $parent - the exported parent node
|
||||
* @param array $all - List of all competency classes.
|
||||
*/
|
||||
private function add_competency_children($parent, $all) {
|
||||
foreach ($all as $one) {
|
||||
if ($one->get_parentid() == $parent->id) {
|
||||
$parent->haschildren = true;
|
||||
$record = $one->to_record();
|
||||
$record->children = array();
|
||||
$record->haschildren = false;
|
||||
$parent->children[] = $record;
|
||||
$this->add_competency_children($record, $all);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Export this data so it can be used as the context for a mustache template.
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function export_for_template(renderer_base $output) {
|
||||
$data = new stdClass();
|
||||
$data->framework = $this->framework->to_record();
|
||||
$data->canmanage = $this->canmanage;
|
||||
$data->competencies = array();
|
||||
$data->search = $this->search;
|
||||
|
||||
foreach ($this->competencies as $competency) {
|
||||
if ($competency->get_parentid() == 0) {
|
||||
$record = $competency->to_record();
|
||||
$record->children = array();
|
||||
$record->haschildren = false;
|
||||
$data->competencies[] = $record;
|
||||
$this->add_competency_children($record, $this->competencies);
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* Class containing data for managecompetencyframeworks page
|
||||
*
|
||||
* @package tool_lp
|
||||
* @copyright 2015 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace tool_lp\output;
|
||||
|
||||
use renderable;
|
||||
use templatable;
|
||||
use renderer_base;
|
||||
use single_button;
|
||||
use stdClass;
|
||||
use moodle_url;
|
||||
use context_system;
|
||||
use tool_lp\api;
|
||||
|
||||
/**
|
||||
* Class containing data for managecompetencyframeworks page
|
||||
*
|
||||
* @copyright 2015 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class manage_competency_frameworks_page implements renderable, templatable {
|
||||
|
||||
/** @var array $navigation List of links to display on the page. Each link contains a url and a title. */
|
||||
var $navigation = array();
|
||||
|
||||
/** @var array $competencyframeworks List of competency frameworks. */
|
||||
var $competencyframeworks = array();
|
||||
|
||||
/** @var bool $canmanage Result of permissions checks. */
|
||||
var $canmanage = false;
|
||||
|
||||
/** @var moodle_url $pluginurlbase Base url to use constructing links. */
|
||||
var $pluginbaseurl = null;
|
||||
|
||||
/**
|
||||
* Construct this renderable.
|
||||
*/
|
||||
public function __construct() {
|
||||
$addpage = new single_button(
|
||||
new moodle_url('/admin/tool/lp/editcompetencyframework.php'),
|
||||
get_string('addnewcompetencyframework', 'tool_lp')
|
||||
);
|
||||
$this->navigation[] = $addpage;
|
||||
|
||||
$this->competencyframeworks = api::list_frameworks(array(), 'sortorder', 'ASC', 0, 0);
|
||||
|
||||
$context = context_system::instance();
|
||||
$this->canmanage = has_capability('tool/lp:competencymanage', $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Export this data so it can be used as the context for a mustache template.
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function export_for_template(renderer_base $output) {
|
||||
$data = new stdClass();
|
||||
$data->canmanage = $this->canmanage;
|
||||
$data->competencyframeworks = array();
|
||||
foreach ($this->competencyframeworks as $framework) {
|
||||
$record = $framework->to_record();
|
||||
$filters = array('competencyframeworkid' => $framework->get_id());
|
||||
$record->competencies_count = api::count_competencies($filters);
|
||||
$data->competencyframeworks[] = $record;
|
||||
}
|
||||
$data->pluginbaseurl = (new moodle_url('/admin/tool/lp'))->out(true);
|
||||
$data->navigation = array();
|
||||
foreach ($this->navigation as $button) {
|
||||
$data->navigation[] = $output->render($button);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* Class containing data for managelearningplans page
|
||||
*
|
||||
* @package tool_lp
|
||||
* @copyright 2015 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace tool_lp\output;
|
||||
|
||||
use renderable;
|
||||
use templatable;
|
||||
use renderer_base;
|
||||
use single_button;
|
||||
use stdClass;
|
||||
use moodle_url;
|
||||
use context_system;
|
||||
use tool_lp\api;
|
||||
|
||||
/**
|
||||
* Class containing data for managecompetencyframeworks page
|
||||
*
|
||||
* @copyright 2015 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class manage_templates_page implements renderable, templatable {
|
||||
|
||||
/** @var array $navigation List of links to display on the page. Each link contains a url and a title. */
|
||||
var $navigation = array();
|
||||
|
||||
/** @var array $templates List of learning plan templates. */
|
||||
var $templates = array();
|
||||
|
||||
/** @var bool $canmanage Result of permissions checks. */
|
||||
var $canmanage = false;
|
||||
|
||||
/**
|
||||
* Construct this renderable.
|
||||
*/
|
||||
public function __construct() {
|
||||
$addpage = new single_button(
|
||||
new moodle_url('/admin/tool/lp/edittemplate.php'),
|
||||
get_string('addnewtemplate', 'tool_lp')
|
||||
);
|
||||
$this->navigation[] = $addpage;
|
||||
|
||||
$this->templates = api::list_templates(array(), 'sortorder', 'ASC', 0, 0);
|
||||
|
||||
$context = context_system::instance();
|
||||
$this->canmanage = has_capability('tool/lp:learningplanmanage', $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Export this data so it can be used as the context for a mustache template.
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function export_for_template(renderer_base $output) {
|
||||
$data = new stdClass();
|
||||
$data->canmanage = $this->canmanage;
|
||||
$data->templates = array();
|
||||
foreach ($this->templates as $template) {
|
||||
$record = $template->to_record();
|
||||
$data->templates[] = $record;
|
||||
}
|
||||
$data->pluginbaseurl = (new moodle_url('/admin/tool/lp'))->out(true);
|
||||
$data->navigation = array();
|
||||
foreach ($this->navigation as $button) {
|
||||
$data->navigation[] = $output->render($button);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* Renderer class for learning plans
|
||||
*
|
||||
* @package tool_lp
|
||||
* @copyright 2015 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace tool_lp\output;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
use plugin_renderer_base;
|
||||
|
||||
/**
|
||||
* Renderer class for learning plans
|
||||
*
|
||||
* @package tool_lp
|
||||
* @copyright 2015 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class renderer extends plugin_renderer_base {
|
||||
|
||||
/**
|
||||
* Defer to template.
|
||||
*
|
||||
* @param manage_competency_frameworks_page $page
|
||||
*
|
||||
* @return string html for the page
|
||||
*/
|
||||
public function render_manage_competency_frameworks_page($page) {
|
||||
$data = $page->export_for_template($this);
|
||||
return parent::render_from_template('tool_lp/manage_competency_frameworks_page', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Defer to template.
|
||||
*
|
||||
* @param manage_competencies_page $page
|
||||
*
|
||||
* @return string html for the page
|
||||
*/
|
||||
public function render_manage_competencies_page($page) {
|
||||
$data = $page->export_for_template($this);
|
||||
return parent::render_from_template('tool_lp/manage_competencies_page', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Defer to template.
|
||||
*
|
||||
* @param course_competencies_page $page
|
||||
*
|
||||
* @return string html for the page
|
||||
*/
|
||||
public function render_course_competencies_page($page) {
|
||||
$data = $page->export_for_template($this);
|
||||
return parent::render_from_template('tool_lp/course_competencies_page', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Defer to template.
|
||||
*
|
||||
* @param manage_templates_page $page
|
||||
*
|
||||
* @return string html for the page
|
||||
*/
|
||||
public function render_manage_templates_page($page) {
|
||||
$data = $page->export_for_template($this);
|
||||
return parent::render_from_template('tool_lp/manage_templates_page', $data);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* Class containing data for learning plan template competencies page
|
||||
*
|
||||
* @package tool_lp
|
||||
* @copyright 2015 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace tool_lp\output;
|
||||
|
||||
use renderable;
|
||||
use templatable;
|
||||
use renderer_base;
|
||||
use stdClass;
|
||||
use moodle_url;
|
||||
use context_system;
|
||||
use tool_lp\api;
|
||||
|
||||
/**
|
||||
* Class containing data for learning plan template competencies page
|
||||
*
|
||||
* @copyright 2015 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class template_competencies_page implements renderable, templatable {
|
||||
|
||||
/**
|
||||
* Construct this renderable.
|
||||
* @param int $templateid The learning plan template id for this page.
|
||||
*/
|
||||
public function __construct($templateid) {
|
||||
$this->courseid = $templateid;
|
||||
$this->competencies = api::list_competencies_in_template($templateid);
|
||||
$this->canmanagecompetencyframeworks = has_capability('tool/lp:competencymanage', context_system::instance());
|
||||
$this->canmanagetemplates = has_capability('tool/lp:templatesmanage', $context);
|
||||
$this->manageurl = new moodle_url('/admin/tool/lp/competencyframeworks.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* Export this data so it can be used as the context for a mustache template.
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function export_for_template(renderer_base $output) {
|
||||
$data = new stdClass();
|
||||
$data->templateid = $this->templateid;
|
||||
$data->competencies = array();
|
||||
foreach ($this->competencies as $competency) {
|
||||
$record = $competency->to_record();
|
||||
array_push($data->competencies, $record);
|
||||
}
|
||||
$data->canmanagecompetencyframeworks = $this->canmanagecompetencyframeworks;
|
||||
$data->canmanagecoursecompetencies = $this->canmanagecoursecompetencies;
|
||||
$data->manageurl = $this->manageurl->out(true);
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,260 @@
|
||||
<?php
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* Abstract class for tool_lp objects saved to the DB.
|
||||
*
|
||||
* @package tool_lp
|
||||
* @copyright 2015 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace tool_lp;
|
||||
|
||||
use external_function_parameters;
|
||||
use external_value;
|
||||
|
||||
/**
|
||||
* Abstract class for tool_lp objects saved to the DB.
|
||||
*
|
||||
* @copyright 2015 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
abstract class persistent {
|
||||
|
||||
/** @var int|null $id Database id for this framework */
|
||||
private $id = null;
|
||||
|
||||
/** @var int $timecreated Creation timestamp */
|
||||
private $timecreated = 0;
|
||||
|
||||
/** @var int $timemodified Modification timestamp */
|
||||
private $timemodified = 0;
|
||||
|
||||
/** @var int $usermodified The user who last modified this framework */
|
||||
private $usermodified = 0;
|
||||
|
||||
/**
|
||||
* Abstract method that provides the table name matching this class.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
abstract public function get_table_name();
|
||||
|
||||
/**
|
||||
* Create an instance of this class.
|
||||
* @param int $id If set, this is the id of an existing record, used to load the data.
|
||||
* @param stdClass $record If set, the data for this class will be taken from the record.
|
||||
*/
|
||||
public function __construct($id = 0, $record = null) {
|
||||
if ($id > 0) {
|
||||
$this->id = $id;
|
||||
$this->read();
|
||||
}
|
||||
if (!empty($record)) {
|
||||
$this->from_record($record);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the record id
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function get_id() {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the record id
|
||||
*
|
||||
* @param int $id The record id
|
||||
*/
|
||||
public function set_id($id) {
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the time the record was created.
|
||||
*
|
||||
* @return string The time the record was created.
|
||||
*/
|
||||
public function get_timecreated() {
|
||||
return $this->timecreated;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the time created timestamp
|
||||
*
|
||||
* @param int $timecreated The timestamp
|
||||
*/
|
||||
public function set_timecreated($timecreated) {
|
||||
$this->timecreated = $timecreated;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last time the record was modified.
|
||||
*
|
||||
* @return string The last time the record was modified
|
||||
*/
|
||||
public function get_timemodified() {
|
||||
return $this->timemodified;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the last modified timestamp
|
||||
*
|
||||
* @param int $timemodified The timestamp
|
||||
*/
|
||||
public function set_timemodified($timemodified) {
|
||||
$this->timemodified = $timemodified;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the user who last modified the record.
|
||||
*
|
||||
* @return string The user who last modified the record
|
||||
*/
|
||||
public function get_usermodified() {
|
||||
return $this->usermodified;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the user id that last modified the record.
|
||||
*
|
||||
* @param int $usermodified The user id
|
||||
*/
|
||||
public function set_usermodified($usermodified) {
|
||||
$this->usermodified = $usermodified;
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate this class with data from a DB record.
|
||||
*
|
||||
* @param stdClass $record A DB record.
|
||||
* @return persistent
|
||||
*/
|
||||
abstract public function from_record($record);
|
||||
|
||||
/**
|
||||
* Create a DB record from this class.
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
abstract public function to_record();
|
||||
|
||||
/**
|
||||
* Reload the data for this class from the DB.
|
||||
*
|
||||
* @return framework
|
||||
*/
|
||||
public function read() {
|
||||
global $DB;
|
||||
|
||||
if ($this->id <= 0) {
|
||||
throw new coding_exception('id is required to load');
|
||||
}
|
||||
$record = $DB->get_record($this->get_table_name(), array('id' => $this->id), '*', MUST_EXIST);
|
||||
return $this->from_record($record);
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a record in the DB
|
||||
*
|
||||
* @return persistent
|
||||
*/
|
||||
public function create() {
|
||||
global $DB, $USER;
|
||||
|
||||
$this->id = 0;
|
||||
$this->timecreated = $this->timemodified = time();
|
||||
$this->usermodified = $USER->id;
|
||||
$record = $this->to_record();
|
||||
|
||||
$id = $DB->insert_record($this->get_table_name(), $record);
|
||||
$this->set_id($id);
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Update the existing record in the DB.
|
||||
*
|
||||
* @return bool Success
|
||||
*/
|
||||
public function update() {
|
||||
global $DB, $USER;
|
||||
|
||||
if ($this->id <= 0) {
|
||||
throw new coding_exception('id is required to update');
|
||||
}
|
||||
$record = $this->to_record();
|
||||
unset($record->timecreated);
|
||||
$record->timemodified = time();
|
||||
$record->usermodified = $USER->id;
|
||||
$record = (array) $record;
|
||||
return $DB->update_record($this->get_table_name(), $record);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the existing record in the DB.
|
||||
*
|
||||
* @return bool Success
|
||||
*/
|
||||
public function delete() {
|
||||
global $DB;
|
||||
|
||||
if ($this->id <= 0) {
|
||||
throw new coding_exception('id is required to delete');
|
||||
}
|
||||
return $DB->delete_records($this->get_table_name(), array('id' => $this->id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a list of records.
|
||||
*
|
||||
* @return array of persistent instances.
|
||||
*/
|
||||
public function get_records($filters = array(), $sort = '', $order = 'ASC', $skip = 0, $limit = 0) {
|
||||
global $DB;
|
||||
|
||||
$orderby = '';
|
||||
if (!empty($sort)) {
|
||||
$orderby = $sort . ' ' . $order;
|
||||
}
|
||||
|
||||
$records = $DB->get_records($this->get_table_name(), $filters, $orderby, '*', $skip, $limit);
|
||||
$instances = array();
|
||||
|
||||
foreach ($records as $record) {
|
||||
$newrecord = new static(0, $record);
|
||||
array_push($instances, $newrecord);
|
||||
}
|
||||
return $instances;
|
||||
}
|
||||
|
||||
/**
|
||||
* Count a list of records.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function count_records($filters = array()) {
|
||||
global $DB;
|
||||
|
||||
$count = $DB->count_records($this->get_table_name(), $filters);
|
||||
return $count;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,274 @@
|
||||
<?php
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* Class for loading/storing learning plan templates from the DB.
|
||||
*
|
||||
* @package tool_lp
|
||||
* @copyright 2015 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace tool_lp;
|
||||
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* Class for loading/storing learning plan templates from the DB.
|
||||
*
|
||||
* @copyright 2015 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class template extends persistent {
|
||||
|
||||
/** @var string $shortname Short name for this template */
|
||||
private $shortname = '';
|
||||
|
||||
/** @var string $description Description for this framework */
|
||||
private $description = '';
|
||||
|
||||
/** @var int $descriptionformat Format for the description */
|
||||
private $descriptionformat = 0;
|
||||
|
||||
/** @var int $sortorder A number used to influence sorting */
|
||||
private $sortorder = 0;
|
||||
|
||||
/** @var string $idnumber Unique idnumber for this template - must be unique if it is non-empty */
|
||||
private $idnumber = '';
|
||||
|
||||
/** @var int $duedate A default due date for instances of this plan */
|
||||
private $duedate = 0;
|
||||
|
||||
/** @var bool $visible Used to show/hide this template */
|
||||
private $visible = true;
|
||||
|
||||
/**
|
||||
* Method that provides the table name matching this class.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_table_name() {
|
||||
return 'tool_lp_plan_template';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the short name.
|
||||
*
|
||||
* @return string The short name
|
||||
*/
|
||||
public function get_shortname() {
|
||||
return $this->shortname;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the short name.
|
||||
*
|
||||
* @param string $shortname The short name
|
||||
*/
|
||||
public function set_shortname($shortname) {
|
||||
$this->shortname = $shortname;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the description format.
|
||||
*
|
||||
* @return int The description format
|
||||
*/
|
||||
public function get_descriptionformat() {
|
||||
return $this->descriptionformat;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the description format
|
||||
*
|
||||
* @param int $descriptionformat The description format
|
||||
*/
|
||||
public function set_descriptionformat($descriptionformat) {
|
||||
$this->descriptionformat = $descriptionformat;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the id number.
|
||||
*
|
||||
* @return string The id number
|
||||
*/
|
||||
public function get_idnumber() {
|
||||
return $this->idnumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the id number.
|
||||
*
|
||||
* @param string $idnumber The id number
|
||||
*/
|
||||
public function set_idnumber($idnumber) {
|
||||
$this->idnumber = $idnumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the description.
|
||||
*
|
||||
* @return string The description
|
||||
*/
|
||||
public function get_description() {
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the description.
|
||||
*
|
||||
* @param string $description The description
|
||||
*/
|
||||
public function set_description($description) {
|
||||
$this->description = $description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the sort order index.
|
||||
*
|
||||
* @return string The sort order index
|
||||
*/
|
||||
public function get_sortorder() {
|
||||
return $this->sortorder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the sort order index.
|
||||
*
|
||||
* @param string $sortorder The sort order index
|
||||
*/
|
||||
public function set_sortorder($sortorder) {
|
||||
$this->sortorder = $sortorder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the due date
|
||||
*
|
||||
* @return string The due date
|
||||
*/
|
||||
public function get_duedate() {
|
||||
return $this->duedate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the due date
|
||||
*
|
||||
* @param string $duedate The due date
|
||||
*/
|
||||
public function set_duedate($duedate) {
|
||||
$this->duedate = $duedate;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the visible flag.
|
||||
*
|
||||
* @return string The visible flag
|
||||
*/
|
||||
public function get_visible() {
|
||||
return $this->visible;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the visible flag.
|
||||
*
|
||||
* @param string $visible The visible flag
|
||||
*/
|
||||
public function set_visible($visible) {
|
||||
$this->visible = $visible;
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate this class with data from a DB record.
|
||||
*
|
||||
* @param stdClass $record A DB record.
|
||||
* @return template
|
||||
*/
|
||||
public function from_record($record) {
|
||||
if (isset($record->id)) {
|
||||
$this->set_id($record->id);
|
||||
}
|
||||
if (isset($record->shortname)) {
|
||||
$this->set_shortname($record->shortname);
|
||||
}
|
||||
if (isset($record->idnumber)) {
|
||||
$this->set_idnumber($record->idnumber);
|
||||
}
|
||||
if (isset($record->description)) {
|
||||
$this->set_description($record->description);
|
||||
}
|
||||
if (isset($record->descriptionformat)) {
|
||||
$this->set_descriptionformat($record->descriptionformat);
|
||||
}
|
||||
if (isset($record->sortorder)) {
|
||||
$this->set_sortorder($record->sortorder);
|
||||
}
|
||||
if (isset($record->visible)) {
|
||||
$this->set_visible($record->visible);
|
||||
}
|
||||
if (isset($record->duedate)) {
|
||||
$this->set_duedate($record->duedate);
|
||||
}
|
||||
if (isset($record->timecreated)) {
|
||||
$this->set_timecreated($record->timecreated);
|
||||
}
|
||||
if (isset($record->timemodified)) {
|
||||
$this->set_timemodified($record->timemodified);
|
||||
}
|
||||
if (isset($record->usermodified)) {
|
||||
$this->set_usermodified($record->usermodified);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a DB record from this class.
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function to_record() {
|
||||
$record = new stdClass();
|
||||
$record->id = $this->get_id();
|
||||
$record->shortname = $this->get_shortname();
|
||||
$record->idnumber = $this->get_idnumber();
|
||||
$record->duedate = $this->get_duedate();
|
||||
$record->duedateformatted = '';
|
||||
if ($record->duedate) {
|
||||
$record->duedateformatted = userdate($this->get_duedate());
|
||||
}
|
||||
$record->description = $this->get_description();
|
||||
$record->descriptionformat = $this->get_descriptionformat();
|
||||
$record->descriptionformatted = format_text($this->get_description(), $this->get_descriptionformat());
|
||||
$record->sortorder = $this->get_sortorder();
|
||||
$record->visible = $this->get_visible();
|
||||
$record->timecreated = $this->get_timecreated();
|
||||
$record->timemodified = $this->get_timemodified();
|
||||
$record->usermodified = $this->get_usermodified();
|
||||
|
||||
return $record;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a default for the sortorder field to the default create logic.
|
||||
*
|
||||
* @return persistent
|
||||
*/
|
||||
public function create() {
|
||||
$this->sortorder = $this->count_records();
|
||||
return parent::create();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,254 @@
|
||||
<?php
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* Class for loading/storing competencies from the DB.
|
||||
*
|
||||
* @package tool_lp
|
||||
* @copyright 2015 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace tool_lp;
|
||||
|
||||
use stdClass;
|
||||
use context_system;
|
||||
|
||||
/**
|
||||
* Class for loading/storing template_competencies from the DB.
|
||||
*
|
||||
* @copyright 2015 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class template_competency extends persistent {
|
||||
|
||||
/** @var int $templateid The template id */
|
||||
private $templateid = 0;
|
||||
|
||||
/** @var int $competencyid The competency id */
|
||||
private $competencyid = 0;
|
||||
|
||||
/**
|
||||
* Method that provides the table name matching this class.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_table_name() {
|
||||
return 'tool_lp_template_competency';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the competency id
|
||||
*
|
||||
* @return int The competency id
|
||||
*/
|
||||
public function get_competencyid() {
|
||||
return $this->competencyid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the competency id
|
||||
*
|
||||
* @param int $competencyid The competency id
|
||||
*/
|
||||
public function set_competencyid($competencyid) {
|
||||
$this->competencyid = $competencyid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the template id
|
||||
*
|
||||
* @return int The template id
|
||||
*/
|
||||
public function get_templateid() {
|
||||
return $this->templateid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the template id
|
||||
*
|
||||
* @param int $templateid The template id
|
||||
*/
|
||||
public function set_templateid($templateid) {
|
||||
$this->templateid = $templateid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate this class with data from a DB record.
|
||||
*
|
||||
* @param stdClass $record A DB record.
|
||||
* @return framework
|
||||
*/
|
||||
public function from_record($record) {
|
||||
if (isset($record->id)) {
|
||||
$this->set_id($record->id);
|
||||
}
|
||||
if (isset($record->templateid)) {
|
||||
$this->set_templateid($record->templateid);
|
||||
}
|
||||
if (isset($record->competencyid)) {
|
||||
$this->set_competencyid($record->competencyid);
|
||||
}
|
||||
if (isset($record->timecreated)) {
|
||||
$this->set_timecreated($record->timecreated);
|
||||
}
|
||||
if (isset($record->timemodified)) {
|
||||
$this->set_timemodified($record->timemodified);
|
||||
}
|
||||
if (isset($record->usermodified)) {
|
||||
$this->set_usermodified($record->usermodified);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a DB record from this class.
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function to_record() {
|
||||
$record = new stdClass();
|
||||
$record->id = $this->get_id();
|
||||
$record->templateid = $this->get_templateid();
|
||||
$record->competencyid = $this->get_competencyid();
|
||||
$record->timecreated = $this->get_timecreated();
|
||||
$record->timemodified = $this->get_timemodified();
|
||||
$record->usermodified = $this->get_usermodified();
|
||||
|
||||
return $record;
|
||||
}
|
||||
|
||||
/**
|
||||
* Count the templates using this competency
|
||||
*
|
||||
* @param int $competencyid The competency id
|
||||
* @param bool $onlyvisible If true, only count visible templates using this competency.
|
||||
* @return int
|
||||
*/
|
||||
public function count_templates($competencyid, $onlyvisible) {
|
||||
global $DB;
|
||||
|
||||
$sql = 'SELECT COUNT(template.id)
|
||||
FROM {' . self::get_table_name() . '} tplcomp
|
||||
JOIN {' . template::get_table_name() . '} tpl
|
||||
ON tplcomp.templateid = tpl.id
|
||||
WHERE tplcomp.competencyid = ? ';
|
||||
$params = array($templateid);
|
||||
|
||||
if ($onlyvisible) {
|
||||
$sql .= ' AND tpl.visible = ?';
|
||||
$params[] = 1;
|
||||
}
|
||||
|
||||
$results = $DB->count_records_sql($sql, $params);
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* List the templates using this competency.
|
||||
*
|
||||
* @param int $competencyid The competency id
|
||||
* @param bool $onlyvisible If true, only count visible templates using this competency.
|
||||
* @return array[competency]
|
||||
*/
|
||||
public function list_templates($competencyid, $onlyvisible) {
|
||||
global $DB;
|
||||
|
||||
$template = new template();
|
||||
|
||||
$sql = 'SELECT tpl.*
|
||||
FROM {' . $template->get_table_name() . '} tpl
|
||||
JOIN {' . self::get_table_name() . '} tplcomp
|
||||
ON tplcomp.templateid = tpl.id
|
||||
WHERE tplcomp.competencyid = ? ';
|
||||
$params = array($competencyid);
|
||||
|
||||
if ($onlyvisible) {
|
||||
$sql .= ' AND tpl.visible = ?';
|
||||
$params[] = 1;
|
||||
}
|
||||
|
||||
$results = $DB->get_records_sql($sql, $params);
|
||||
|
||||
$instances = array();
|
||||
foreach ($results as $result) {
|
||||
array_push($instances, new template(0, $result));
|
||||
}
|
||||
|
||||
return $instances;
|
||||
}
|
||||
|
||||
/**
|
||||
* Count the competencies in this template.
|
||||
*
|
||||
* @param int $templateid The template id
|
||||
* @param bool $onlyvisible If true, only count visible competencies in this template.
|
||||
* @return int
|
||||
*/
|
||||
public function count_competencies($templateid, $onlyvisible) {
|
||||
global $DB;
|
||||
|
||||
$sql = 'SELECT COUNT(comp.id)
|
||||
FROM {' . self::get_table_name() . '} tplcomp
|
||||
JOIN {' . competency::get_table_name() . '} comp
|
||||
ON tplcomp.competencyid = comp.id
|
||||
WHERE tplcomp.templateid = ? ';
|
||||
$params = array($templateid);
|
||||
|
||||
if ($onlyvisible) {
|
||||
$sql .= ' AND comp.visible = ?';
|
||||
$params[] = 1;
|
||||
}
|
||||
|
||||
$results = $DB->count_records_sql($sql, $params);
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* List the competencies in this template.
|
||||
*
|
||||
* @param int $templateid The template id
|
||||
* @param bool $onlyvisible If true, only count visible competencies in this template.
|
||||
* @return array[competency]
|
||||
*/
|
||||
public function list_competencies($templateid, $onlyvisible) {
|
||||
global $DB;
|
||||
|
||||
$competency = new competency();
|
||||
|
||||
$sql = 'SELECT comp.*
|
||||
FROM {' . $competency->get_table_name() . '} comp
|
||||
JOIN {' . self::get_table_name() . '} tplcomp
|
||||
ON tplcomp.competencyid = comp.id
|
||||
WHERE tplcomp.templateid = ? ';
|
||||
$params = array($templateid);
|
||||
|
||||
if ($onlyvisible) {
|
||||
$sql .= ' AND comp.visible = ?';
|
||||
$params[] = 1;
|
||||
}
|
||||
|
||||
$results = $DB->get_records_sql($sql, $params);
|
||||
|
||||
$instances = array();
|
||||
foreach ($results as $result) {
|
||||
array_push($instances, new competency(0, $result));
|
||||
}
|
||||
|
||||
return $instances;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* This page lets users to manage site wide competencies.
|
||||
*
|
||||
* @package tool_lp
|
||||
* @copyright 2015 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(__DIR__ . '/../../../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
admin_externalpage_setup('toollpcompetencies');
|
||||
|
||||
$id = required_param('competencyframeworkid', PARAM_INT);
|
||||
$search = optional_param('search', '', PARAM_RAW);
|
||||
|
||||
$framework = \tool_lp\api::read_framework($id);
|
||||
|
||||
$title = get_string('competencies', 'tool_lp');
|
||||
$pagetitle = get_string('competenciesforframework', 'tool_lp', $framework->get_shortname());
|
||||
// Set up the page.
|
||||
$url = new moodle_url("/admin/tool/lp/competencies.php", array('competencyframeworkid' => $framework->get_id()));
|
||||
$PAGE->set_url($url);
|
||||
$PAGE->navbar->add($framework->get_shortname(), $url);
|
||||
$PAGE->set_title($title);
|
||||
$PAGE->set_heading($title);
|
||||
$output = $PAGE->get_renderer('tool_lp');
|
||||
echo $output->header();
|
||||
echo $output->heading($pagetitle);
|
||||
|
||||
$page = new \tool_lp\output\manage_competencies_page($framework, $search);
|
||||
echo $output->render($page);
|
||||
|
||||
echo $output->footer();
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* This page lets users to manage site wide competencies.
|
||||
*
|
||||
* @package tool_lp
|
||||
* @copyright 2015 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(__DIR__ . '/../../../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
admin_externalpage_setup('toollpcompetencies');
|
||||
|
||||
$title = get_string('competencies', 'tool_lp');
|
||||
$pagetitle = get_string('competencyframeworks', 'tool_lp');
|
||||
// Set up the page.
|
||||
$url = new moodle_url("/admin/tool/lp/competencyframeworks.php");
|
||||
$PAGE->set_url($url);
|
||||
$PAGE->set_title($title);
|
||||
$PAGE->set_heading($title);
|
||||
$output = $PAGE->get_renderer('tool_lp');
|
||||
echo $output->header();
|
||||
echo $output->heading($pagetitle);
|
||||
|
||||
$page = new \tool_lp\output\manage_competency_frameworks_page();
|
||||
echo $output->render($page);
|
||||
|
||||
echo $output->footer();
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* This page lets users to manage site wide competencies.
|
||||
*
|
||||
* @package tool_lp
|
||||
* @copyright 2015 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(__DIR__ . '/../../../config.php');
|
||||
|
||||
$id = required_param('courseid', PARAM_INT);
|
||||
|
||||
$params = array('id' => $id);
|
||||
$course = $DB->get_record('course', $params, '*', MUST_EXIST);
|
||||
require_login($course);
|
||||
$context = context_course::instance($course->id);
|
||||
$urlparams = array('courseid' => $id);
|
||||
|
||||
$url = new moodle_url('/admin/tool/lp/coursecompetencies.php', $urlparams);
|
||||
$title = get_string('coursecompetencies', 'tool_lp');
|
||||
$PAGE->set_url($url);
|
||||
$PAGE->set_title($title);
|
||||
$coursename = format_text($course->fullname, false, array('context' => $context));
|
||||
$PAGE->set_heading($coursename);
|
||||
$PAGE->set_pagelayout('incourse');
|
||||
|
||||
$output = $PAGE->get_renderer('tool_lp');
|
||||
echo $output->header();
|
||||
echo $output->heading($title);
|
||||
|
||||
$page = new \tool_lp\output\course_competencies_page($course->id);
|
||||
echo $output->render($page);
|
||||
|
||||
echo $output->footer();
|
||||
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* Capabilities.
|
||||
*
|
||||
* This files lists capabilities related to tool_lp.
|
||||
*
|
||||
* @package tool_lp
|
||||
* @copyright 2015 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$capabilities = array(
|
||||
|
||||
'tool/lp:competencyread' => array(
|
||||
'captype' => 'read',
|
||||
'contextlevel' => CONTEXT_SYSTEM,
|
||||
'archetypes' => array(
|
||||
'user' => CAP_ALLOW
|
||||
),
|
||||
'clonepermissionsfrom' => 'moodle/block:view'
|
||||
),
|
||||
'tool/lp:competencymanage' => array(
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_SYSTEM,
|
||||
'archetypes' => array(
|
||||
),
|
||||
'clonepermissionsfrom' => 'moodle/site:config'
|
||||
),
|
||||
'tool/lp:templateread' => array(
|
||||
'captype' => 'read',
|
||||
'contextlevel' => CONTEXT_SYSTEM,
|
||||
'archetypes' => array(
|
||||
'user' => CAP_ALLOW
|
||||
),
|
||||
'clonepermissionsfrom' => 'moodle/block:view'
|
||||
),
|
||||
'tool/lp:templatemanage' => array(
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_SYSTEM,
|
||||
'archetypes' => array(
|
||||
),
|
||||
'clonepermissionsfrom' => 'moodle/site:config'
|
||||
),
|
||||
'tool/lp:learningplanread' => array(
|
||||
'captype' => 'read',
|
||||
'contextlevel' => CONTEXT_SYSTEM,
|
||||
'archetypes' => array(
|
||||
'user' => CAP_ALLOW
|
||||
),
|
||||
'clonepermissionsfrom' => 'moodle/block:view'
|
||||
),
|
||||
'tool/lp:learningplanmanage' => array(
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_SYSTEM,
|
||||
'archetypes' => array(
|
||||
),
|
||||
'clonepermissionsfrom' => 'moodle/site:config'
|
||||
),
|
||||
'tool/lp:coursecompetencyread' => array(
|
||||
'captype' => 'read',
|
||||
'contextlevel' => CONTEXT_COURSE,
|
||||
'archetypes' => array(
|
||||
'user' => CAP_ALLOW
|
||||
),
|
||||
'clonepermissionsfrom' => 'moodle/block:view'
|
||||
),
|
||||
'tool/lp:coursecompetencymanage' => array(
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_COURSE,
|
||||
'archetypes' => array(
|
||||
'editingteacher' => CAP_ALLOW,
|
||||
'manager' => CAP_ALLOW
|
||||
),
|
||||
'clonepermissionsfrom' => 'moodle/site:backup'
|
||||
)
|
||||
|
||||
);
|
||||
Executable
+95
@@ -0,0 +1,95 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<XMLDB PATH="admin/tool/lp/db" VERSION="20150312" COMMENT="XMLDB file for Moodle admin/tool/lp"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="../../../../lib/xmldb/xmldb.xsd"
|
||||
>
|
||||
<TABLES>
|
||||
<TABLE NAME="tool_lp_competency" COMMENT="This table contains the master record of each competency in a framework.">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
|
||||
<FIELD NAME="shortname" TYPE="char" LENGTH="100" NOTNULL="false" SEQUENCE="false" COMMENT="Shortname of a competency"/>
|
||||
<FIELD NAME="description" TYPE="text" NOTNULL="false" SEQUENCE="false" COMMENT="Description of a single competency"/>
|
||||
<FIELD NAME="descriptionformat" TYPE="int" LENGTH="4" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="The format of the description field"/>
|
||||
<FIELD NAME="idnumber" TYPE="char" LENGTH="100" NOTNULL="false" SEQUENCE="false"/>
|
||||
<FIELD NAME="competencyframeworkid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="The framework this competency relates to."/>
|
||||
<FIELD NAME="parentid" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="The parent competency."/>
|
||||
<FIELD NAME="visible" TYPE="int" LENGTH="2" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="Used to hide the competency."/>
|
||||
<FIELD NAME="path" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" COMMENT="Used to speed up queries that use an entire branch of the tree. Looks like /5/34/54."/>
|
||||
<FIELD NAME="sortorder" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="Relative sort order within the branch"/>
|
||||
<FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="The time this competency was created."/>
|
||||
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="The time this competency was last modified."/>
|
||||
<FIELD NAME="usermodified" TYPE="int" LENGTH="10" NOTNULL="false" SEQUENCE="false" COMMENT="The user who last modified this competency"/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
</KEYS>
|
||||
</TABLE>
|
||||
<TABLE NAME="tool_lp_competency_framework" COMMENT="List of competency frameworks.">
|
||||
<FIELDS>
|
||||
<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="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="descriptionformat" TYPE="int" LENGTH="4" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="The format of the description field"/>
|
||||
<FIELD NAME="sortorder" TYPE="int" LENGTH="10" NOTNULL="false" SEQUENCE="false" COMMENT="Defined sort order for this competency when it is displayed in a list."/>
|
||||
<FIELD NAME="visible" TYPE="int" LENGTH="2" NOTNULL="true" DEFAULT="1" SEQUENCE="false" COMMENT="Used to show/hide this competency framework."/>
|
||||
<FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="The time this competency framework was created."/>
|
||||
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="The time this competency framework was last modified."/>
|
||||
<FIELD NAME="usermodified" TYPE="int" LENGTH="10" NOTNULL="false" SEQUENCE="false" COMMENT="The user who last modified this framework"/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
</KEYS>
|
||||
</TABLE>
|
||||
<TABLE NAME="tool_lp_plan_template" COMMENT="Learning plan templates.">
|
||||
<FIELDS>
|
||||
<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 learning plan template."/>
|
||||
<FIELD NAME="idnumber" TYPE="char" LENGTH="100" NOTNULL="false" SEQUENCE="false" COMMENT="Unique idnumber for this learning plan template."/>
|
||||
<FIELD NAME="description" TYPE="text" NOTNULL="false" SEQUENCE="false" COMMENT="Description of this learning plan template"/>
|
||||
<FIELD NAME="descriptionformat" TYPE="int" LENGTH="4" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="The format of the description field"/>
|
||||
<FIELD NAME="sortorder" TYPE="int" LENGTH="10" NOTNULL="false" SEQUENCE="false" COMMENT="Defined sort order for this template when it is displayed in a list."/>
|
||||
<FIELD NAME="visible" TYPE="int" LENGTH="2" NOTNULL="true" DEFAULT="1" SEQUENCE="false" COMMENT="Used to show/hide this learning plan template."/>
|
||||
<FIELD NAME="duedate" TYPE="int" LENGTH="10" NOTNULL="false" SEQUENCE="false" COMMENT="The default due date for instances of this plan."/>
|
||||
<FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="The time this learning plan template was created."/>
|
||||
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="The time this learning plan template was last modified."/>
|
||||
<FIELD NAME="usermodified" TYPE="int" LENGTH="10" NOTNULL="false" SEQUENCE="false" COMMENT="The user who last modified this learning plan template"/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
</KEYS>
|
||||
</TABLE>
|
||||
<TABLE NAME="tool_lp_course_competency" COMMENT="Link a competency to a course.">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
|
||||
<FIELD NAME="courseid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="The course this competency is linked to."/>
|
||||
<FIELD NAME="competencyid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="The competency that is linked to this course."/>
|
||||
<FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="The time this link was created."/>
|
||||
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="The time this link was modified."/>
|
||||
<FIELD NAME="usermodified" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="The user who modified this link."/>
|
||||
<FIELD NAME="sortorder" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="The display order for this link."/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
<KEY NAME="courseidlink" TYPE="foreign" FIELDS="courseid" REFTABLE="course" REFFIELDS="id" COMMENT="Course foreign key."/>
|
||||
<KEY NAME="competencyid" TYPE="foreign" FIELDS="competencyid" REFTABLE="tool_lp_competency" REFFIELDS="id" COMMENT="Competency foreign key."/>
|
||||
</KEYS>
|
||||
</TABLE>
|
||||
<TABLE NAME="tool_lp_template_competency" COMMENT="Link a competency to a learning plan template.">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
|
||||
<FIELD NAME="templateid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="The template this competency is linked to."/>
|
||||
<FIELD NAME="competencyid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="The competency that is linked to this course."/>
|
||||
<FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="The time this link was created."/>
|
||||
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="The time this link was modified."/>
|
||||
<FIELD NAME="usermodified" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="The user who modified this link."/>
|
||||
<FIELD NAME="sortorder" TYPE="int" LENGTH="10" NOTNULL="false" SEQUENCE="false" COMMENT="Relative sort order"/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
<KEY NAME="templateidlink" TYPE="foreign" FIELDS="templateid" REFTABLE="tool_lp_plan_template" REFFIELDS="id" COMMENT="Template foreign key."/>
|
||||
<KEY NAME="competencyid" TYPE="foreign" FIELDS="competencyid" REFTABLE="tool_lp_competency" REFFIELDS="id" COMMENT="Competency foreign key."/>
|
||||
</KEYS>
|
||||
</TABLE>
|
||||
</TABLES>
|
||||
</XMLDB>
|
||||
@@ -0,0 +1,313 @@
|
||||
<?php
|
||||
// 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/>.
|
||||
|
||||
|
||||
/**
|
||||
* Learning plan webservice functions.
|
||||
*
|
||||
*
|
||||
* @package tool_lp
|
||||
* @copyright 2015 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
$functions = array(
|
||||
|
||||
// Learning plan related functions.
|
||||
|
||||
'tool_lp_create_competency_framework' => array(
|
||||
'classname' => 'tool_lp\external',
|
||||
'methodname' => 'create_competency_framework',
|
||||
'classpath' => '',
|
||||
'description' => 'Creates new competency frameworks.',
|
||||
'type' => 'write',
|
||||
'capabilities'=> 'tool/lp:competencymanage',
|
||||
),
|
||||
'tool_lp_read_competency_framework' => array(
|
||||
'classname' => 'tool_lp\external',
|
||||
'methodname' => 'read_competency_framework',
|
||||
'classpath' => '',
|
||||
'description' => 'Load a summary of a competency framework.',
|
||||
'type' => 'read',
|
||||
'capabilities'=> 'tool/lp:competencyview',
|
||||
),
|
||||
'tool_lp_delete_competency_framework' => array(
|
||||
'classname' => 'tool_lp\external',
|
||||
'methodname' => 'delete_competency_framework',
|
||||
'classpath' => '',
|
||||
'description' => 'Delete a competency framework.',
|
||||
'type' => 'write',
|
||||
'capabilities'=> 'tool/lp:competencymanage',
|
||||
),
|
||||
'tool_lp_update_competency_framework' => array(
|
||||
'classname' => 'tool_lp\external',
|
||||
'methodname' => 'update_competency_framework',
|
||||
'classpath' => '',
|
||||
'description' => 'Update a competency framework.',
|
||||
'type' => 'write',
|
||||
'capabilities'=> 'tool/lp:competencymanage',
|
||||
),
|
||||
'tool_lp_list_competency_frameworks' => array(
|
||||
'classname' => 'tool_lp\external',
|
||||
'methodname' => 'list_competency_frameworks',
|
||||
'classpath' => '',
|
||||
'description' => 'Load a list of a competency frameworks.',
|
||||
'type' => 'read',
|
||||
'capabilities'=> 'tool/lp:competencyview',
|
||||
),
|
||||
'tool_lp_count_competency_frameworks' => array(
|
||||
'classname' => 'tool_lp\external',
|
||||
'methodname' => 'count_competency_frameworks',
|
||||
'classpath' => '',
|
||||
'description' => 'Count a list of a competency frameworks.',
|
||||
'type' => 'read',
|
||||
'capabilities'=> 'tool/lp:competencyview',
|
||||
),
|
||||
'tool_lp_data_for_competency_frameworks_manage_page' => array(
|
||||
'classname' => 'tool_lp\external',
|
||||
'methodname' => 'data_for_competency_frameworks_manage_page',
|
||||
'classpath' => '',
|
||||
'description' => 'Load the data for the competency frameworks manage page template',
|
||||
'type' => 'read',
|
||||
'capabilities'=> 'tool/lp:competencyview',
|
||||
),
|
||||
'tool_lp_reorder_competency_framework' => array(
|
||||
'classname' => 'tool_lp\external',
|
||||
'methodname' => 'reorder_competency_framework',
|
||||
'classpath' => '',
|
||||
'description' => 'Move a competency framework to a new relative sort order.',
|
||||
'type' => 'write',
|
||||
'capabilities'=> 'tool/lp:competencymanage',
|
||||
),
|
||||
'tool_lp_create_competency' => array(
|
||||
'classname' => 'tool_lp\external',
|
||||
'methodname' => 'create_competency',
|
||||
'classpath' => '',
|
||||
'description' => 'Creates new competencies.',
|
||||
'type' => 'write',
|
||||
'capabilities'=> 'tool/lp:competencymanage',
|
||||
),
|
||||
'tool_lp_read_competency' => array(
|
||||
'classname' => 'tool_lp\external',
|
||||
'methodname' => 'read_competency',
|
||||
'classpath' => '',
|
||||
'description' => 'Load a summary of a competency.',
|
||||
'type' => 'read',
|
||||
'capabilities'=> 'tool/lp:competencyview',
|
||||
),
|
||||
'tool_lp_delete_competency' => array(
|
||||
'classname' => 'tool_lp\external',
|
||||
'methodname' => 'delete_competency',
|
||||
'classpath' => '',
|
||||
'description' => 'Delete a competency.',
|
||||
'type' => 'write',
|
||||
'capabilities'=> 'tool/lp:competencymanage',
|
||||
),
|
||||
'tool_lp_update_competency' => array(
|
||||
'classname' => 'tool_lp\external',
|
||||
'methodname' => 'update_competency',
|
||||
'classpath' => '',
|
||||
'description' => 'Update a competency.',
|
||||
'type' => 'write',
|
||||
'capabilities'=> 'tool/lp:competencymanage',
|
||||
),
|
||||
'tool_lp_list_competencies' => array(
|
||||
'classname' => 'tool_lp\external',
|
||||
'methodname' => 'list_competencies',
|
||||
'classpath' => '',
|
||||
'description' => 'Load a list of a competencies.',
|
||||
'type' => 'read',
|
||||
'capabilities'=> 'tool/lp:competencyview',
|
||||
),
|
||||
'tool_lp_count_competencies' => array(
|
||||
'classname' => 'tool_lp\external',
|
||||
'methodname' => 'count_competencies',
|
||||
'classpath' => '',
|
||||
'description' => 'Count a list of a competencies.',
|
||||
'type' => 'read',
|
||||
'capabilities'=> 'tool/lp:competencyview',
|
||||
),
|
||||
'tool_lp_search_competencies' => array(
|
||||
'classname' => 'tool_lp\external',
|
||||
'methodname' => 'search_competencies',
|
||||
'classpath' => '',
|
||||
'description' => 'Search a list of a competencies.',
|
||||
'type' => 'read',
|
||||
'capabilities'=> 'tool/lp:competencyview',
|
||||
),
|
||||
'tool_lp_data_for_competencies_manage_page' => array(
|
||||
'classname' => 'tool_lp\external',
|
||||
'methodname' => 'data_for_competencies_manage_page',
|
||||
'classpath' => '',
|
||||
'description' => 'Load the data for the competencies manage page template',
|
||||
'type' => 'read',
|
||||
'capabilities'=> 'tool/lp:competencyview',
|
||||
),
|
||||
'tool_lp_set_parent_competency' => array(
|
||||
'classname' => 'tool_lp\external',
|
||||
'methodname' => 'set_parent_competency',
|
||||
'classpath' => '',
|
||||
'description' => 'Set a new parent for a competency.',
|
||||
'type' => 'write',
|
||||
'capabilities'=> 'tool/lp:competencymanage',
|
||||
),
|
||||
'tool_lp_move_up_competency' => array(
|
||||
'classname' => 'tool_lp\external',
|
||||
'methodname' => 'move_up_competency',
|
||||
'classpath' => '',
|
||||
'description' => 'Re-order a competency.',
|
||||
'type' => 'write',
|
||||
'capabilities'=> 'tool/lp:competencymanage',
|
||||
),
|
||||
'tool_lp_move_down_competency' => array(
|
||||
'classname' => 'tool_lp\external',
|
||||
'methodname' => 'move_down_competency',
|
||||
'classpath' => '',
|
||||
'description' => 'Re-order a competency.',
|
||||
'type' => 'write',
|
||||
'capabilities'=> 'tool/lp:competencymanage',
|
||||
),
|
||||
'tool_lp_list_competencies_in_course' => array(
|
||||
'classname' => 'tool_lp\external',
|
||||
'methodname' => 'list_competencies_in_course',
|
||||
'classpath' => '',
|
||||
'description' => 'List the competencies in a course',
|
||||
'type' => 'read',
|
||||
'capabilities'=> 'tool/lp:coursecompetencyread',
|
||||
),
|
||||
'tool_lp_list_courses_using_competency' => array(
|
||||
'classname' => 'tool_lp\external',
|
||||
'methodname' => 'list_courses_using_competency',
|
||||
'classpath' => '',
|
||||
'description' => 'List the courses using a competency',
|
||||
'type' => 'read',
|
||||
'capabilities'=> 'tool/lp:coursecompetencyread',
|
||||
),
|
||||
'tool_lp_count_competencies_in_course' => array(
|
||||
'classname' => 'tool_lp\external',
|
||||
'methodname' => 'count_competencies_in_course',
|
||||
'classpath' => '',
|
||||
'description' => 'List the competencies in a course',
|
||||
'type' => 'read',
|
||||
'capabilities'=> 'tool/lp:coursecompetencyread',
|
||||
),
|
||||
'tool_lp_count_courses_using_competency' => array(
|
||||
'classname' => 'tool_lp\external',
|
||||
'methodname' => 'count_courses_using_competency',
|
||||
'classpath' => '',
|
||||
'description' => 'List the courses using a competency',
|
||||
'type' => 'read',
|
||||
'capabilities'=> 'tool/lp:coursecompetencyread',
|
||||
),
|
||||
'tool_lp_add_competency_to_course' => array(
|
||||
'classname' => 'tool_lp\external',
|
||||
'methodname' => 'add_competency_to_course',
|
||||
'classpath' => '',
|
||||
'description' => 'Add the competency to a course',
|
||||
'type' => 'write',
|
||||
'capabilities'=> 'tool/lp:coursecompetencymanage',
|
||||
),
|
||||
'tool_lp_remove_competency_from_course' => array(
|
||||
'classname' => 'tool_lp\external',
|
||||
'methodname' => 'remove_competency_from_course',
|
||||
'classpath' => '',
|
||||
'description' => 'Remove a competency from a course',
|
||||
'type' => 'write',
|
||||
'capabilities'=> 'tool/lp:coursecompetencymanage',
|
||||
),
|
||||
'tool_lp_data_for_course_competencies_page' => array(
|
||||
'classname' => 'tool_lp\external',
|
||||
'methodname' => 'data_for_course_competencies_page',
|
||||
'classpath' => '',
|
||||
'description' => 'Load the data for the course competencies page template.',
|
||||
'type' => 'read',
|
||||
'capabilities'=> 'tool/lp:coursecompetencyread',
|
||||
),
|
||||
'tool_lp_reorder_course_competency' => array(
|
||||
'classname' => 'tool_lp\external',
|
||||
'methodname' => 'reorder_course_competency',
|
||||
'classpath' => '',
|
||||
'description' => 'Move a course competency to a new relative sort order.',
|
||||
'type' => 'write',
|
||||
'capabilities'=> 'tool/lp:coursecompetencymanage',
|
||||
),
|
||||
'tool_lp_create_template' => array(
|
||||
'classname' => 'tool_lp\external',
|
||||
'methodname' => 'create_template',
|
||||
'classpath' => '',
|
||||
'description' => 'Creates new learning plan templates.',
|
||||
'type' => 'write',
|
||||
'capabilities'=> 'tool/lp:templatemanage',
|
||||
),
|
||||
'tool_lp_read_template' => array(
|
||||
'classname' => 'tool_lp\external',
|
||||
'methodname' => 'read_template',
|
||||
'classpath' => '',
|
||||
'description' => 'Load a summary of a learning plan template.',
|
||||
'type' => 'read',
|
||||
'capabilities'=> 'tool/lp:templateview',
|
||||
),
|
||||
'tool_lp_delete_template' => array(
|
||||
'classname' => 'tool_lp\external',
|
||||
'methodname' => 'delete_template',
|
||||
'classpath' => '',
|
||||
'description' => 'Delete a learning plan template.',
|
||||
'type' => 'write',
|
||||
'capabilities'=> 'tool/lp:templatemanage',
|
||||
),
|
||||
'tool_lp_update_template' => array(
|
||||
'classname' => 'tool_lp\external',
|
||||
'methodname' => 'update_template',
|
||||
'classpath' => '',
|
||||
'description' => 'Update a learning plan template.',
|
||||
'type' => 'write',
|
||||
'capabilities'=> 'tool/lp:templatemanage',
|
||||
),
|
||||
'tool_lp_list_templates' => array(
|
||||
'classname' => 'tool_lp\external',
|
||||
'methodname' => 'list_templates',
|
||||
'classpath' => '',
|
||||
'description' => 'Load a list of a learning plan templates.',
|
||||
'type' => 'read',
|
||||
'capabilities'=> 'tool/lp:templateview',
|
||||
),
|
||||
'tool_lp_count_templates' => array(
|
||||
'classname' => 'tool_lp\external',
|
||||
'methodname' => 'count_templates',
|
||||
'classpath' => '',
|
||||
'description' => 'Count a list of a learning plan templates.',
|
||||
'type' => 'read',
|
||||
'capabilities'=> 'tool/lp:templateview',
|
||||
),
|
||||
'tool_lp_data_for_templates_manage_page' => array(
|
||||
'classname' => 'tool_lp\external',
|
||||
'methodname' => 'data_for_templates_manage_page',
|
||||
'classpath' => '',
|
||||
'description' => 'Load the data for the learning plan templates manage page template',
|
||||
'type' => 'read',
|
||||
'capabilities'=> 'tool/lp:templateview',
|
||||
),
|
||||
'tool_lp_reorder_template' => array(
|
||||
'classname' => 'tool_lp\external',
|
||||
'methodname' => 'reorder_template',
|
||||
'classpath' => '',
|
||||
'description' => 'Move a learning plan template to a new relative sort order.',
|
||||
'type' => 'write',
|
||||
'capabilities'=> 'tool/lp:templatemanage',
|
||||
),
|
||||
|
||||
);
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* This page lets users to manage site wide competencies.
|
||||
*
|
||||
* @package tool_lp
|
||||
* @copyright 2015 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(__DIR__ . '/../../../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
admin_externalpage_setup('toollpcompetencies');
|
||||
|
||||
$title = get_string('competencies', 'tool_lp');
|
||||
$id = optional_param('id', 0, PARAM_INT);
|
||||
$competencyframeworkid = required_param('competencyframeworkid', PARAM_INT);
|
||||
$parentid = optional_param('parentid', 0, PARAM_INT);
|
||||
|
||||
if (empty($id)) {
|
||||
$pagetitle = get_string('addnewcompetency', 'tool_lp');
|
||||
} else {
|
||||
$pagetitle = get_string('editcompetency', 'tool_lp');
|
||||
}
|
||||
// Set up the page.
|
||||
$params = array('id'=>$id, 'competencyframeworkid'=>$competencyframeworkid, 'parentid'=>$parentid);
|
||||
$url = new moodle_url("/admin/tool/lp/editcompetency.php", $params);
|
||||
$PAGE->set_url($url);
|
||||
$PAGE->set_title($title);
|
||||
$PAGE->set_heading($title);
|
||||
$output = $PAGE->get_renderer('tool_lp');
|
||||
|
||||
$competencyframework = \tool_lp\api::read_framework($competencyframeworkid);
|
||||
$parent = null;
|
||||
if ($parentid) {
|
||||
$parent = \tool_lp\api::read_competency($parentid);
|
||||
}
|
||||
|
||||
$form = new \tool_lp\form\competency(null, array('id' => $id, 'competencyframework' => $competencyframework, 'parent' => $parent));
|
||||
|
||||
if ($form->is_cancelled()) {
|
||||
redirect(new moodle_url('/admin/tool/lp/competencies.php', array('competencyframeworkid'=>$competencyframeworkid)));
|
||||
}
|
||||
|
||||
echo $output->header();
|
||||
echo $output->heading($pagetitle);
|
||||
|
||||
$data = $form->get_data();
|
||||
if ($data) {
|
||||
// Save the changes and continue back to the manage page.
|
||||
// Massage the editor data.
|
||||
$data->descriptionformat = $data->description['format'];
|
||||
$data->description = $data->description['text'];
|
||||
if (empty($data->id)) {
|
||||
// Create new framework.
|
||||
require_sesskey();
|
||||
\tool_lp\api::create_competency($data);
|
||||
echo $output->notification(get_string('competencycreated', 'tool_lp'), 'notifysuccess');
|
||||
echo $output->continue_button(new moodle_url('/admin/tool/lp/competencies.php', array('competencyframeworkid'=>$competencyframeworkid)));
|
||||
} else {
|
||||
require_sesskey();
|
||||
\tool_lp\api::update_competency($data);
|
||||
echo $output->notification(get_string('competencyupdated', 'tool_lp'), 'notifysuccess');
|
||||
echo $output->continue_button(new moodle_url('/admin/tool/lp/competencies.php', array('competencyframeworkid'=>$competencyframeworkid)));
|
||||
}
|
||||
} else {
|
||||
$form->display();
|
||||
}
|
||||
|
||||
|
||||
echo $output->footer();
|
||||
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* This page lets users to manage site wide competencies.
|
||||
*
|
||||
* @package tool_lp
|
||||
* @copyright 2015 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(__DIR__ . '/../../../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
admin_externalpage_setup('toollpcompetencies');
|
||||
|
||||
$title = get_string('competencies', 'tool_lp');
|
||||
$id = optional_param('id', 0, PARAM_INT);
|
||||
if (empty($id)) {
|
||||
$pagetitle = get_string('addnewcompetencyframework', 'tool_lp');
|
||||
} else {
|
||||
$pagetitle = get_string('editcompetencyframework', 'tool_lp');
|
||||
}
|
||||
// Set up the page.
|
||||
$url = new moodle_url("/admin/tool/lp/editcompetencyframework.php", array('id'=>$id));
|
||||
$PAGE->set_url($url);
|
||||
$PAGE->set_title($title);
|
||||
$PAGE->set_heading($title);
|
||||
$output = $PAGE->get_renderer('tool_lp');
|
||||
|
||||
$form = new \tool_lp\form\competency_framework(null, $id);
|
||||
|
||||
if ($form->is_cancelled()) {
|
||||
redirect(new moodle_url('/admin/tool/lp/competencyframeworks.php'));
|
||||
}
|
||||
|
||||
echo $output->header();
|
||||
echo $output->heading($pagetitle);
|
||||
|
||||
$data = $form->get_data();
|
||||
if ($data) {
|
||||
// Save the changes and continue back to the manage page.
|
||||
// Massage the editor data.
|
||||
$data->descriptionformat = $data->description['format'];
|
||||
$data->description = $data->description['text'];
|
||||
if (empty($data->id)) {
|
||||
// Create new framework.
|
||||
require_sesskey();
|
||||
\tool_lp\api::create_framework($data);
|
||||
echo $output->notification(get_string('competencyframeworkcreated', 'tool_lp'), 'notifysuccess');
|
||||
echo $output->continue_button('/admin/tool/lp/competencyframeworks.php');
|
||||
} else {
|
||||
require_sesskey();
|
||||
\tool_lp\api::update_framework($data);
|
||||
echo $output->notification(get_string('competencyframeworkupdated', 'tool_lp'), 'notifysuccess');
|
||||
echo $output->continue_button('/admin/tool/lp/competencyframeworks.php');
|
||||
}
|
||||
} else {
|
||||
$form->display();
|
||||
}
|
||||
|
||||
|
||||
echo $output->footer();
|
||||
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* This page lets users to manage site wide learning plan templates.
|
||||
*
|
||||
* @package tool_lp
|
||||
* @copyright 2015 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(__DIR__ . '/../../../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
admin_externalpage_setup('toollplearningplans');
|
||||
|
||||
$title = get_string('templates', 'tool_lp');
|
||||
$id = optional_param('id', 0, PARAM_INT);
|
||||
if (empty($id)) {
|
||||
$pagetitle = get_string('addnewtemplate', 'tool_lp');
|
||||
} else {
|
||||
$pagetitle = get_string('edittemplate', 'tool_lp');
|
||||
}
|
||||
// Set up the page.
|
||||
$url = new moodle_url("/admin/tool/lp/edittemplate.php", array('id'=>$id));
|
||||
$PAGE->set_url($url);
|
||||
$PAGE->set_title($title);
|
||||
$PAGE->set_heading($title);
|
||||
$output = $PAGE->get_renderer('tool_lp');
|
||||
|
||||
$form = new \tool_lp\form\template(null, $id);
|
||||
|
||||
if ($form->is_cancelled()) {
|
||||
redirect(new moodle_url('/admin/tool/lp/learningplans.php'));
|
||||
}
|
||||
|
||||
echo $output->header();
|
||||
echo $output->heading($pagetitle);
|
||||
|
||||
$data = $form->get_data();
|
||||
if ($data) {
|
||||
// Save the changes and continue back to the manage page.
|
||||
// Massage the editor data.
|
||||
$data->descriptionformat = $data->description['format'];
|
||||
$data->description = $data->description['text'];
|
||||
if (empty($data->id)) {
|
||||
// Create new template.
|
||||
require_sesskey();
|
||||
\tool_lp\api::create_template($data);
|
||||
echo $output->notification(get_string('templatecreated', 'tool_lp'), 'notifysuccess');
|
||||
echo $output->continue_button('/admin/tool/lp/learningplans.php');
|
||||
} else {
|
||||
require_sesskey();
|
||||
\tool_lp\api::update_template($data);
|
||||
echo $output->notification(get_string('templateupdated', 'tool_lp'), 'notifysuccess');
|
||||
echo $output->continue_button('/admin/tool/lp/learningplans.php');
|
||||
}
|
||||
} else {
|
||||
$form->display();
|
||||
}
|
||||
|
||||
|
||||
echo $output->footer();
|
||||
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* Strings for component 'tool_lp', language 'en'
|
||||
*
|
||||
* @package tool_lp
|
||||
* @copyright 2015 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
$string['pluginname'] = 'Learning Plans';
|
||||
$string['lp:learningplanmanage'] = 'Manage learning plans';
|
||||
$string['lp:learningplanread'] = 'View learning plans';
|
||||
$string['lp:competencymanage'] = 'Manage competency frameworks';
|
||||
$string['lp:competencyread'] = 'View competency frameworks';
|
||||
$string['lp:coursecompetencymanage'] = 'Manage course competencies';
|
||||
$string['lp:coursecompetencyread'] = 'View course competencies';
|
||||
$string['competencies'] = 'Competencies';
|
||||
$string['competenciesforframework'] = 'Competencies for {$a}';
|
||||
$string['competencyframeworks'] = 'Competency Frameworks';
|
||||
$string['addnewcompetencyframework'] = 'Add new competency framework';
|
||||
$string['addnewtemplate'] = 'Add new learning plan template';
|
||||
$string['addnewcompetency'] = 'Add new competency';
|
||||
$string['addcompetency'] = 'Add competency';
|
||||
$string['editcompetencyframework'] = 'Edit competency framework';
|
||||
$string['listcompetencyframeworkscaption'] = 'List of competency frameworks';
|
||||
$string['listtemplatescaption'] = 'List of learning plan templates';
|
||||
$string['competencyframeworkname'] = 'Name';
|
||||
$string['actions'] = 'Actions';
|
||||
$string['notemplates'] = 'No learning plan templates have been created yet.';
|
||||
$string['nocompetencyframeworks'] = 'No competency frameworks have been created yet.';
|
||||
$string['nocompetencies'] = 'No competencies have been created in this framework.';
|
||||
$string['nocompetenciesincourse'] = 'No competencies have been linked to this course.';
|
||||
|
||||
$string['shortname'] = 'Name';
|
||||
$string['savechanges'] = 'Save changes';
|
||||
$string['description'] = 'Description';
|
||||
$string['visible'] = 'Visible';
|
||||
$string['visible_help'] = 'A competency framework can be hidden from teachers. This could be useful if a framework is still in the process of being developed.';
|
||||
$string['idnumber'] = 'Id number';
|
||||
$string['competencyframework'] = 'Competency framework';
|
||||
$string['parentcompetency'] = 'Parent competency';
|
||||
$string['competencyframeworkcreated'] = 'Competency framework created.';
|
||||
$string['competencyframeworkupdated'] = 'Competency framework updated.';
|
||||
$string['editcompetencyframework'] = 'Edit competency framework';
|
||||
$string['editthiscompetencyframework'] = 'Edit';
|
||||
$string['deletethiscompetencyframework'] = 'Delete';
|
||||
$string['deletethistemplate'] = 'Delete';
|
||||
$string['hiddenhint'] = '(hidden)';
|
||||
$string['movecompetencyframework'] = 'Move competency framework';
|
||||
$string['movetonewparent'] = 'Relocate';
|
||||
$string['moveframeworkafter'] = 'Move competency framework after {$a}';
|
||||
$string['selectedcompetency'] = 'Selected competency';
|
||||
$string['nocompetencyselected'] = 'No competency selected';
|
||||
$string['search'] = 'Search...';
|
||||
$string['competencycreated'] = 'Competency created';
|
||||
$string['competencyupdated'] = 'Competency updated';
|
||||
$string['hidden'] = 'Hidden';
|
||||
$string['editcompetency'] = 'Edit competency';
|
||||
$string['confirm'] = 'Confirm';
|
||||
$string['delete'] = 'Delete';
|
||||
$string['deletecompetency'] = 'Delete competency? {$a}';
|
||||
$string['deletecompetencyframework'] = 'Delete competency framework? {$a}';
|
||||
$string['cancel'] = 'Cancel';
|
||||
$string['move'] = 'Move';
|
||||
$string['movecompetency'] = 'Move competency: {$a}';
|
||||
$string['selectcompetencymovetarget'] = 'Select a location to move this competency to:';
|
||||
$string['coursecompetencies'] = 'Course competencies';
|
||||
$string['linkcoursecompetencies'] = 'Link course competencies';
|
||||
$string['managecompetenciesandframeworks'] = 'Manage competencies and frameworks';
|
||||
$string['locatecompetency'] = 'Locate competency';
|
||||
$string['itemstoadd'] = 'Items to add';
|
||||
$string['linkedcourses'] = 'Linked courses';
|
||||
$string['nolinkedcourses'] = 'No courses are using this competency';
|
||||
$string['coursesusingthiscompetency'] = 'Courses using this competency';
|
||||
$string['learningplans'] = 'Learning plans';
|
||||
$string['movecoursecompetency'] = 'Move course competency';
|
||||
$string['movecoursecompetencyafter'] = 'Move course competency after {$a}';
|
||||
|
||||
$string['templates'] = 'Learning plan templates';
|
||||
$string['templatename'] = 'Name';
|
||||
$string['editthistemplate'] = 'Edit';
|
||||
$string['templatecreated'] = 'Learning plan template created';
|
||||
$string['templateupdated'] = 'Learning plan template updated';
|
||||
$string['edittemplate'] = 'Edit learning plan template';
|
||||
$string['deletetemplate'] = 'Delete learning plan template? {$a}';
|
||||
$string['duedate'] = 'Due date';
|
||||
$string['duedate_help'] = 'The date that a learning plan should be completed by.';
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* This page lets users to manage site wide competencies.
|
||||
*
|
||||
* @package tool_lp
|
||||
* @copyright 2015 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(__DIR__ . '/../../../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
admin_externalpage_setup('toollplearningplans');
|
||||
|
||||
$title = get_string('learningplans', 'tool_lp');
|
||||
$pagetitle = get_string('templates', 'tool_lp');
|
||||
// Set up the page.
|
||||
$url = new moodle_url("/admin/tool/lp/learningplans.php");
|
||||
$PAGE->set_url($url);
|
||||
$PAGE->set_title($title);
|
||||
$PAGE->set_heading($title);
|
||||
$output = $PAGE->get_renderer('tool_lp');
|
||||
echo $output->header();
|
||||
echo $output->heading($pagetitle);
|
||||
|
||||
$page = new \tool_lp\output\manage_templates_page();
|
||||
echo $output->render($page);
|
||||
|
||||
echo $output->footer();
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* This page contains navigation hooks for learning plans.
|
||||
*
|
||||
* @package tool_lp
|
||||
* @copyright 2015 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
/**
|
||||
* This function extends the course navigation
|
||||
*
|
||||
* @param navigation_node $navigation The navigation node to extend
|
||||
* @param stdClass $course The course to object for the tool
|
||||
* @param context $coursecontext The context of the course
|
||||
*/
|
||||
function tool_lp_extend_navigation_course($navigation, $course, $coursecontext) {
|
||||
// Just a link to course report.
|
||||
$title = get_string('coursecompetencies', 'tool_lp');
|
||||
$path = new moodle_url("/admin/tool/lp/coursecompetencies.php", array('courseid' => $course->id));
|
||||
$settingsnode = navigation_node::create($title,
|
||||
$path,
|
||||
navigation_node::TYPE_SETTING,
|
||||
null,
|
||||
null,
|
||||
new pix_icon('competency', '', 'tool_lp'));
|
||||
if (isset($settingsnode)) {
|
||||
$navigation->add_node($settingsnode);
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 994 B |
@@ -0,0 +1,76 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="32"
|
||||
height="32"
|
||||
id="svg2"
|
||||
version="1.1"
|
||||
inkscape:version="0.48.4 r9939"
|
||||
sodipodi:docname="New document 1">
|
||||
<defs
|
||||
id="defs4" />
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="5.6"
|
||||
inkscape:cx="32.609372"
|
||||
inkscape:cy="35.818362"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="false"
|
||||
width="33px"
|
||||
inkscape:window-width="1916"
|
||||
inkscape:window-height="981"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="72"
|
||||
inkscape:window-maximized="0" />
|
||||
<metadata
|
||||
id="metadata7">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"
|
||||
transform="translate(0,-1020.3622)">
|
||||
<g
|
||||
id="g3050"
|
||||
transform="matrix(0.92121849,0,0,0.92121849,-35.507391,91.120599)">
|
||||
<path
|
||||
style="fill:#fafafa"
|
||||
d="m 38.892857,1026.2908 0,-17 17,0 17,0 0,17 0,17 -17,0 -17,0 0,-17 z"
|
||||
id="path3056"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
style="fill:#989898"
|
||||
d="m 40.954049,1037.3439 c -3.465234,-3.0054 -1.687876,-4.0531 6.875853,-4.0531 6.919599,0 7.985143,0.2502 9.263277,2.1752 0.947236,1.4266 2.021632,1.9536 3.121972,1.5314 1.37559,-0.5279 1.677706,-2.0754 1.677706,-8.5934 0,-4.3723 0.273145,-8.6614 0.606989,-9.5314 0.509481,-1.3277 -0.303204,-1.5818 -5.059017,-1.5818 -3.522693,0 -5.432219,-0.3783 -5.047972,-1 1.028329,-1.6639 14.737848,-1.2221 17.277494,0.5567 3.593622,2.5171 2.823056,4.4433 -1.777494,4.4433 l -4,0 0,7.345 c 0,9.8743 -0.892111,10.655 -12.175731,10.655 -7.005509,0 -8.916904,-0.3458 -10.763077,-1.9469 z m 3.938808,-10.6589 c 0,-2.9538 0.324365,-3.3942 2.5,-3.3942 2.153991,0 2.499902,0.4498 2.499294,3.25 -6e-4,2.7611 -0.376693,3.2717 -2.5,3.3942 -2.203157,0.1271 -2.499294,-0.2579 -2.499294,-3.25 z m 7.428571,-1.3942 c 0,-1.6931 0.666667,-2 4.344732,-2 5.000845,0 4.927087,1.9191 -0.08232,2.1419 -3.011559,0.1339 -2.966069,0.1822 0.809017,0.8581 l 4,0.7162 -4.535714,0.1419 c -3.91635,0.1225 -4.535715,-0.1312 -4.535715,-1.8581 z m -6.761904,-3.6667 c -1.167788,-1.1678 -0.718106,-4.0457 0.833333,-5.3333 1.846181,-1.5322 4.5,0.2461 4.5,3.0155 0,2.2918 -3.735778,3.9154 -5.333333,2.3178 z m 6.833333,-0.3333 c 0.339919,-0.55 2.139919,-1 4,-1 1.860081,0 3.660081,0.45 4,1 0.377944,0.6115 -1.175955,1 -4,1 -2.824045,0 -4.377944,-0.3885 -4,-1 z"
|
||||
id="path3054"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
style="fill:#5e5e5e"
|
||||
d="m 40.892857,1036.2908 c -1.027328,-1.9196 -0.76049,-2 6.636076,-2 5.863885,0 8.157677,0.4084 9.593719,1.708 1.429812,1.2939 2.297278,1.4506 3.578741,0.6463 1.318167,-0.8273 1.801811,-3.0713 2.191464,-10.1678 l 0.5,-9.1062 -5.5,-0.351 c -4.40263,-0.2811 -3.893849,-0.3889 2.55,-0.5402 5.16365,-0.1213 8.480263,0.2412 9.25,1.0109 2.011735,2.0117 1.364232,2.8 -2.3,2.8 l -3.5,0 0,7.0657 c 0,10.7479 -0.204518,10.9343 -12,10.9343 -8.906177,0 -10.039956,-0.2061 -11,-2 z m 5.078947,-9.0357 c -0.06465,-2.8954 0.283272,-3.5357 1.921053,-3.5357 1.608782,0 2,0.6666 2,3.4081 0,2.8111 -0.245749,3.2042 -1.402754,2.244 -1.077175,-0.894 -1.523051,-0.8644 -1.921053,0.1276 -0.285064,0.7104 -0.553825,-0.2994 -0.597246,-2.244 z m 8.682712,-0.6716 c 1.243913,-0.2392 3.043913,-0.2301 4,0.02 0.956088,0.2503 -0.06166,0.446 -2.261659,0.4349 -2.2,-0.011 -2.982253,-0.2159 -1.738341,-0.4551 z m 0,-3 c 1.243913,-0.2392 3.043913,-0.2301 4,0.02 0.956088,0.2503 -0.06166,0.446 -2.261659,0.4349 -2.2,-0.011 -2.982253,-0.2159 -1.738341,-0.4551 z m 0,-2 c 1.243913,-0.2392 3.043913,-0.2301 4,0.02 0.956088,0.2503 -0.06166,0.446 -2.261659,0.4349 -2.2,-0.011 -2.982253,-0.2159 -1.738341,-0.4551 z m -9.205886,-1.2025 c -0.810187,-1.3109 0.447721,-4.0902 1.851216,-4.0902 1.828446,0 3.499178,2.081 2.907877,3.6219 -0.592966,1.5452 -3.892838,1.87 -4.759093,0.4683 z"
|
||||
id="path3052"
|
||||
inkscape:connector-curvature="0" />
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.7 KiB |
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* Links and settings
|
||||
*
|
||||
* This file contains links and settings used by tool_lp
|
||||
*
|
||||
* @package tool_lp
|
||||
* @copyright 2015 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
// Manage competency frameworks page.
|
||||
$temp = new admin_externalpage(
|
||||
'toollpcompetencies',
|
||||
get_string('competencyframeworks', 'tool_lp'),
|
||||
new moodle_url('/admin/tool/lp/competencyframeworks.php'),
|
||||
'tool/lp:competencymanage'
|
||||
);
|
||||
$ADMIN->add('root', $temp, 'badges');
|
||||
// Manage learning plans page.
|
||||
$temp = new admin_externalpage(
|
||||
'toollplearningplans',
|
||||
get_string('learningplans', 'tool_lp'),
|
||||
new moodle_url('/admin/tool/lp/learningplans.php'),
|
||||
'tool/lp:learningplanmanage'
|
||||
);
|
||||
$ADMIN->add('root', $temp, 'toollpcompetencies');
|
||||
|
||||
// No report settings.
|
||||
$settings = null;
|
||||
@@ -0,0 +1,59 @@
|
||||
.path-admin-tool-learningplan [data-region="managecompetencies"] ul li,
|
||||
.path-admin-tool-learningplan [data-region="competencymovetree"] ul li,
|
||||
.path-admin-tool-learningplan [data-region="competencylinktree"] ul li {
|
||||
list-style-type: none;
|
||||
}
|
||||
|
||||
.path-admin-tool-learningplan [data-region="managecompetencies"] ul li img {
|
||||
margin-left: -20px;
|
||||
margin-right: 4px;
|
||||
}
|
||||
.dir-rtl.path-admin-tool-learningplan [data-region="managecompetencies"] ul li img {
|
||||
margin-right: -20px;
|
||||
margin-left: 4px;
|
||||
}
|
||||
|
||||
.path-admin-tool-learningplan [data-region="managecompetencies"] ul[data-enhance="tree"],
|
||||
.path-admin-tool-learningplan [data-region="competencylinktree"] ul[data-enhance="linktree"],
|
||||
.path-admin-tool-learningplan [data-region="competencymovetree"] ul[data-enhance="movetree"] {
|
||||
border: 1px solid #ccc;
|
||||
box-shadow: inset 0 1px 1px rgba(0,0,0,0.075);
|
||||
transition: border linear .2s,box-shadow linear .2s;
|
||||
border-radius: 4px;
|
||||
padding-left: 20px;
|
||||
padding-right: 20px;
|
||||
margin-left: 10px;
|
||||
margin-right: 10px;
|
||||
}
|
||||
.path-admin-tool-learningplan [data-region="managecompetencies"] ul,
|
||||
.path-admin-tool-learningplan [data-region="competencylinktree"] ul,
|
||||
.path-admin-tool-learningplan [data-region="competencymovetree"] ul {
|
||||
cursor: pointer;
|
||||
}
|
||||
.path-admin-tool-learningplan [data-region="competencylinktree"] ul [aria-selected="true"],
|
||||
.path-admin-tool-learningplan [data-region="competencymovetree"] ul [aria-selected="true"],
|
||||
.path-admin-tool-learningplan [data-region="managecompetencies"] ul [aria-selected="true"] {
|
||||
background-color: #dfdfdf;
|
||||
}
|
||||
.path-admin-tool-learningplan [data-region="filtercompetencies"] input {
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
.path-admin-tool-learningplan [data-region="link-buttons"],
|
||||
.path-admin-tool-learningplan [data-region="move-buttons"] {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.dir-rtl.path-admin-tool-learningplan [data-region="filtercompetencies"] input {
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.path-admin-tool-learningplan [data-region="competencyactionsmenu"] {
|
||||
display: none;
|
||||
}
|
||||
.path-admin-tool-learningplan [data-region="competencyactionsmenu"] .moodle-actionmenu[data-enhanced].show .menu {
|
||||
white-space: nowrap;
|
||||
}
|
||||
.path-admin-tool-learningplan .currentdragtarget {
|
||||
border: 1px dashed;
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
{{!
|
||||
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/>.
|
||||
}}
|
||||
{{!
|
||||
Manage competencies template.
|
||||
|
||||
Classes required for JS:
|
||||
|
||||
Data attibutes required for JS:
|
||||
* data-enhance=tree
|
||||
|
||||
Context variables required for this template:
|
||||
* framework -
|
||||
* competencies - array of objects containing id, shortname, idnumber, sortorder, visible, parentid, competencyframeworkid, path
|
||||
}}
|
||||
<div data-region="competencymovetree" >
|
||||
<label>{{#str}}selectcompetencymovetarget, tool_lp{{/str}}</label>
|
||||
|
||||
<ul data-enhance="movetree">
|
||||
<li>{{framework.shortname}}
|
||||
<ul>
|
||||
{{#competencies}}
|
||||
{{> tool_lp/competencies_tree }}
|
||||
{{/competencies}}
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div data-region="move-buttons">
|
||||
<input type="button" data-action="move" value="{{#str}}move{{/str}}"/>
|
||||
<input type="button" data-action="cancel" value="{{#str}}cancel{{/str}}"/>
|
||||
</div>
|
||||
@@ -0,0 +1,12 @@
|
||||
<li data-id="{{id}}" draggable="true">
|
||||
{{^visible}}<span class="disabled">{{/visible}}
|
||||
{{shortname}} <em>{{idnumber}}</em>
|
||||
{{^visible}}</span>{{/visible}}
|
||||
{{#haschildren}}
|
||||
<ul>
|
||||
{{#children}}
|
||||
{{> tool_lp/competencies_tree }}
|
||||
{{/children}}
|
||||
</ul>
|
||||
{{/haschildren}}
|
||||
</li>
|
||||
@@ -0,0 +1,5 @@
|
||||
<p><strong>{{shortname}} <em>{{idnumber}}</em></strong></p>
|
||||
<p>{{descriptionformatted}}</p>
|
||||
{{^visible}}
|
||||
( {{#str}} hidden, tool_lp{{/str}})
|
||||
{{/visible}}
|
||||
@@ -0,0 +1,56 @@
|
||||
{{!
|
||||
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/>.
|
||||
}}
|
||||
{{!
|
||||
Course competencies template.
|
||||
}}
|
||||
<div data-region="coursecompetenciespage">
|
||||
<div data-region="coursecompetencies">
|
||||
<table class="generaltable fullwidth managecompetencies">
|
||||
<tbody class="drag-parentnode">
|
||||
{{#competencies}}
|
||||
<tr class="drag-samenode" data-id="{{id}}">
|
||||
<td>
|
||||
<span class="drag-handlecontainer pull-left"></span>
|
||||
<div class="pull-right"><a href="#" data-action="delete-competency-link" data-id="{{id}}">{{#pix}}t/delete, core, {{#str}}delete{{/str}}{{/pix}}</a></div>
|
||||
{{> tool_lp/competency_summary }}
|
||||
</td>
|
||||
</tr>
|
||||
{{/competencies}}
|
||||
</tbody>
|
||||
</table>
|
||||
{{^competencies}}
|
||||
<p class="alert-info">
|
||||
{{#str}}nocompetenciesincourse, tool_lp{{/str}}
|
||||
</p>
|
||||
{{/competencies}}
|
||||
</div>
|
||||
<div data-region="actions">
|
||||
<div class="pull-right">
|
||||
{{#canmanagecoursecompetencies}}
|
||||
<button style="display: none">{{#str}}linkcoursecompetencies, tool_lp{{/str}}</button>
|
||||
{{/canmanagecoursecompetencies}}
|
||||
</div>
|
||||
{{#canmanagecompetencyframeworks}}
|
||||
<p><a href="{{manageurl}}">{{#str}}managecompetenciesandframeworks, tool_lp{{/str}}</a></p>
|
||||
{{/canmanagecompetencyframeworks}}
|
||||
</div>
|
||||
</div>
|
||||
{{#js}}
|
||||
require(['tool_lp/coursecompetencies'], function(mod) {
|
||||
(new mod({{courseid}}));
|
||||
});
|
||||
{{/js}}
|
||||
@@ -0,0 +1,29 @@
|
||||
<div data-region="competencylinktree">
|
||||
<h3>{{#str}}competencyframeworks, tool_lp{{/str}}</h3>
|
||||
<select data-action="chooseframework">
|
||||
{{#frameworks}}
|
||||
<option value="{{id}}" {{#selected}}selected="selected"{{/selected}}>{{shortname}} <em>{{idnumber}}</em></option>
|
||||
{{/frameworks}}
|
||||
</select>
|
||||
<h3>{{#str}}locatecompetency, tool_lp{{/str}}</h3>
|
||||
|
||||
|
||||
<form data-region="filtercompetencies" data-frameworkid="{{framework.id}}">
|
||||
<label class="accesshide" for="filter{{uniqid}}">{{#str}}search, tool_lp{{/str}}</label>
|
||||
<input type="text" id="filter{{uniqid}}" placeholder="{{#str}}search, tool_lp{{/str}}" value="{{search}}">
|
||||
<button>{{#pix}}a/search, , {{#str}}search{{/str}}{{/pix}}</button>
|
||||
</form>
|
||||
<ul data-enhance="linktree">
|
||||
<li>{{framework.shortname}}
|
||||
<ul>
|
||||
{{#competencies}}
|
||||
{{> tool_lp/competencies_tree }}
|
||||
{{/competencies}}
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<div data-region="link-buttons">
|
||||
<input type="button" data-action="add" value="{{#str}}add{{/str}}"/>
|
||||
<input type="button" data-action="cancel" value="{{#str}}cancel{{/str}}"/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,11 @@
|
||||
<p>
|
||||
{{#str}}coursesusingthiscompetency, tool_lp{{/str}}
|
||||
</p>
|
||||
<ol>
|
||||
{{#courses}}
|
||||
<li><a href="{{courseviewurl}}?id={{id}}">{{{fullnameformatted}}} {{{shortnameformatted}}}</a></li>
|
||||
{{/courses}}
|
||||
{{^courses}}
|
||||
{{#str}}nolinkedcourses, tool_lp{{/str}}
|
||||
{{/courses}}
|
||||
</ol>
|
||||
@@ -0,0 +1,114 @@
|
||||
{{!
|
||||
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/>.
|
||||
}}
|
||||
{{!
|
||||
Manage competencies template.
|
||||
|
||||
Classes required for JS:
|
||||
|
||||
Data attibutes required for JS:
|
||||
* data-enhance=tree
|
||||
|
||||
Context variables required for this template:
|
||||
* framework -
|
||||
* competencies - array of objects containing id, shortname, idnumber, sortorder, visible, parentid, competencyframeworkid, path
|
||||
* canmanage - true if this user has permission to manage the competencies
|
||||
}}
|
||||
<div data-region="managecompetencies" >
|
||||
|
||||
<div class="row">
|
||||
<div class="span6">
|
||||
<p>
|
||||
<form data-region="filtercompetencies" data-frameworkid="{{framework.id}}">
|
||||
<label class="accesshide" for="filter{{uniqid}}">{{#str}}search, tool_lp{{/str}}</label>
|
||||
<input type="text" id="filter{{uniqid}}" placeholder="{{#str}}search, tool_lp{{/str}}" value="{{search}}">
|
||||
<button>{{#pix}}a/search, , {{#str}}search{{/str}}{{/pix}}</button>
|
||||
</form>
|
||||
</p>
|
||||
<ul data-enhance="tree">
|
||||
<li>{{framework.shortname}}
|
||||
<ul>
|
||||
{{#competencies}}
|
||||
{{> tool_lp/competencies_tree }}
|
||||
{{/competencies}}
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="span6 well">
|
||||
<h4>{{#str}}selectedcompetency, tool_lp{{/str}}</h4>
|
||||
<p data-region="competencyinfo">
|
||||
{{#str}}nocompetencyselected, tool_lp{{/str}}
|
||||
</p>
|
||||
{{#canmanage}}
|
||||
<div data-region="competencyactions">
|
||||
<div class="btn-group">
|
||||
<button class="btn" data-action="add" disabled="disabled">{{#pix}}t/add{{/pix}} {{#str}}addcompetency, tool_lp{{/str}}</button>
|
||||
</div>
|
||||
<div data-region="competencyactionsmenu">
|
||||
<ul class="competencyactionsmenu">
|
||||
<li>
|
||||
<a href="#" data-action="edit">
|
||||
{{#pix}}t/edit{{/pix}}{{#str}}edit{{/str}}
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" data-action="move">
|
||||
{{#pix}}t/move{{/pix}}{{#str}}movetonewparent, tool_lp{{/str}}
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" data-action="delete">
|
||||
{{#pix}}t/delete{{/pix}}{{#str}}delete{{/str}}
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" data-action="moveup">
|
||||
{{#pix}}t/up{{/pix}}{{#str}}moveup{{/str}}
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" data-action="movedown">
|
||||
{{#pix}}t/down{{/pix}}{{#str}}movedown{{/str}}
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" data-action="linkedcourses">
|
||||
{{#pix}}t/viewdetails{{/pix}}{{#str}}linkedcourses, tool_lp{{/str}}
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
{{/canmanage}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{#js}}
|
||||
// Initialise the JS.
|
||||
require(['core/tree', 'tool_lp/competencytree', 'tool_lp/competencyactions' ], function(ariatree, treeModel, actions) {
|
||||
|
||||
treeModel.init({{framework.id}});
|
||||
|
||||
actions.init(treeModel);
|
||||
|
||||
var competencytree = new ariatree('[data-enhance=tree]', actions.selectionChanged);
|
||||
|
||||
});
|
||||
{{/js}}
|
||||
|
||||
</div>
|
||||
@@ -0,0 +1,100 @@
|
||||
{{!
|
||||
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/>.
|
||||
}}
|
||||
{{!
|
||||
Manage competency frameworks template.
|
||||
|
||||
Classes required for JS:
|
||||
* drag-parentnode
|
||||
* drag-handlecontainer
|
||||
* drag-samenode
|
||||
* competencyframeworkactions
|
||||
|
||||
Data attibutes required for JS:
|
||||
* data-region = managecompetencies
|
||||
* data-frameworkid = id
|
||||
* data-action = deletecompetencyframework
|
||||
|
||||
Context variables required for this template:
|
||||
* competencyframeworks - array of objects containing id, shortname, idnumber, sortorder, visible
|
||||
* canmanage - true if this user has permission to manage the frameworks
|
||||
* navigation - array of strings containing buttons for navigation
|
||||
}}
|
||||
<div data-region="managecompetencies">
|
||||
<table class="generaltable fullwidth managecompetencies">
|
||||
<caption>{{#str}}listcompetencyframeworkscaption, tool_lp{{/str}}</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">{{#str}}competencyframeworkname, tool_lp{{/str}}</th>
|
||||
<th scope="col">{{#str}}competencies, tool_lp{{/str}}</th>
|
||||
<th scope="col">{{#str}}actions, tool_lp{{/str}}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="drag-parentnode">
|
||||
{{#competencyframeworks}}
|
||||
<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>{{competencies_count}}</td>
|
||||
<td>
|
||||
{{#canmanage}}
|
||||
<div style="display: inline-block;">
|
||||
<ul class="competencyframeworkactions hide">
|
||||
<li>
|
||||
<a href="{{pluginbaseurl}}/editcompetencyframework.php?id={{id}}">
|
||||
{{#pix}}t/edit{{/pix}}{{#str}}editthiscompetencyframework, tool_lp{{/str}}
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a data-action="deletecompetencyframework" data-frameworkid="{{id}}" href="#">
|
||||
{{#pix}}t/delete{{/pix}}{{#str}}deletethiscompetencyframework, tool_lp{{/str}}
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
{{/canmanage}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/competencyframeworks}}
|
||||
</tbody>
|
||||
</table>
|
||||
{{^competencyframeworks}}
|
||||
<p class="alert-info">
|
||||
{{#str}}nocompetencyframeworks, tool_lp{{/str}}
|
||||
</p>
|
||||
{{/competencyframeworks}}
|
||||
|
||||
<div class="btn-group pull-right">
|
||||
{{#navigation}}
|
||||
{{{.}}}
|
||||
{{/navigation}}
|
||||
</div>
|
||||
|
||||
{{#js}}
|
||||
// Initialise the JS.
|
||||
require(['tool_lp/frameworkdelete',
|
||||
'core/menu',
|
||||
'tool_lp/frameworkmove'],
|
||||
function(deleteMod, menu, moveMod) {
|
||||
|
||||
deleteMod.init();
|
||||
moveMod.init();
|
||||
|
||||
menu.menu('{{#str}}edit{{/str}}', '.competencyframeworkactions');
|
||||
});
|
||||
|
||||
{{/js}}
|
||||
|
||||
</div>
|
||||
@@ -0,0 +1,98 @@
|
||||
{{!
|
||||
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/>.
|
||||
}}
|
||||
{{!
|
||||
Manage learning plan templates template.
|
||||
|
||||
Classes required for JS:
|
||||
* drag-parentnode
|
||||
* drag-handlecontainer
|
||||
* drag-samenode
|
||||
* templateactions
|
||||
|
||||
Data attibutes required for JS:
|
||||
* data-region = managetemplates
|
||||
* data-templateid = id
|
||||
* data-action = deletetemplate
|
||||
|
||||
Context variables required for this template:
|
||||
* templates - array of objects containing id, shortname, idnumber, sortorder, visible
|
||||
* canmanage - true if this user has permission to manage the templates
|
||||
* navigation - array of strings containing buttons for navigation
|
||||
}}
|
||||
<div data-region="managetemplates">
|
||||
<table class="generaltable fullwidth managetemplates">
|
||||
<caption>{{#str}}listtemplatescaption, tool_lp{{/str}}</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">{{#str}}templatename, tool_lp{{/str}}</th>
|
||||
<th scope="col">{{#str}}actions, tool_lp{{/str}}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="drag-parentnode">
|
||||
{{#templates}}
|
||||
<tr class="drag-samenode" data-templateid="{{id}}">
|
||||
<td><span class="drag-handlecontainer"></span><span><a href="{{pluginbaseurl}}/templatecompetencies.php?templateid={{id}}">{{shortname}} {{idnumber}}</a></span> {{^visible}}{{#str}}hiddenhint, tool_lp{{/str}}{{/visible}}</td>
|
||||
<td>
|
||||
{{#canmanage}}
|
||||
<div style="display: inline-block;">
|
||||
<ul class="templateactions hide">
|
||||
<li>
|
||||
<a href="{{pluginbaseurl}}/edittemplate.php?id={{id}}">
|
||||
{{#pix}}t/edit{{/pix}}{{#str}}editthistemplate, tool_lp{{/str}}
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a data-action="deletetemplate" data-templateid="{{id}}" href="#">
|
||||
{{#pix}}t/delete{{/pix}}{{#str}}deletethistemplate, tool_lp{{/str}}
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
{{/canmanage}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/templates}}
|
||||
</tbody>
|
||||
</table>
|
||||
{{^templates}}
|
||||
<p class="alert-info">
|
||||
{{#str}}notemplates, tool_lp{{/str}}
|
||||
</p>
|
||||
{{/templates}}
|
||||
|
||||
<div class="btn-group pull-right">
|
||||
{{#navigation}}
|
||||
{{{.}}}
|
||||
{{/navigation}}
|
||||
</div>
|
||||
|
||||
{{#js}}
|
||||
// Initialise the JS.
|
||||
require(['tool_lp/templatedelete',
|
||||
'core/menu',
|
||||
'tool_lp/templatemove'],
|
||||
function(deleteMod, menu, moveMod) {
|
||||
|
||||
deleteMod.init();
|
||||
moveMod.init();
|
||||
|
||||
menu.menu('{{#str}}edit{{/str}}', '.templateactions');
|
||||
});
|
||||
|
||||
{{/js}}
|
||||
|
||||
</div>
|
||||
@@ -0,0 +1,3 @@
|
||||
<p class="alert-error">
|
||||
{{#str}}nocompetencyframeworks, tool_lp{{/str}}
|
||||
</p>
|
||||
@@ -0,0 +1,578 @@
|
||||
<?php
|
||||
// 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/>.
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
global $CFG;
|
||||
|
||||
require_once($CFG->dirroot . '/webservice/tests/helpers.php');
|
||||
|
||||
use tool_lp\external;
|
||||
|
||||
/**
|
||||
* External learning plans webservice API tests.
|
||||
*
|
||||
* @package tool_lp
|
||||
* @copyright 2015 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class tool_lp_external_testcase extends externallib_advanced_testcase {
|
||||
|
||||
/** @var stdClass $learningplancreator User with enough permissions to create */
|
||||
protected $creator = null;
|
||||
|
||||
/** @var stdClass $learningplanuser User with enough permissions to view */
|
||||
protected $user = null;
|
||||
|
||||
/**
|
||||
* Setup function - we will create a course and add an assign instance to it.
|
||||
*/
|
||||
protected function setUp() {
|
||||
global $DB;
|
||||
|
||||
$this->resetAfterTest(true);
|
||||
|
||||
// Create some users.
|
||||
$creator = $this->getDataGenerator()->create_user();
|
||||
$user = $this->getDataGenerator()->create_user();
|
||||
$syscontext = context_system::instance();
|
||||
|
||||
$creatorrole = create_role('Creator role', 'creatorrole', 'learning plan creator role description');
|
||||
$userrole = create_role('User role', 'userrole', 'learning plan user role description');
|
||||
|
||||
assign_capability('tool/lp:competencymanage', CAP_ALLOW, $creatorrole, $syscontext->id);
|
||||
assign_capability('tool/lp:competencyview', CAP_ALLOW, $userrole, $syscontext->id);
|
||||
|
||||
role_assign($creatorrole, $creator->id, $syscontext->id);
|
||||
role_assign($userrole, $user->id, $syscontext->id);
|
||||
|
||||
$this->creator = $creator;
|
||||
$this->user = $user;
|
||||
accesslib_clear_all_caches_for_unit_testing();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test we can't create a competency framework with only read permissions.
|
||||
*/
|
||||
public function test_create_competency_frameworks_with_read_permissions() {
|
||||
$this->setExpectedException('required_capability_exception');
|
||||
$this->setUser($this->user);
|
||||
$result = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test we can create a competency framework with manage permissions.
|
||||
*/
|
||||
public function test_create_competency_frameworks_with_manage_permissions() {
|
||||
$this->setUser($this->creator);
|
||||
$result = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true);
|
||||
$result = (object) external_api::clean_returnvalue(external::create_competency_framework_returns(), $result);
|
||||
|
||||
$this->assertGreaterThan(0, $result->timecreated);
|
||||
$this->assertGreaterThan(0, $result->timemodified);
|
||||
$this->assertEquals($this->creator->id, $result->usermodified);
|
||||
$this->assertEquals('shortname', $result->shortname);
|
||||
$this->assertEquals('idnumber', $result->idnumber);
|
||||
$this->assertEquals('description', $result->description);
|
||||
$this->assertEquals(FORMAT_HTML, $result->descriptionformat);
|
||||
$this->assertEquals(true, $result->visible);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test we cannot create a competency framework with nasty data.
|
||||
*/
|
||||
public function test_create_competency_frameworks_with_nasty_data() {
|
||||
$this->setUser($this->creator);
|
||||
$this->setExpectedException('invalid_parameter_exception');
|
||||
$result = external::create_competency_framework('short<a href="">', 'id;"number', 'de<>\\..scription', FORMAT_HTML, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test we can read a competency framework with manage permissions.
|
||||
*/
|
||||
public function test_read_competency_frameworks_with_manage_permissions() {
|
||||
$this->setUser($this->creator);
|
||||
$result = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true);
|
||||
$result = (object) external_api::clean_returnvalue(external::create_competency_framework_returns(), $result);
|
||||
|
||||
$id = $result->id;
|
||||
$result = external::read_competency_framework($id);
|
||||
$result = (object) external_api::clean_returnvalue(external::read_competency_framework_returns(), $result);
|
||||
|
||||
$this->assertGreaterThan(0, $result->timecreated);
|
||||
$this->assertGreaterThan(0, $result->timemodified);
|
||||
$this->assertEquals($this->creator->id, $result->usermodified);
|
||||
$this->assertEquals('shortname', $result->shortname);
|
||||
$this->assertEquals('idnumber', $result->idnumber);
|
||||
$this->assertEquals('description', $result->description);
|
||||
$this->assertEquals(FORMAT_HTML, $result->descriptionformat);
|
||||
$this->assertEquals(true, $result->visible);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test we can read a competency framework with read permissions.
|
||||
*/
|
||||
public function test_read_competency_frameworks_with_read_permissions() {
|
||||
$this->setUser($this->creator);
|
||||
$result = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true);
|
||||
$result = (object) external_api::clean_returnvalue(external::create_competency_framework_returns(), $result);
|
||||
|
||||
// Switch users to someone with less permissions.
|
||||
$this->setUser($this->user);
|
||||
$id = $result->id;
|
||||
$result = external::read_competency_framework($id);
|
||||
$result = (object) external_api::clean_returnvalue(external::read_competency_framework_returns(), $result);
|
||||
|
||||
$this->assertGreaterThan(0, $result->timecreated);
|
||||
$this->assertGreaterThan(0, $result->timemodified);
|
||||
$this->assertEquals($this->creator->id, $result->usermodified);
|
||||
$this->assertEquals('shortname', $result->shortname);
|
||||
$this->assertEquals('idnumber', $result->idnumber);
|
||||
$this->assertEquals('description', $result->description);
|
||||
$this->assertEquals(FORMAT_HTML, $result->descriptionformat);
|
||||
$this->assertEquals(true, $result->visible);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test we can delete a competency framework with manage permissions.
|
||||
*/
|
||||
public function test_delete_competency_frameworks_with_manage_permissions() {
|
||||
$this->setUser($this->creator);
|
||||
$result = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true);
|
||||
$result = (object) external_api::clean_returnvalue(external::create_competency_framework_returns(), $result);
|
||||
|
||||
$id = $result->id;
|
||||
$result = external::delete_competency_framework($id);
|
||||
$result = external_api::clean_returnvalue(external::delete_competency_framework_returns(), $result);
|
||||
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test we can delete a competency framework with read permissions.
|
||||
*/
|
||||
public function test_delete_competency_frameworks_with_read_permissions() {
|
||||
$this->setExpectedException('required_capability_exception');
|
||||
$this->setUser($this->creator);
|
||||
$result = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true);
|
||||
$result = (object) external_api::clean_returnvalue(external::create_competency_framework_returns(), $result);
|
||||
|
||||
$id = $result->id;
|
||||
// Switch users to someone with less permissions.
|
||||
$this->setUser($this->user);
|
||||
$result = external::delete_competency_framework($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test we can update a competency framework with manage permissions.
|
||||
*/
|
||||
public function test_update_competency_frameworks_with_manage_permissions() {
|
||||
$this->setUser($this->creator);
|
||||
$result = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true);
|
||||
$result = (object) external_api::clean_returnvalue(external::create_competency_framework_returns(), $result);
|
||||
|
||||
$result = external::update_competency_framework($result->id, 'shortname2', 'idnumber2', 'description2', FORMAT_PLAIN, false);
|
||||
$result = external_api::clean_returnvalue(external::update_competency_framework_returns(), $result);
|
||||
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test we can update a competency framework with read permissions.
|
||||
*/
|
||||
public function test_update_competency_frameworks_with_read_permissions() {
|
||||
$this->setExpectedException('required_capability_exception');
|
||||
$this->setUser($this->creator);
|
||||
$result = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true);
|
||||
$result = (object) external_api::clean_returnvalue(external::create_competency_framework_returns(), $result);
|
||||
|
||||
$this->setUser($this->user);
|
||||
$result = external::update_competency_framework($result->id, 'shortname2', 'idnumber2', 'description2', FORMAT_PLAIN, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test we can list and count competency frameworks with manage permissions.
|
||||
*/
|
||||
public function test_list_and_count_competency_frameworks_with_manage_permissions() {
|
||||
$this->setUser($this->creator);
|
||||
$result = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true);
|
||||
$result = external::create_competency_framework('shortname2', 'idnumber2', 'description', FORMAT_HTML, true);
|
||||
$result = external::create_competency_framework('shortname3', 'idnumber3', 'description', FORMAT_HTML, true);
|
||||
|
||||
$result = external::count_competency_frameworks(array());
|
||||
$result = external_api::clean_returnvalue(external::count_competency_frameworks_returns(), $result);
|
||||
|
||||
$this->assertEquals($result, 3);
|
||||
|
||||
$result = external::list_competency_frameworks(array(), 'shortname', 'ASC', 0, 10);
|
||||
$result = external_api::clean_returnvalue(external::list_competency_frameworks_returns(), $result);
|
||||
|
||||
$this->assertEquals(count($result), 3);
|
||||
$result = (object) $result[0];
|
||||
|
||||
$this->assertGreaterThan(0, $result->timecreated);
|
||||
$this->assertGreaterThan(0, $result->timemodified);
|
||||
$this->assertEquals($this->creator->id, $result->usermodified);
|
||||
$this->assertEquals('shortname', $result->shortname);
|
||||
$this->assertEquals('idnumber', $result->idnumber);
|
||||
$this->assertEquals('description', $result->description);
|
||||
$this->assertEquals(FORMAT_HTML, $result->descriptionformat);
|
||||
$this->assertEquals(true, $result->visible);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test we can list and count competency frameworks with read permissions.
|
||||
*/
|
||||
public function test_list_and_count_competency_frameworks_with_read_permissions() {
|
||||
$this->setUser($this->creator);
|
||||
$result = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true);
|
||||
$result = external::create_competency_framework('shortname2', 'idnumber2', 'description', FORMAT_HTML, true);
|
||||
$result = external::create_competency_framework('shortname3', 'idnumber3', 'description', FORMAT_HTML, true);
|
||||
|
||||
$this->setUser($this->user);
|
||||
$result = external::count_competency_frameworks(array());
|
||||
$result = external_api::clean_returnvalue(external::count_competency_frameworks_returns(), $result);
|
||||
|
||||
$this->assertEquals($result, 3);
|
||||
|
||||
$result = external::list_competency_frameworks(array(), 'shortname', 'ASC', 0, 10);
|
||||
$result = external_api::clean_returnvalue(external::list_competency_frameworks_returns(), $result);
|
||||
|
||||
$this->assertEquals(count($result), 3);
|
||||
$result = (object) $result[0];
|
||||
|
||||
$this->assertGreaterThan(0, $result->timecreated);
|
||||
$this->assertGreaterThan(0, $result->timemodified);
|
||||
$this->assertEquals($this->creator->id, $result->usermodified);
|
||||
$this->assertEquals('shortname', $result->shortname);
|
||||
$this->assertEquals('idnumber', $result->idnumber);
|
||||
$this->assertEquals('description', $result->description);
|
||||
$this->assertEquals(FORMAT_HTML, $result->descriptionformat);
|
||||
$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.
|
||||
*/
|
||||
public function test_create_competency_with_read_permissions() {
|
||||
$this->setExpectedException('required_capability_exception');
|
||||
$framework = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true);
|
||||
$framework = (object) external_api::clean_returnvalue(external::create_competency_framework_returns(), $framework);
|
||||
$this->setUser($this->user);
|
||||
$competency = external::create_competency('shortname', 'idnumber', 'description', FORMAT_HTML, true, $framework->id, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test we can create a competency with manage permissions.
|
||||
*/
|
||||
public function test_create_competency_with_manage_permissions() {
|
||||
$this->setUser($this->creator);
|
||||
$framework = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true);
|
||||
$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 = (object) external_api::clean_returnvalue(external::create_competency_returns(), $competency);
|
||||
|
||||
$this->assertGreaterThan(0, $competency->timecreated);
|
||||
$this->assertGreaterThan(0, $competency->timemodified);
|
||||
$this->assertEquals($this->creator->id, $competency->usermodified);
|
||||
$this->assertEquals('shortname', $competency->shortname);
|
||||
$this->assertEquals('idnumber', $competency->idnumber);
|
||||
$this->assertEquals('description', $competency->description);
|
||||
$this->assertEquals(FORMAT_HTML, $competency->descriptionformat);
|
||||
$this->assertEquals(true, $competency->visible);
|
||||
$this->assertEquals(0, $competency->parentid);
|
||||
$this->assertEquals($framework->id, $competency->competencyframeworkid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test we cannot create a competency with nasty data.
|
||||
*/
|
||||
public function test_create_competency_with_nasty_data() {
|
||||
$this->setUser($this->creator);
|
||||
$framework = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true);
|
||||
$framework = (object) external_api::clean_returnvalue(external::create_competency_framework_returns(), $framework);
|
||||
$this->setExpectedException('invalid_parameter_exception');
|
||||
$competency = external::create_competency('shortname<a href="">', 'id;"number', 'de<>\\..scription', FORMAT_HTML, true, $framework->id, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test we can read a competency with manage permissions.
|
||||
*/
|
||||
public function test_read_competencies_with_manage_permissions() {
|
||||
$this->setUser($this->creator);
|
||||
$framework = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true);
|
||||
$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 = (object) external_api::clean_returnvalue(external::create_competency_returns(), $result);
|
||||
|
||||
$id = $result->id;
|
||||
$result = external::read_competency($id);
|
||||
$result = (object) external_api::clean_returnvalue(external::read_competency_returns(), $result);
|
||||
|
||||
$this->assertGreaterThan(0, $result->timecreated);
|
||||
$this->assertGreaterThan(0, $result->timemodified);
|
||||
$this->assertEquals($this->creator->id, $result->usermodified);
|
||||
$this->assertEquals('shortname', $result->shortname);
|
||||
$this->assertEquals('idnumber', $result->idnumber);
|
||||
$this->assertEquals('description', $result->description);
|
||||
$this->assertEquals(FORMAT_HTML, $result->descriptionformat);
|
||||
$this->assertEquals(true, $result->visible);
|
||||
$this->assertEquals(0, $result->parentid);
|
||||
$this->assertEquals(0, $result->parentid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test we can read a competency with read permissions.
|
||||
*/
|
||||
public function test_read_competencies_with_read_permissions() {
|
||||
$this->setUser($this->creator);
|
||||
$framework = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true);
|
||||
$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 = (object) external_api::clean_returnvalue(external::create_competency_returns(), $result);
|
||||
|
||||
// Switch users to someone with less permissions.
|
||||
$this->setUser($this->user);
|
||||
$id = $result->id;
|
||||
$result = external::read_competency($id);
|
||||
$result = (object) external_api::clean_returnvalue(external::read_competency_returns(), $result);
|
||||
|
||||
$this->assertGreaterThan(0, $result->timecreated);
|
||||
$this->assertGreaterThan(0, $result->timemodified);
|
||||
$this->assertEquals($this->creator->id, $result->usermodified);
|
||||
$this->assertEquals('shortname', $result->shortname);
|
||||
$this->assertEquals('idnumber', $result->idnumber);
|
||||
$this->assertEquals('description', $result->description);
|
||||
$this->assertEquals(FORMAT_HTML, $result->descriptionformat);
|
||||
$this->assertEquals(true, $result->visible);
|
||||
$this->assertEquals(0, $result->parentid);
|
||||
$this->assertEquals(0, $result->parentid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test we can delete a competency with manage permissions.
|
||||
*/
|
||||
public function test_delete_competency_with_manage_permissions() {
|
||||
$this->setUser($this->creator);
|
||||
$framework = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true);
|
||||
$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 = (object) external_api::clean_returnvalue(external::create_competency_returns(), $result);
|
||||
|
||||
$id = $result->id;
|
||||
$result = external::delete_competency($id);
|
||||
$result = external_api::clean_returnvalue(external::delete_competency_returns(), $result);
|
||||
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test we can delete a competency with read permissions.
|
||||
*/
|
||||
public function test_delete_competency_with_read_permissions() {
|
||||
$this->setExpectedException('required_capability_exception');
|
||||
$this->setUser($this->creator);
|
||||
$framework = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true);
|
||||
$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 = (object) external_api::clean_returnvalue(external::create_competency_returns(), $result);
|
||||
|
||||
$id = $result->id;
|
||||
// Switch users to someone with less permissions.
|
||||
$this->setUser($this->user);
|
||||
$result = external::delete_competency($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test we can update a competency with manage permissions.
|
||||
*/
|
||||
public function test_update_competency_with_manage_permissions() {
|
||||
$this->setUser($this->creator);
|
||||
$framework = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true);
|
||||
$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 = (object) external_api::clean_returnvalue(external::create_competency_returns(), $result);
|
||||
|
||||
$result = external::update_competency($result->id, 'shortname2', 'idnumber2', 'description2', FORMAT_HTML, false);
|
||||
$result = external_api::clean_returnvalue(external::update_competency_returns(), $result);
|
||||
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test we can update a competency with read permissions.
|
||||
*/
|
||||
public function test_update_competency_with_read_permissions() {
|
||||
$this->setExpectedException('required_capability_exception');
|
||||
$this->setUser($this->creator);
|
||||
$framework = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true);
|
||||
$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 = (object) external_api::clean_returnvalue(external::create_competency_returns(), $result);
|
||||
|
||||
$this->setUser($this->user);
|
||||
$result = external::update_competency($result->id, 'shortname2', 'idnumber2', 'description2', FORMAT_HTML, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test we can list and count competencies with manage permissions.
|
||||
*/
|
||||
public function test_list_and_count_competencies_with_manage_permissions() {
|
||||
$this->setUser($this->creator);
|
||||
$framework = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true);
|
||||
$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('shortname2', 'idnumber2', 'description2', FORMAT_HTML, true, $framework->id, 0);
|
||||
$result = external::create_competency('shortname3', 'idnumber3', 'description3', FORMAT_HTML, true, $framework->id, 0);
|
||||
|
||||
$result = external::count_competencies(array());
|
||||
$result = external_api::clean_returnvalue(external::count_competencies_returns(), $result);
|
||||
|
||||
$this->assertEquals($result, 3);
|
||||
|
||||
$result = external::list_competencies(array(), 'shortname', 'ASC', 0, 10);
|
||||
$result = external_api::clean_returnvalue(external::list_competencies_returns(), $result);
|
||||
|
||||
$this->assertEquals(count($result), 3);
|
||||
$result = (object) $result[0];
|
||||
|
||||
$this->assertGreaterThan(0, $result->timecreated);
|
||||
$this->assertGreaterThan(0, $result->timemodified);
|
||||
$this->assertEquals($this->creator->id, $result->usermodified);
|
||||
$this->assertEquals('shortname', $result->shortname);
|
||||
$this->assertEquals('idnumber', $result->idnumber);
|
||||
$this->assertEquals('description', $result->description);
|
||||
$this->assertEquals(true, $result->visible);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test we can list and count competencies with read permissions.
|
||||
*/
|
||||
public function test_list_and_count_competencies_with_read_permissions() {
|
||||
$this->setUser($this->creator);
|
||||
$framework = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true);
|
||||
$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('shortname2', 'idnumber2', 'description2', FORMAT_HTML, true, $framework->id, 0);
|
||||
$result = external::create_competency('shortname3', 'idnumber3', 'description3', FORMAT_HTML, true, $framework->id, 0);
|
||||
|
||||
$this->setUser($this->user);
|
||||
|
||||
$result = external::count_competencies(array());
|
||||
$result = external_api::clean_returnvalue(external::count_competencies_returns(), $result);
|
||||
|
||||
$this->assertEquals($result, 3);
|
||||
|
||||
$result = external::list_competencies(array(), 'shortname', 'ASC', 0, 10);
|
||||
$result = external_api::clean_returnvalue(external::list_competencies_returns(), $result);
|
||||
|
||||
$this->assertEquals(count($result), 3);
|
||||
$result = (object) $result[0];
|
||||
|
||||
$this->assertGreaterThan(0, $result->timecreated);
|
||||
$this->assertGreaterThan(0, $result->timemodified);
|
||||
$this->assertEquals($this->creator->id, $result->usermodified);
|
||||
$this->assertEquals('shortname', $result->shortname);
|
||||
$this->assertEquals('idnumber', $result->idnumber);
|
||||
$this->assertEquals('description', $result->description);
|
||||
$this->assertEquals(true, $result->visible);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test we can search for competencies.
|
||||
*/
|
||||
public function test_search_competencies_with_read_permissions() {
|
||||
$this->setUser($this->creator);
|
||||
$framework = external::create_competency_framework('shortname', 'idnumber', 'description', FORMAT_HTML, true);
|
||||
$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('shortname2', 'idnumber2', 'description2', FORMAT_HTML, true, $framework->id, 0);
|
||||
$result = external::create_competency('shortname3', 'idnumber3', 'description3', FORMAT_HTML, true, $framework->id, 0);
|
||||
|
||||
$this->setUser($this->user);
|
||||
|
||||
$result = external::search_competencies('short', $framework->id);
|
||||
$result = external_api::clean_returnvalue(external::search_competencies_returns(), $result);
|
||||
|
||||
$this->assertEquals(count($result), 3);
|
||||
$result = (object) $result[0];
|
||||
|
||||
$this->assertGreaterThan(0, $result->timecreated);
|
||||
$this->assertGreaterThan(0, $result->timemodified);
|
||||
$this->assertEquals($this->creator->id, $result->usermodified);
|
||||
$this->assertEquals('shortname', $result->shortname);
|
||||
$this->assertEquals('idnumber', $result->idnumber);
|
||||
$this->assertEquals('description', $result->description);
|
||||
$this->assertEquals(true, $result->visible);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* Plugin version info
|
||||
*
|
||||
* @package tool_lp
|
||||
* @copyright 2015 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2015021623; // The current plugin version (Date: YYYYMMDDXX).
|
||||
$plugin->requires = 2014110400; // Requires this Moodle version.
|
||||
$plugin->component = 'tool_lp'; // Full name of the plugin (used for diagnostics).
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* Wrapper for the YUI M.core.notification class. Allows us to
|
||||
* use the YUI version in AMD code until it is replaced.
|
||||
*
|
||||
* @module core/dialogue
|
||||
* @package core
|
||||
* @copyright 2015 Damyon Wiese <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
define(['core/yui'], function(Y) {
|
||||
|
||||
// Private variables and functions.
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param {string} title Title for the window.
|
||||
* @param {string} content The content for the window.
|
||||
* @param {function} afterShow Callback executed after the window is opened.
|
||||
*/
|
||||
var dialogue = function(title, content, afterShow) {
|
||||
this.yuiDialogue = null;
|
||||
var parent = this;
|
||||
|
||||
Y.use('moodle-core-notification', function () {
|
||||
|
||||
parent.yuiDialogue = new M.core.dialogue({
|
||||
headerContent: title,
|
||||
bodyContent: content,
|
||||
draggable: true,
|
||||
visible: false,
|
||||
center: true,
|
||||
modal: true
|
||||
});
|
||||
|
||||
parent.yuiDialogue.after('visibleChange', function(e) {
|
||||
if (e.newVal) {
|
||||
afterShow(parent);
|
||||
}
|
||||
});
|
||||
|
||||
parent.yuiDialogue.show();
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Close this window.
|
||||
*/
|
||||
dialogue.prototype.close = function() {
|
||||
this.yuiDialogue.hide();
|
||||
this.yuiDialogue.destroy();
|
||||
};
|
||||
|
||||
/**
|
||||
* Get content.
|
||||
*/
|
||||
dialogue.prototype.getContent = function() {
|
||||
return this.yuiDialogue.bodyNode.getDOMNode();
|
||||
};
|
||||
|
||||
return /** @alias module:core/dialogue */ dialogue;
|
||||
});
|
||||
+1
-1
@@ -70,7 +70,7 @@ define(['core/config'], function(config) {
|
||||
}
|
||||
|
||||
// Fix admin urls.
|
||||
if (config.admin !== 'admin') {
|
||||
if (typeof config.admin != "undefined" && config.admin !== 'admin') {
|
||||
relativePath = relativePath.replace(/^\/admin\//, '/' + config.admin + '/');
|
||||
}
|
||||
return config.wwwroot + relativePath;
|
||||
|
||||
Reference in New Issue
Block a user