Differences Between: [Versions 310 and 402] [Versions 311 and 402] [Versions 39 and 402] [Versions 400 and 402] [Versions 401 and 402]
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 /** @var bool true if the user has this capability. Otherwise false. */ 72 protected bool $canmanagetemplatecompetencies = false; 73 74 /** 75 * Construct this renderable. 76 * 77 * @param template $template The learning plan template. 78 * @param context $pagecontext The page context. 79 */ 80 public function __construct(template $template, context $pagecontext) { 81 $this->pagecontext = $pagecontext; 82 $this->template = $template; 83 $this->templatestatistics = new template_statistics($template->get('id')); 84 $this->competencies = api::list_competencies_in_template($template); 85 $this->canmanagecompetencyframeworks = has_capability('moodle/competency:competencymanage', $this->pagecontext); 86 $this->canmanagetemplatecompetencies = has_capability('moodle/competency:templatemanage', $this->pagecontext); 87 $this->manageurl = new moodle_url('/admin/tool/lp/competencyframeworks.php', 88 array('pagecontextid' => $this->pagecontext->id)); 89 } 90 91 /** 92 * Export this data so it can be used as the context for a mustache template. 93 * 94 * @param \renderer_base $output 95 * @return stdClass 96 */ 97 public function export_for_template(renderer_base $output) { 98 $data = new stdClass(); 99 $data->template = (new template_exporter($this->template))->export($output); 100 $data->pagecontextid = $this->pagecontext->id; 101 $data->competencies = array(); 102 $helper = new performance_helper(); 103 foreach ($this->competencies as $competency) { 104 $context = $helper->get_context_from_competency($competency); 105 $framework = $helper->get_framework_from_competency($competency); 106 107 $courses = api::list_courses_using_competency($competency->get('id')); 108 $relatedcompetencies = api::list_related_competencies($competency->get('id')); 109 110 $related = array( 111 'competency' => $competency, 112 'linkedcourses' => $courses, 113 'context' => $context, 114 'relatedcompetencies' => $relatedcompetencies, 115 'framework' => $framework 116 ); 117 $exporter = new competency_summary_exporter(null, $related); 118 $record = $exporter->export($output); 119 120 array_push($data->competencies, $record); 121 } 122 123 $data->pluginbaseurl = (new moodle_url('/admin/tool/lp'))->out(false); 124 $data->canmanagecompetencyframeworks = $this->canmanagecompetencyframeworks; 125 $data->canmanagetemplatecompetencies = $this->canmanagetemplatecompetencies; 126 $data->manageurl = $this->manageurl->out(true); 127 $exporter = new template_statistics_exporter($this->templatestatistics); 128 $data->statistics = $exporter->export($output); 129 $data->showcompetencylinks = true; 130 131 return $data; 132 } 133 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body