[ 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 user evidence with all competencies. 19 * 20 * @package tool_lp 21 * @copyright 2016 Serge Gauthier - <serge.gauthier.2@umontreal.ca> 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 moodle_url; 28 use renderer_base; 29 use core_competency\external\stored_file_exporter; 30 31 /** 32 * Class for exporting user evidence with all competencies. 33 * 34 * @copyright 2016 Serge Gauthier - <serge.gauthier.2@umontreal.ca> 35 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 36 */ 37 class user_evidence_summary_exporter extends \core_competency\external\persistent_exporter { 38 39 protected static function define_class() { 40 return 'core_competency\\user_evidence'; 41 } 42 43 protected static function define_other_properties() { 44 return array( 45 'canmanage' => array( 46 'type' => PARAM_BOOL 47 ), 48 'filecount' => array( 49 'type' => PARAM_INT 50 ), 51 'files' => array( 52 'type' => stored_file_exporter::read_properties_definition(), 53 'multiple' => true 54 ), 55 'hasurlorfiles' => array( 56 'type' => PARAM_BOOL 57 ), 58 'urlshort' => array( 59 'type' => PARAM_TEXT 60 ), 61 'competencycount' => array( 62 'type' => PARAM_INT 63 ), 64 'usercompetencies' => array( 65 'type' => user_evidence_competency_summary_exporter::read_properties_definition(), 66 'optional' => true, 67 'multiple' => true 68 ), 69 'userhasplan' => array( 70 'type' => PARAM_BOOL 71 ), 72 ); 73 } 74 75 protected function get_other_values(renderer_base $output) { 76 $urlshort = ''; 77 $url = $this->persistent->get_url(); 78 if (!empty($url)) { 79 $murl = new moodle_url($url); 80 $shorturl = preg_replace('@^https?://(www\.)?@', '', $murl->out(false)); 81 $urlshort = shorten_text($shorturl, 30, true); 82 } 83 84 $files = array(); 85 $storedfiles = $this->persistent->get_files(); 86 if (!empty($storedfiles)) { 87 foreach ($storedfiles as $storedfile) { 88 $fileexporter = new stored_file_exporter($storedfile, array('context' => $this->related['context'])); 89 $files[] = $fileexporter->export($output); 90 } 91 } 92 93 $userevidencecompetencies = array(); 94 $frameworks = array(); 95 $scales = array(); 96 $usercompetencies = $this->persistent->get_user_competencies(); 97 foreach ($usercompetencies as $usercompetency) { 98 $competency = $usercompetency->get_competency(); 99 100 // Get the framework. 101 if (!isset($frameworks[$competency->get_competencyframeworkid()])) { 102 $frameworks[$competency->get_competencyframeworkid()] = $competency->get_framework(); 103 } 104 $framework = $frameworks[$competency->get_competencyframeworkid()]; 105 106 // Get the scale. 107 $scaleid = $competency->get_scaleid(); 108 if ($scaleid === null) { 109 $scaleid = $framework->get_scaleid(); 110 } 111 if (!isset($scales[$framework->get_scaleid()])) { 112 $scales[$framework->get_scaleid()] = $framework->get_scale(); 113 } 114 $scale = $scales[$framework->get_scaleid()]; 115 116 $related = array('competency' => $competency, 117 'usercompetency' => $usercompetency, 118 'scale' => $scale, 119 'context' => $framework->get_context()); 120 121 $userevidencecompetencysummaryexporter = new user_evidence_competency_summary_exporter(null, $related); 122 123 $userevidencecompetencies[] = $userevidencecompetencysummaryexporter->export($output); 124 } 125 126 $values = array( 127 'canmanage' => $this->persistent->can_manage(), 128 'filecount' => count($files), 129 'files' => $files, 130 'userhasplan' => $this->persistent->user_has_plan(), 131 'hasurlorfiles' => !empty($files) || !empty($url), 132 'urlshort' => $urlshort, 133 'competencycount' => count($userevidencecompetencies), 134 'usercompetencies' => $userevidencecompetencies 135 ); 136 137 return $values; 138 } 139 140 }
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 |