[ 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 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 tool_lp\external\competency_summary_exporter; 38 use tool_lp\external\template_statistics_exporter; 39 use tool_lp\template_statistics; 40 41 /** 42 * Class containing data for learning plan template competencies page 43 * 44 * @copyright 2015 Damyon Wiese 45 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 46 */ 47 class template_competencies_page implements renderable, templatable { 48 49 /** @var template $template Template for this page. */ 50 protected $template = null; 51 52 /** @var \core_competency\competency[] $competencies List of competencies. */ 53 protected $competencies = array(); 54 55 /** @var bool $canmanagecompetencyframeworks Can the current user manage competency frameworks. */ 56 protected $canmanagecompetencyframeworks = false; 57 58 /** @var bool $canmanagecoursecompetencies Can the current user manage course competency frameworks.. */ 59 protected $canmanagecoursecompetencies = false; 60 61 /** @var string $manageurl manage url. */ 62 protected $manageurl = null; 63 64 /** @var context $pagecontext The page context. */ 65 protected $pagecontext = null; 66 67 /** @var template_statistics $templatestatistics The generated summary statistics for this template. */ 68 protected $templatestatistics = null; 69 70 /** 71 * Construct this renderable. 72 * 73 * @param template $template The learning plan template. 74 * @param context $pagecontext The page context. 75 */ 76 public function __construct(template $template, context $pagecontext) { 77 $this->pagecontext = $pagecontext; 78 $this->template = $template; 79 $this->templatestatistics = new template_statistics($template->get_id()); 80 $this->competencies = api::list_competencies_in_template($template); 81 $this->canmanagecompetencyframeworks = has_capability('moodle/competency:competencymanage', $this->pagecontext); 82 $this->canmanagetemplatecompetencies = has_capability('moodle/competency:templatemanage', $this->pagecontext); 83 $this->manageurl = new moodle_url('/admin/tool/lp/competencyframeworks.php', 84 array('pagecontextid' => $this->pagecontext->id)); 85 } 86 87 /** 88 * Export this data so it can be used as the context for a mustache template. 89 * 90 * @param \renderer_base $output 91 * @return stdClass 92 */ 93 public function export_for_template(renderer_base $output) { 94 $data = new stdClass(); 95 $data->template = (new template_exporter($this->template))->export($output); 96 $data->pagecontextid = $this->pagecontext->id; 97 $data->competencies = array(); 98 $contextcache = array(); 99 $frameworkcache = array(); 100 foreach ($this->competencies as $competency) { 101 if (!isset($contextcache[$competency->get_competencyframeworkid()])) { 102 $contextcache[$competency->get_competencyframeworkid()] = $competency->get_context(); 103 } 104 $context = $contextcache[$competency->get_competencyframeworkid()]; 105 if (!isset($frameworkcache[$competency->get_competencyframeworkid()])) { 106 $frameworkcache[$competency->get_competencyframeworkid()] = $competency->get_framework(); 107 } 108 $framework = $frameworkcache[$competency->get_competencyframeworkid()]; 109 110 $courses = api::list_courses_using_competency($competency->get_id()); 111 $relatedcompetencies = api::list_related_competencies($competency->get_id()); 112 113 $related = array( 114 'competency' => $competency, 115 'linkedcourses' => $courses, 116 'context' => $context, 117 'relatedcompetencies' => $relatedcompetencies, 118 'framework' => $framework 119 ); 120 $exporter = new competency_summary_exporter(null, $related); 121 $record = $exporter->export($output); 122 123 array_push($data->competencies, $record); 124 } 125 126 $data->pluginbaseurl = (new moodle_url('/admin/tool/lp'))->out(false); 127 $data->canmanagecompetencyframeworks = $this->canmanagecompetencyframeworks; 128 $data->canmanagetemplatecompetencies = $this->canmanagetemplatecompetencies; 129 $data->manageurl = $this->manageurl->out(true); 130 $exporter = new template_statistics_exporter($this->templatestatistics); 131 $data->statistics = $exporter->export($output); 132 $data->showcompetencylinks = true; 133 134 return $data; 135 } 136 }
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 |