[ 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 * User competency plan page class. 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\output; 25 26 use renderable; 27 use renderer_base; 28 use templatable; 29 use context_course; 30 use \core_competency\external\competency_exporter; 31 use stdClass; 32 33 /** 34 * User competency plan navigation class. 35 * 36 * @package tool_lp 37 * @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca> 38 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 39 */ 40 class competency_plan_navigation implements renderable, templatable { 41 42 /** @var userid */ 43 protected $userid; 44 45 /** @var competencyid */ 46 protected $competencyid; 47 48 /** @var planid */ 49 protected $planid; 50 51 /** @var baseurl */ 52 protected $baseurl; 53 54 /** 55 * Construct. 56 * 57 * @param int $userid 58 * @param int $competencyid 59 * @param int $planid 60 * @param string $baseurl 61 */ 62 public function __construct($userid, $competencyid, $planid, $baseurl) { 63 $this->userid = $userid; 64 $this->competencyid = $competencyid; 65 $this->planid = $planid; 66 $this->baseurl = $baseurl; 67 } 68 69 /** 70 * Export the data. 71 * 72 * @param renderer_base $output 73 * @return stdClass 74 */ 75 public function export_for_template(renderer_base $output) { 76 77 $data = new stdClass(); 78 $data->userid = $this->userid; 79 $data->competencyid = $this->competencyid; 80 $data->planid = $this->planid; 81 $data->baseurl = $this->baseurl; 82 83 $plancompetencies = \core_competency\api::list_plan_competencies($data->planid); 84 $data->competencies = array(); 85 $contextcache = array(); 86 foreach ($plancompetencies as $plancompetency) { 87 $frameworkid = $plancompetency->competency->get_competencyframeworkid(); 88 if (!isset($contextcache[$frameworkid])) { 89 $contextcache[$frameworkid] = $plancompetency->competency->get_context(); 90 } 91 $context = $contextcache[$frameworkid]; 92 $exporter = new competency_exporter($plancompetency->competency, array('context' => $context)); 93 $competency = $exporter->export($output); 94 if ($competency->id == $this->competencyid) { 95 $competency->selected = true; 96 } 97 $data->competencies[] = $competency; 98 } 99 $data->hascompetencies = count($data->competencies); 100 return $data; 101 } 102 }
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 |