See Release Notes
Long Term Support Release
Differences Between: [Versions 401 and 402] [Versions 401 and 403]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * Class containing data for learning plan template competencies page 19 * 20 * @package tool_lp 21 * @copyright 2015 Damyon Wiese 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 namespace tool_lp\output; 25 defined('MOODLE_INTERNAL') || die(); 26 27 use renderable; 28 use templatable; 29 use renderer_base; 30 use stdClass; 31 use context; 32 use context_system; 33 use moodle_url; 34 use core_competency\external\template_exporter; 35 use core_competency\template; 36 use core_competency\api; 37 use core_competency\external\performance_helper; 38 use tool_lp\external\competency_summary_exporter; 39 use tool_lp\external\template_statistics_exporter; 40 use tool_lp\template_statistics; 41 42 /** 43 * Class containing data for learning plan template competencies page 44 * 45 * @copyright 2015 Damyon Wiese 46 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 47 */ 48 class template_competencies_page implements renderable, templatable { 49 50 /** @var template $template Template for this page. */ 51 protected $template = null; 52 53 /** @var \core_competency\competency[] $competencies List of competencies. */ 54 protected $competencies = array(); 55 56 /** @var bool $canmanagecompetencyframeworks Can the current user manage competency frameworks. */ 57 protected $canmanagecompetencyframeworks = false; 58 59 /** @var bool $canmanagecoursecompetencies Can the current user manage course competency frameworks.. */ 60 protected $canmanagecoursecompetencies = false; 61 62 /** @var string $manageurl manage url. */ 63 protected $manageurl = null; 64 65 /** @var context $pagecontext The page context. */ 66 protected $pagecontext = null; 67 68 /** @var template_statistics $templatestatistics The generated summary statistics for this template. */ 69 protected $templatestatistics = null; 70 71 /** 72 * Construct this renderable. 73 * 74 * @param template $template The learning plan template. 75 * @param context $pagecontext The page context. 76 */ 77 public function __construct(template $template, context $pagecontext) { 78 $this->pagecontext = $pagecontext; 79 $this->template = $template; 80 $this->templatestatistics = new template_statistics($template->get('id')); 81 $this->competencies = api::list_competencies_in_template($template); 82 $this->canmanagecompetencyframeworks = has_capability('moodle/competency:competencymanage', $this->pagecontext); 83 $this->canmanagetemplatecompetencies = has_capability('moodle/competency:templatemanage', $this->pagecontext); 84 $this->manageurl = new moodle_url('/admin/tool/lp/competencyframeworks.php', 85 array('pagecontextid' => $this->pagecontext->id)); 86 } 87 88 /** 89 * Export this data so it can be used as the context for a mustache template. 90 * 91 * @param \renderer_base $output 92 * @return stdClass 93 */ 94 public function export_for_template(renderer_base $output) { 95 $data = new stdClass(); 96 $data->template = (new template_exporter($this->template))->export($output); 97 $data->pagecontextid = $this->pagecontext->id; 98 $data->competencies = array(); 99 $helper = new performance_helper(); 100 foreach ($this->competencies as $competency) { 101 $context = $helper->get_context_from_competency($competency); 102 $framework = $helper->get_framework_from_competency($competency); 103 104 $courses = api::list_courses_using_competency($competency->get('id')); 105 $relatedcompetencies = api::list_related_competencies($competency->get('id')); 106 107 $related = array( 108 'competency' => $competency, 109 'linkedcourses' => $courses, 110 'context' => $context, 111 'relatedcompetencies' => $relatedcompetencies, 112 'framework' => $framework 113 ); 114 $exporter = new competency_summary_exporter(null, $related); 115 $record = $exporter->export($output); 116 117 array_push($data->competencies, $record); 118 } 119 120 $data->pluginbaseurl = (new moodle_url('/admin/tool/lp'))->out(false); 121 $data->canmanagecompetencyframeworks = $this->canmanagecompetencyframeworks; 122 $data->canmanagetemplatecompetencies = $this->canmanagetemplatecompetencies; 123 $data->manageurl = $this->manageurl->out(true); 124 $exporter = new template_statistics_exporter($this->templatestatistics); 125 $data->statistics = $exporter->export($output); 126 $data->showcompetencylinks = true; 127 128 return $data; 129 } 130 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body