[ 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 course competency 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 course competency statistics summary. 33 * 34 * @copyright 2015 Damyon Wiese 35 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 36 */ 37 class course_competency_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 'proficientcompetencycount' => array( 45 'type' => PARAM_INT, 46 ), 47 ); 48 } 49 50 public static function define_other_properties() { 51 return array( 52 'proficientcompetencypercentage' => array( 53 'type' => PARAM_FLOAT 54 ), 55 'proficientcompetencypercentageformatted' => array( 56 'type' => PARAM_RAW 57 ), 58 'leastproficient' => array( 59 'type' => competency_exporter::read_properties_definition(), 60 'multiple' => true 61 ), 62 'leastproficientcount' => array( 63 'type' => PARAM_INT 64 ), 65 'canbegradedincourse' => array( 66 'type' => PARAM_BOOL 67 ), 68 'canmanagecoursecompetencies' => array( 69 'type' => PARAM_BOOL 70 ), 71 ); 72 } 73 74 protected static function define_related() { 75 return array('context' => 'context'); 76 } 77 78 protected function get_other_values(renderer_base $output) { 79 $proficientcompetencypercentage = 0; 80 $proficientcompetencypercentageformatted = ''; 81 if ($this->data->competencycount > 0) { 82 $proficientcompetencypercentage = ((float) $this->data->proficientcompetencycount 83 / (float) $this->data->competencycount) * 100.0; 84 $proficientcompetencypercentageformatted = format_float($proficientcompetencypercentage); 85 } 86 $competencies = array(); 87 $contextcache = array(); 88 foreach ($this->data->leastproficientcompetencies as $competency) { 89 if (!isset($contextcache[$competency->get_competencyframeworkid()])) { 90 $contextcache[$competency->get_competencyframeworkid()] = $competency->get_context(); 91 } 92 $context = $contextcache[$competency->get_competencyframeworkid()]; 93 $exporter = new competency_exporter($competency, array('context' => $context)); 94 $competencies[] = $exporter->export($output); 95 } 96 return array( 97 'proficientcompetencypercentage' => $proficientcompetencypercentage, 98 'proficientcompetencypercentageformatted' => $proficientcompetencypercentageformatted, 99 'leastproficient' => $competencies, 100 'leastproficientcount' => count($competencies), 101 'canbegradedincourse' => has_capability('moodle/competency:coursecompetencygradable', $this->related['context']), 102 'canmanagecoursecompetencies' => has_capability('moodle/competency:coursecompetencymanage', $this->related['context']) 103 ); 104 } 105 }
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 |