$id = required_param('id', PARAM_INT); $pagecontextid = required_param('pagecontextid', PARAM_INT); // Reference to the context we came from. require_login(0, false); \core_competency\api::require_enabled(); $template = \core_competency\api::read_template($id); $context = $template->get_context(); $canreadtemplate = $template->can_read(); $canmanagetemplate = $template->can_manage(); $duedatereached = $template->get_duedate() > 0 && $template->get_duedate() < time(); if (!$canreadtemplate) { throw new required_capability_exception($context, 'moodle/competency:templateview', 'nopermissions', ''); } // Set up the page. $url = new moodle_url('/admin/tool/lp/template_cohorts.php', array('id' => $id, 'pagecontextid' => $pagecontextid)); list($title, $subtitle) = \tool_lp\page_helper::setup_for_template($pagecontextid, $url, $template, get_string('cohortssyncedtotemplate', 'tool_lp')); // Remove cohort. if ($canmanagetemplate && ($removecohort = optional_param('removecohort', false, PARAM_INT)) !== false && confirm_sesskey()) { \core_competency\api::delete_template_cohort($template, $removecohort); } // Capture the form submission. $form = new \tool_lp\form\template_cohorts($url->out(false), array('pagecontextid' => $pagecontextid)); if ($canmanagetemplate && ($data = $form->get_data()) && !empty($data->cohorts)) { $maxtocreate = 50; $maxreached = false; $i = 0; foreach ($data->cohorts as $cohortid) { // Create the template/cohort relationship. $relation = \core_competency\api::create_template_cohort($template, $cohortid); // Create a plan for each member if template visible, and the due date is not reached, and we didn't reach our limit yet. if ($template->get_visible() && $i < $maxtocreate && !$duedatereached) {
} else { $context = context::instance_by_id($pagecontextid); } // We check that we have the permission to edit this framework, in its own context. require_login(0, false); \core_competency\api::require_enabled(); require_capability('moodle/competency:templatemanage', $context); // We keep the original context in the URLs, so that we remain in the same context. $url = new moodle_url("/admin/tool/lp/edittemplate.php", ['id' => $id, 'pagecontextid' => $pagecontextid, 'return' => $returntype]); if (empty($id)) { $pagetitle = get_string('addnewtemplate', 'tool_lp'); list($title, $subtitle, $returnurl) = \tool_lp\page_helper::setup_for_template($pagecontextid, $url, null, $pagetitle, $returntype); } else { $template = \core_competency\api::read_template($id); $pagetitle = get_string('edittemplate', 'tool_lp'); list($title, $subtitle, $returnurl) = \tool_lp\page_helper::setup_for_template($pagecontextid, $url, $template, $pagetitle, $returntype); } $form = new \tool_lp\form\template($url->out(false), array('persistent' => $template, 'context' => $context)); if ($form->is_cancelled()) { redirect($returnurl); } $data = $form->get_data(); if ($data) { if (empty($data->id)) { $template = \core_competency\api::create_template($data); $returnurl = new moodle_url('/admin/tool/lp/templatecompetencies.php', ['templateid' => $template->get_id(), 'pagecontextid' => $pagecontextid]); $returnmsg = get_string('templatecreated', 'tool_lp'); } else { \core_competency\api::update_template($data); $returnmsg = get_string('templateupdated', 'tool_lp'); }
// 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'; $pagecontextid = required_param('pagecontextid', PARAM_INT); $context = context::instance_by_id($pagecontextid); require_login(0, false); \core_competency\api::require_enabled(); if (!\core_competency\template::can_read_context($context)) { throw new required_capability_exception($context, 'moodle/competency:templateview', 'nopermissions', ''); } $url = new moodle_url('/admin/tool/lp/learningplans.php', array('pagecontextid' => $pagecontextid)); list($title, $subtitle) = \tool_lp\page_helper::setup_for_template($pagecontextid, $url); $output = $PAGE->get_renderer('tool_lp'); echo $output->header(); echo $output->heading($title); $page = new \tool_lp\output\manage_templates_page($context); echo $output->render($page); echo $output->footer();
require __DIR__ . '/../../../config.php'; $id = required_param('id', PARAM_INT); $pagecontextid = required_param('pagecontextid', PARAM_INT); // Reference to the context we came from. require_login(0, false); \core_competency\api::require_enabled(); $template = \core_competency\api::read_template($id); $context = $template->get_context(); $canreadtemplate = $template->can_read(); $canmanagetemplate = $template->can_manage(); if (!$canreadtemplate) { throw new required_capability_exception($context, 'moodle/competency:templateview', 'nopermissions', ''); } // Set up the page. $url = new moodle_url('/admin/tool/lp/template_plans.php', array('id' => $id, 'pagecontextid' => $pagecontextid)); list($title, $subtitle) = \tool_lp\page_helper::setup_for_template($pagecontextid, $url, $template, get_string('userplans', 'core_competency')); // Capture the form submission. $form = new \tool_lp\form\template_plans($url->out(false)); if ($canmanagetemplate && ($data = $form->get_data()) && !empty($data->users)) { $i = 0; foreach ($data->users as $userid) { $result = \core_competency\api::create_plan_from_template($template->get_id(), $userid); if ($result) { $i++; } } if ($i == 0) { $notification = get_string('noplanswerecreated', 'tool_lp'); } else { if ($i == 1) { $notification = get_string('oneplanwascreated', 'tool_lp');