[ 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 a template statistics summary. 19 * 20 * @package tool_lp 21 * @copyright 2016 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 renderer_base; 28 use moodle_url; 29 use core_competency\external\competency_exporter; 30 31 /** 32 * Class for exporting a cohort summary from an stdClass. 33 * 34 * @copyright 2015 Damyon Wiese 35 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 36 */ 37 class template_statistics_exporter extends \core_competency\external\exporter { 38 39 public static function define_properties() { 40 return array( 41 'competencycount' => array( 42 'type' => PARAM_INT, 43 ), 44 'unlinkedcompetencycount' => array( 45 'type' => PARAM_INT, 46 ), 47 'plancount' => array( 48 'type' => PARAM_INT, 49 ), 50 'completedplancount' => array( 51 'type' => PARAM_INT, 52 ), 53 'usercompetencyplancount' => array( 54 'type' => PARAM_INT, 55 ), 56 'proficientusercompetencyplancount' => array( 57 'type' => PARAM_INT, 58 ) 59 ); 60 } 61 62 public static function define_other_properties() { 63 return array( 64 'linkedcompetencypercentage' => array( 65 'type' => PARAM_FLOAT 66 ), 67 'linkedcompetencypercentageformatted' => array( 68 'type' => PARAM_RAW 69 ), 70 'linkedcompetencycount' => array( 71 'type' => PARAM_INT 72 ), 73 'completedplanpercentage' => array( 74 'type' => PARAM_FLOAT 75 ), 76 'completedplanpercentageformatted' => array( 77 'type' => PARAM_RAW 78 ), 79 'proficientusercompetencyplanpercentage' => array( 80 'type' => PARAM_FLOAT 81 ), 82 'proficientusercompetencyplanpercentageformatted' => array( 83 'type' => PARAM_RAW 84 ), 85 'leastproficient' => array( 86 'type' => competency_exporter::read_properties_definition(), 87 'multiple' => true 88 ), 89 'leastproficientcount' => array( 90 'type' => PARAM_INT 91 ), 92 ); 93 } 94 95 protected function get_other_values(renderer_base $output) { 96 $linkedcompetencycount = $this->data->competencycount - $this->data->unlinkedcompetencycount; 97 if ($linkedcompetencycount < 0) { 98 // Should never happen. 99 $linkedcompetencycount = 0; 100 } 101 $linkedcompetencypercentage = 0; 102 $linkedcompetencypercentageformatted = ''; 103 if ($this->data->competencycount > 0) { 104 $linkedcompetencypercentage = ((float) $linkedcompetencycount / (float) $this->data->competencycount) * 100.0; 105 $linkedcompetencypercentageformatted = format_float($linkedcompetencypercentage); 106 } 107 $completedplanpercentage = 0; 108 $completedplanpercentageformatted = ''; 109 if ($this->data->plancount > 0) { 110 $completedplanpercentage = ((float) $this->data->completedplancount / (float) $this->data->plancount) * 100.0; 111 $completedplanpercentageformatted = format_float($completedplanpercentage); 112 } 113 $proficientusercompetencyplanpercentage = 0; 114 $proficientusercompetencyplanpercentageformatted = ''; 115 if ($this->data->usercompetencyplancount > 0) { 116 $proficientusercompetencyplanpercentage = ((float) $this->data->proficientusercompetencyplancount 117 / (float) $this->data->usercompetencyplancount) * 100.0; 118 $proficientusercompetencyplanpercentageformatted = format_float($proficientusercompetencyplanpercentage); 119 } 120 $competencies = array(); 121 $contextcache = array(); 122 foreach ($this->data->leastproficientcompetencies as $competency) { 123 if (!isset($contextcache[$competency->get_competencyframeworkid()])) { 124 $contextcache[$competency->get_competencyframeworkid()] = $competency->get_context(); 125 } 126 $context = $contextcache[$competency->get_competencyframeworkid()]; 127 $exporter = new competency_exporter($competency, array('context' => $context)); 128 $competencies[] = $exporter->export($output); 129 } 130 return array( 131 'linkedcompetencycount' => $linkedcompetencycount, 132 'linkedcompetencypercentage' => $linkedcompetencypercentage, 133 'linkedcompetencypercentageformatted' => $linkedcompetencypercentageformatted, 134 'completedplanpercentage' => $completedplanpercentage, 135 'completedplanpercentageformatted' => $completedplanpercentageformatted, 136 'proficientusercompetencyplanpercentage' => $proficientusercompetencyplanpercentage, 137 'proficientusercompetencyplanpercentageformatted' => $proficientusercompetencyplanpercentageformatted, 138 'leastproficient' => $competencies, 139 'leastproficientcount' => count($competencies) 140 ); 141 } 142 }
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 |