[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
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 for exporting competency_path data. 19 * 20 * @package tool_lp 21 * @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca> 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 namespace tool_lp\external; 25 defined('MOODLE_INTERNAL') || die(); 26 27 use renderer_base; 28 use moodle_url; 29 30 /** 31 * Class for exporting competency_path data. 32 * 33 * @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca> 34 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 35 */ 36 class competency_path_exporter extends \core_competency\external\exporter { 37 38 /** 39 * Constructor. 40 * 41 * @param array $related - related objects. 42 */ 43 public function __construct($related) { 44 parent::__construct([], $related); 45 } 46 47 /** 48 * Return the list of properties. 49 * 50 * @return array 51 */ 52 protected static function define_related() { 53 return [ 54 'ancestors' => 'core_competency\\competency[]', 55 'framework' => 'core_competency\\competency_framework', 56 'context' => 'context' 57 ]; 58 } 59 60 /** 61 * Return the list of additional properties used only for display. 62 * 63 * @return array - Keys with their types. 64 */ 65 protected static function define_other_properties() { 66 return [ 67 'ancestors' => [ 68 'type' => path_node_exporter::read_properties_definition(), 69 'multiple' => true, 70 ], 71 'framework' => [ 72 'type' => path_node_exporter::read_properties_definition() 73 ], 74 'pluginbaseurl' => [ 75 'type' => PARAM_TEXT 76 ], 77 'pagecontextid' => [ 78 'type' => PARAM_INT 79 ] 80 ]; 81 } 82 83 /** 84 * Get the additional values to inject while exporting. 85 * 86 * @param renderer_base $output The renderer. 87 * @return array Keys are the property names, values are their values. 88 */ 89 protected function get_other_values(renderer_base $output) { 90 $result = new \stdClass(); 91 $ancestors = []; 92 $nodescount = count($this->related['ancestors']); 93 $i = 1; 94 foreach ($this->related['ancestors'] as $competency) { 95 $exporter = new path_node_exporter([ 96 'id' => $competency->get_id(), 97 'name' => $competency->get_idnumber(), 98 'position' => $i, 99 'first' => $i == 1, 100 'last' => $i == $nodescount 101 ], [ 102 'context' => $this->related['context'], 103 ] 104 ); 105 $ancestors[] = $exporter->export($output); 106 $i++; 107 } 108 $result->ancestors = $ancestors; 109 $exporter = new path_node_exporter([ 110 'id' => $this->related['framework']->get_id(), 111 'name' => $this->related['framework']->get_shortname(), 112 'first' => 0, 113 'last' => 0, 114 'position' => -1 115 ], [ 116 'context' => $this->related['context'] 117 ] 118 ); 119 $result->framework = $exporter->export($output); 120 $result->pluginbaseurl = (new moodle_url('/admin/tool/lp'))->out(true); 121 $result->pagecontextid = $this->related['context']->id; 122 return (array) $result; 123 } 124 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |