Differences Between: [Versions 311 and 402] [Versions 311 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 a competency. 19 * 20 * @package tool_lp 21 * @copyright 2015 David Monllao 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 moodle_url; 32 use core_competency\api; 33 use core_competency\external\competency_exporter; 34 35 /** 36 * Class containing data for related competencies. 37 * 38 * @package tool_lp 39 * @copyright 2015 David Monllao 40 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 41 */ 42 class related_competencies implements renderable, templatable { 43 44 /** @var array Related competencies. */ 45 protected $relatedcompetencies = null; 46 47 /** 48 * Construct this renderable. 49 * 50 * @param int $competencyid 51 */ 52 public function __construct($competencyid) { 53 $this->competency = api::read_competency($competencyid); 54 $this->context = $this->competency->get_context(); 55 $this->relatedcompetencies = api::list_related_competencies($competencyid); 56 } 57 58 /** 59 * Export this data so it can be used as the context for a mustache template. 60 * 61 * @param renderer_base $output 62 * @return stdClass 63 */ 64 public function export_for_template(renderer_base $output) { 65 $data = new stdClass(); 66 $data->relatedcompetencies = array(); 67 if ($this->relatedcompetencies) { 68 foreach ($this->relatedcompetencies as $competency) { 69 $exporter = new competency_exporter($competency, array('context' => $this->context)); 70 $record = $exporter->export($output); 71 $data->relatedcompetencies[] = $record; 72 } 73 } 74 75 // We checked the user permissions in the constructor. 76 $data->showdeleterelatedaction = true; 77 78 return $data; 79 } 80 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body