MDL-53472 tool_lp: Improve user navigation flow in competency frameworks
This commit is contained in:
committed by
Frederic Massart
parent
66df4d2fad
commit
a4f1b030f2
@@ -1169,7 +1169,8 @@ class external extends external_api {
|
||||
'canmanage' => new external_value(PARAM_BOOL, 'True if this user has permission to manage competency frameworks'),
|
||||
'pagecontextid' => new external_value(PARAM_INT, 'Context id for the framework'),
|
||||
'search' => new external_value(PARAM_RAW, 'Current search string'),
|
||||
'rulesmodules' => new external_value(PARAM_RAW, 'JSON encoded data for rules')
|
||||
'rulesmodules' => new external_value(PARAM_RAW, 'JSON encoded data for rules'),
|
||||
'pluginbaseurl' => new external_value(PARAM_RAW, 'Plugin base url')
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
@@ -95,6 +95,7 @@ class manage_competencies_page implements renderable, templatable {
|
||||
$data->canmanage = $this->canmanage;
|
||||
$data->search = $this->search;
|
||||
$data->pagecontextid = $this->pagecontext->id;
|
||||
$data->pluginbaseurl = (new moodle_url('/admin/tool/lp'))->out(true);
|
||||
|
||||
$rules = competency::get_available_rules();
|
||||
foreach ($rules as $type => $rule) {
|
||||
|
||||
@@ -313,4 +313,64 @@ class page_helper {
|
||||
|
||||
return array($title, $subtitle, $returnurl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set-up a framework page.
|
||||
*
|
||||
* Example:
|
||||
* list($pagetitle, $pagesubtitle, $url, $frameworksurl) = page_helper::setup_for_framework($id, $pagecontextid);
|
||||
* echo $OUTPUT->heading($pagetitle);
|
||||
* echo $OUTPUT->heading($pagesubtitle, 3);
|
||||
*
|
||||
* @param int $id The framework ID.
|
||||
* @param int $pagecontextid The page context ID.
|
||||
* @param \tool_lp\competency_framework $framework The framework.
|
||||
* @param string $returntype The desired return page.
|
||||
* @return array With the following:
|
||||
* - Page title
|
||||
* - Page sub title
|
||||
* - Page URL
|
||||
* - Page framework URL
|
||||
*/
|
||||
public static function setup_for_framework($id, $pagecontextid, $framework = null, $returntype = null) {
|
||||
global $PAGE;
|
||||
|
||||
// We keep the original context in the URLs, so that we remain in the same context.
|
||||
$url = new moodle_url("/admin/tool/lp/editcompetencyframework.php", array('id' => $id, 'pagecontextid' => $pagecontextid));
|
||||
if ($returntype) {
|
||||
$url->param('return', $returntype);
|
||||
}
|
||||
$frameworksurl = new moodle_url('/admin/tool/lp/competencyframeworks.php', array('pagecontextid' => $pagecontextid));
|
||||
|
||||
$PAGE->navigation->override_active_url($frameworksurl);
|
||||
$title = get_string('competencies', 'tool_lp');
|
||||
if (empty($id)) {
|
||||
$pagetitle = get_string('competencyframeworks', 'tool_lp');
|
||||
$pagesubtitle = get_string('addnewcompetencyframework', 'tool_lp');
|
||||
|
||||
$url->remove_params(array('id'));
|
||||
$PAGE->navbar->add($pagesubtitle, $url);
|
||||
} else {
|
||||
$pagetitle = $framework->get_shortname();
|
||||
$pagesubtitle = get_string('editcompetencyframework', 'tool_lp');
|
||||
if ($returntype == 'competencies') {
|
||||
$frameworksurl = new moodle_url('/admin/tool/lp/competencies.php', array(
|
||||
'pagecontextid' => $pagecontextid,
|
||||
'competencyframeworkid' => $id
|
||||
));
|
||||
} else {
|
||||
$frameworksurl->param('competencyframeworkid', $id);
|
||||
}
|
||||
|
||||
$PAGE->navbar->add($pagetitle, $frameworksurl);
|
||||
$PAGE->navbar->add($pagesubtitle, $url);
|
||||
}
|
||||
|
||||
$PAGE->set_context(context::instance_by_id($pagecontextid));
|
||||
$PAGE->set_pagelayout('admin');
|
||||
$PAGE->set_url($url);
|
||||
$PAGE->set_title($title);
|
||||
$PAGE->set_heading($title);
|
||||
return array($pagetitle, $pagesubtitle, $url, $frameworksurl);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,6 @@ $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, $pagecontext);
|
||||
echo $output->render($page);
|
||||
|
||||
@@ -37,6 +37,7 @@ require_capability('tool/lp:competencymanage', $context);
|
||||
|
||||
$title = get_string('competencies', 'tool_lp');
|
||||
$pagetitle = get_string('competencyframeworks', 'tool_lp');
|
||||
$pagesubtitle = get_string('listcompetencyframeworkscaption', 'tool_lp');
|
||||
|
||||
// Set up the page.
|
||||
$PAGE->set_context($context);
|
||||
@@ -46,7 +47,8 @@ $PAGE->set_title($title);
|
||||
$PAGE->set_heading($title);
|
||||
$output = $PAGE->get_renderer('tool_lp');
|
||||
echo $output->header();
|
||||
echo $output->heading($pagetitle);
|
||||
echo $output->heading($pagetitle, 2);
|
||||
echo $output->heading($pagesubtitle, 3);
|
||||
|
||||
$page = new \tool_lp\output\manage_competency_frameworks_page($context);
|
||||
echo $output->render($page);
|
||||
|
||||
@@ -26,6 +26,7 @@ require_once(__DIR__ . '/../../../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
$id = optional_param('id', 0, PARAM_INT);
|
||||
$returntype = optional_param('return', null, PARAM_TEXT);
|
||||
$pagecontextid = required_param('pagecontextid', PARAM_INT); // Reference to where we can from.
|
||||
|
||||
$framework = null;
|
||||
@@ -42,24 +43,9 @@ require_login();
|
||||
\tool_lp\api::require_enabled();
|
||||
require_capability('tool/lp:competencymanage', $context);
|
||||
|
||||
// We keep the original context in the URLs, so that we remain in the same context.
|
||||
$url = new moodle_url("/admin/tool/lp/editcompetencyframework.php", array('id' => $id, 'pagecontextid' => $pagecontextid));
|
||||
$frameworksurl = new moodle_url('/admin/tool/lp/competencyframeworks.php', array('pagecontextid' => $pagecontextid));
|
||||
|
||||
$title = get_string('competencies', 'tool_lp');
|
||||
if (empty($id)) {
|
||||
$pagetitle = get_string('addnewcompetencyframework', 'tool_lp');
|
||||
} else {
|
||||
$pagetitle = get_string('editcompetencyframework', 'tool_lp');
|
||||
}
|
||||
|
||||
// Set up the page.
|
||||
$PAGE->navigation->override_active_url($frameworksurl);
|
||||
$PAGE->set_context(context::instance_by_id($pagecontextid));
|
||||
$PAGE->set_pagelayout('admin');
|
||||
$PAGE->set_url($url);
|
||||
$PAGE->set_title($title);
|
||||
$PAGE->set_heading($title);
|
||||
// Set up the framework page.
|
||||
list($pagetitle, $pagesubtitle, $url, $frameworksurl) = tool_lp\page_helper::setup_for_framework($id,
|
||||
$pagecontextid, $framework, $returntype);
|
||||
$output = $PAGE->get_renderer('tool_lp');
|
||||
$form = new \tool_lp\form\competency_framework($url->out(false), array('context' => $context, 'persistent' => $framework));
|
||||
|
||||
@@ -84,6 +70,7 @@ if ($form->is_cancelled()) {
|
||||
}
|
||||
|
||||
echo $output->header();
|
||||
echo $output->heading($pagetitle);
|
||||
echo $output->heading($pagetitle, 2);
|
||||
echo $output->heading($pagesubtitle, 3);
|
||||
$form->display();
|
||||
echo $output->footer();
|
||||
|
||||
@@ -31,7 +31,13 @@
|
||||
* canmanage - true if this user has permission to manage the competencies
|
||||
}}
|
||||
<div data-region="managecompetencies">
|
||||
|
||||
<h2>
|
||||
{{framework.shortname}}
|
||||
{{#canmanage}}
|
||||
<a href="{{pluginbaseurl}}/editcompetencyframework.php?id={{framework.id}}&pagecontextid={{pagecontextid}}&return=competencies">{{#pix}}t/edit, core, {{#str}}editcompetencyframework, tool_lp{{/str}}{{/pix}}</a>
|
||||
{{/canmanage}}
|
||||
</h2>
|
||||
<h3>{{#str}}competencies, tool_lp{{/str}}</h3>
|
||||
<div class="row-fluid">
|
||||
<div class="span6">
|
||||
<p>
|
||||
|
||||
@@ -40,8 +40,6 @@
|
||||
{{/navigation}}
|
||||
</div>
|
||||
<table class="generaltable fullwidth managecompetencies">
|
||||
<caption>{{#str}}listcompetencyframeworkscaption, tool_lp{{/str}}
|
||||
</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">{{#str}}competencyframeworkname, tool_lp{{/str}}</th>
|
||||
|
||||
Reference in New Issue
Block a user