+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class competency_plan_navigation implements renderable, templatable {
+
+ /** @var userid */
+ protected $userid;
+
+ /** @var competencyid */
+ protected $competencyid;
+
+ /** @var planid */
+ protected $planid;
+
+ /** @var baseurl */
+ protected $baseurl;
+
+ /**
+ * Construct.
+ *
+ * @param int $userid
+ * @param int $competencyid
+ * @param int $planid
+ * @param string $baseurl
+ */
+ public function __construct($userid, $competencyid, $planid, $baseurl) {
+ $this->userid = $userid;
+ $this->competencyid = $competencyid;
+ $this->planid = $planid;
+ $this->baseurl = $baseurl;
+ }
+
+ /**
+ * Export the data.
+ *
+ * @param renderer_base $output
+ * @return stdClass
+ */
+ public function export_for_template(renderer_base $output) {
+
+ $data = new stdClass();
+ $data->userid = $this->userid;
+ $data->competencyid = $this->competencyid;
+ $data->planid = $this->planid;
+ $data->baseurl = $this->baseurl;
+
+ $plancompetencies = \core_competency\api::list_plan_competencies($data->planid);
+ $data->competencies = array();
+ $contextcache = array();
+ foreach ($plancompetencies as $plancompetency) {
+ $frameworkid = $plancompetency->competency->get_competencyframeworkid();
+ if (!isset($contextcache[$frameworkid])) {
+ $contextcache[$frameworkid] = $plancompetency->competency->get_context();
+ }
+ $context = $contextcache[$frameworkid];
+ $exporter = new competency_exporter($plancompetency->competency, array('context' => $context));
+ $competency = $exporter->export($output);
+ if ($competency->id == $this->competencyid) {
+ $competency->selected = true;
+ }
+ $data->competencies[] = $competency;
+ }
+ $data->hascompetencies = count($data->competencies);
+ return $data;
+ }
+}
diff --git a/admin/tool/lp/classes/output/renderer.php b/admin/tool/lp/classes/output/renderer.php
index f2c68c0aeaf..ca45e2980f2 100644
--- a/admin/tool/lp/classes/output/renderer.php
+++ b/admin/tool/lp/classes/output/renderer.php
@@ -206,6 +206,17 @@ class renderer extends plugin_renderer_base {
return parent::render_from_template('tool_lp/user_competency_course_navigation', $data);
}
+ /**
+ * Defer to template.
+ *
+ * @param competency_plan_navigation $nav
+ * @return string
+ */
+ public function render_competency_plan_navigation(competency_plan_navigation $nav) {
+ $data = $nav->export_for_template($this);
+ return parent::render_from_template('tool_lp/competency_plan_navigation', $data);
+ }
+
/**
* Defer to template.
*
diff --git a/admin/tool/lp/templates/competency_plan_navigation.mustache b/admin/tool/lp/templates/competency_plan_navigation.mustache
new file mode 100644
index 00000000000..53aa5d30351
--- /dev/null
+++ b/admin/tool/lp/templates/competency_plan_navigation.mustache
@@ -0,0 +1,22 @@
+
+{{#hascompetencies}}
+
+
+
+
+{{/hascompetencies}}
+
+
+{{#js}}
+require(['core/form-autocomplete', 'tool_lp/competency_plan_navigation'], function(autocomplete, nav) {
+ (new nav('#competency-nav-{{uniqid}}', '{{baseurl}}', {{userid}}, {{competencyid}}, {{planid}}));
+{{#hascompetencies}}
+ autocomplete.enhance('#competency-nav-{{uniqid}}', false, false, '{{#str}}jumptocompetency, tool_lp{{/str}}');
+{{/hascompetencies}}
+
+});
+{{/js}}
diff --git a/admin/tool/lp/templates/plan_page.mustache b/admin/tool/lp/templates/plan_page.mustache
index 1b66ee3f022..2039a21bcf4 100644
--- a/admin/tool/lp/templates/plan_page.mustache
+++ b/admin/tool/lp/templates/plan_page.mustache
@@ -126,7 +126,7 @@
{{#plan.canbeedited}}
{{/plan.canbeedited}}
- {{competency.shortname}}
+ {{competency.shortname}}
{{competency.idnumber}}
{{#comppath}}
@@ -178,10 +178,11 @@
{{#js}}
-require(['tool_lp/competencies', 'tool_lp/planactions', 'tool_lp/user_competency_workflow'], function(mod, actionsMod, UserCompWorkflow) {
+require(['tool_lp/competencies', 'tool_lp/planactions', 'tool_lp/user_competency_workflow', 'tool_lp/user_competency_plan_popup'], function(mod, actionsMod, UserCompWorkflow, Popup) {
var planActions = new actionsMod('plan');
(new mod({{plan.id}}, 'plan', {{contextid}}));
+ (new Popup('[data-region=plan-page]', '[data-usercompetency=true]', {{plan.id}}));
planActions.registerEvents();
var ucw = new UserCompWorkflow();
diff --git a/admin/tool/lp/user_competency_in_plan.php b/admin/tool/lp/user_competency_in_plan.php
index 1a1cd28de8a..3a48a475ffb 100644
--- a/admin/tool/lp/user_competency_in_plan.php
+++ b/admin/tool/lp/user_competency_in_plan.php
@@ -46,7 +46,11 @@ list($title, $subtitle) = \tool_lp\page_helper::setup_for_plan($userid, $url, $p
$output = $PAGE->get_renderer('tool_lp');
echo $output->header();
echo $output->heading($title);
+// User competency plan navigation.
+$baseurl = new moodle_url('/admin/tool/lp/user_competency_in_plan.php');
+$nav = new \tool_lp\output\competency_plan_navigation($userid, $competencyid, $planid, $baseurl);
+echo $output->render($nav);
$page = new \tool_lp\output\user_competency_summary_in_plan($competencyid, $planid);
echo $output->render($page);
// Trigger the viewed event.