[ 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 evidence data. 19 * 20 * @package core_competency 21 * @copyright 2015 Damyon Wiese 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 namespace core_competency\external; 25 26 use renderer_base; 27 use core_competency\evidence; 28 use core_competency\user_competency; 29 30 /** 31 * Class for exporting evidence data. 32 * 33 * @copyright 2015 Damyon Wiese 34 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 35 */ 36 class evidence_exporter extends persistent_exporter { 37 38 protected static function define_related() { 39 return array( 40 'actionuser' => 'stdClass?', 41 'scale' => 'grade_scale', 42 'usercompetency' => 'core_competency\\user_competency?', 43 'usercompetencyplan' => 'core_competency\\user_competency_plan?', 44 ); 45 } 46 47 protected static function define_class() { 48 return 'core_competency\\evidence'; 49 } 50 51 protected function get_other_values(renderer_base $output) { 52 $other = array(); 53 54 if (!empty($this->related['actionuser'])) { 55 $exporter = new user_summary_exporter($this->related['actionuser']); 56 $actionuser = $exporter->export($output); 57 $other['actionuser'] = $actionuser; 58 } 59 60 $other['description'] = $this->persistent->get_description(); 61 62 $other['userdate'] = userdate($this->persistent->get_timecreated()); 63 64 if ($this->persistent->get_grade() === null) { 65 $gradename = '-'; 66 } else { 67 $gradename = $this->related['scale']->scale_items[$this->persistent->get_grade() - 1]; 68 } 69 $other['gradename'] = $gradename; 70 71 // Try to guess the user from the user competency. 72 $userid = null; 73 if ($this->related['usercompetency']) { 74 $userid = $this->related['usercompetency']->get_userid(); 75 } else if ($this->related['usercompetencyplan']) { 76 $userid = $this->related['usercompetencyplan']->get_userid(); 77 } else { 78 $uc = user_competency::get_record(['id' => $this->persistent->get_usercompetencyid()]); 79 $userid = $uc->get_userid(); 80 } 81 $other['candelete'] = evidence::can_delete_user($userid); 82 83 return $other; 84 } 85 86 public static function define_other_properties() { 87 return array( 88 'actionuser' => array( 89 'type' => user_summary_exporter::read_properties_definition(), 90 'optional' => true 91 ), 92 'description' => array( 93 'type' => PARAM_TEXT, 94 ), 95 'gradename' => array( 96 'type' => PARAM_TEXT, 97 ), 98 'userdate' => array( 99 'type' => PARAM_TEXT 100 ), 101 'candelete' => array( 102 'type' => PARAM_BOOL 103 ) 104 ); 105 } 106 }
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 |