[ 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 data with the set of linked courses. 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\external; 25 defined('MOODLE_INTERNAL') || die(); 26 27 use context_course; 28 use renderer_base; 29 use stdClass; 30 use core_competency\competency_framework; 31 use core_competency\external\competency_exporter; 32 use core_competency\external\competency_framework_exporter; 33 34 /** 35 * Class for exporting competency data with additional related data. 36 * 37 * @copyright 2015 Damyon Wiese 38 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 39 */ 40 class competency_summary_exporter extends \core_competency\external\exporter { 41 42 protected static function define_related() { 43 // We cache the context so it does not need to be retrieved from the framework every time. 44 return array('context' => '\\context', 45 'competency' => '\\core_competency\\competency', 46 'framework' => '\\core_competency\\competency_framework', 47 'linkedcourses' => '\\stdClass[]', 48 'relatedcompetencies' => '\\core_competency\\competency[]'); 49 } 50 51 protected static function define_other_properties() { 52 return array( 53 'linkedcourses' => array( 54 'type' => course_summary_exporter::read_properties_definition(), 55 'multiple' => true 56 ), 57 'relatedcompetencies' => array( 58 'type' => competency_exporter::read_properties_definition(), 59 'multiple' => true 60 ), 61 'competency' => array( 62 'type' => competency_exporter::read_properties_definition() 63 ), 64 'framework' => array( 65 'type' => competency_framework_exporter::read_properties_definition() 66 ), 67 'hascourses' => array( 68 'type' => PARAM_BOOL 69 ), 70 'hasrelatedcompetencies' => array( 71 'type' => PARAM_BOOL 72 ), 73 'scaleid' => array( 74 'type' => PARAM_INT 75 ), 76 'scaleconfiguration' => array( 77 'type' => PARAM_RAW 78 ), 79 'taxonomyterm' => array( 80 'type' => PARAM_TEXT 81 ), 82 'comppath' => array( 83 'type' => competency_path_exporter::read_properties_definition(), 84 ) 85 ); 86 } 87 88 protected function get_other_values(renderer_base $output) { 89 $result = new stdClass(); 90 $context = $this->related['context']; 91 92 $courses = $this->related['linkedcourses']; 93 $linkedcourses = array(); 94 foreach ($courses as $course) { 95 $context = context_course::instance($course->id); 96 $exporter = new course_summary_exporter($course, array('context' => $context)); 97 $courseexport = $exporter->export($output); 98 array_push($linkedcourses, $courseexport); 99 } 100 $result->linkedcourses = $linkedcourses; 101 $result->hascourses = count($linkedcourses) > 0; 102 103 $relatedcompetencies = array(); 104 foreach ($this->related['relatedcompetencies'] as $competency) { 105 $exporter = new competency_exporter($competency, array('context' => $context)); 106 $competencyexport = $exporter->export($output); 107 array_push($relatedcompetencies, $competencyexport); 108 } 109 $result->relatedcompetencies = $relatedcompetencies; 110 $result->hasrelatedcompetencies = count($relatedcompetencies) > 0; 111 112 $competency = $this->related['competency']; 113 $exporter = new competency_exporter($competency, array('context' => $context)); 114 $result->competency = $exporter->export($output); 115 116 $exporter = new competency_framework_exporter($this->related['framework']); 117 $result->framework = $exporter->export($output); 118 $scaleconfiguration = $this->related['framework']->get_scaleconfiguration(); 119 $scaleid = $this->related['framework']->get_scaleid(); 120 if ($competency->get_scaleid()) { 121 $scaleconfiguration = $competency->get_scaleconfiguration(); 122 $scaleid = $competency->get_scaleid(); 123 } 124 $result->scaleconfiguration = $scaleconfiguration; 125 $result->scaleid = $scaleid; 126 127 $level = $competency->get_level(); 128 $taxonomy = $this->related['framework']->get_taxonomy($level); 129 $result->taxonomyterm = (string) (competency_framework::get_taxonomies_list()[$taxonomy]); 130 131 // Competency path. 132 $exporter = new competency_path_exporter([ 133 'ancestors' => $competency->get_ancestors(), 134 'framework' => $this->related['framework'], 135 'context' => $context 136 ]); 137 $result->comppath = $exporter->export($output); 138 139 return (array) $result; 140 } 141 }
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 |