See Release Notes
Long Term Support Release
Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 400 and 401] [Versions 401 and 402] [Versions 401 and 403]
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 partial feedback data. 19 * 20 * @package mod_feedback 21 * @copyright 2017 Juan Leyva <juan@moodle.com> 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 namespace mod_feedback\external; 25 defined('MOODLE_INTERNAL') || die(); 26 27 use core\external\exporter; 28 use renderer_base; 29 use external_util; 30 use external_files; 31 32 /** 33 * Class for exporting partial feedback data (some fields are only viewable by admins). 34 * 35 * @copyright 2017 Juan Leyva <juan@moodle.com> 36 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 37 */ 38 class feedback_summary_exporter extends exporter { 39 40 protected static function define_properties() { 41 return array( 42 'id' => array( 43 'type' => PARAM_INT, 44 'description' => 'The primary key of the record.', 45 ), 46 'course' => array( 47 'type' => PARAM_INT, 48 'description' => 'Course id this feedback is part of.', 49 ), 50 'name' => array( 51 'type' => PARAM_TEXT, 52 'description' => 'Feedback name.', 53 ), 54 'intro' => array( 55 'default' => '', 56 'type' => PARAM_RAW, 57 'description' => 'Feedback introduction text.', 58 ), 59 'introformat' => array( 60 'choices' => array(FORMAT_HTML, FORMAT_MOODLE, FORMAT_PLAIN, FORMAT_MARKDOWN), 61 'type' => PARAM_INT, 62 'default' => FORMAT_MOODLE, 63 'description' => 'Feedback intro text format.', 64 ), 65 'lang' => array( 66 'type' => PARAM_LANG, 67 'description' => 'Forced activity language', 68 'null' => NULL_ALLOWED, 69 ), 70 'anonymous' => array( 71 'type' => PARAM_INT, 72 'description' => 'Whether the feedback is anonymous.', 73 ), 74 'email_notification' => array( 75 'type' => PARAM_BOOL, 76 'optional' => true, 77 'description' => 'Whether email notifications will be sent to teachers.', 78 ), 79 'multiple_submit' => array( 80 'default' => 1, 81 'type' => PARAM_BOOL, 82 'description' => 'Whether multiple submissions are allowed.', 83 ), 84 'autonumbering' => array( 85 'default' => 1, 86 'type' => PARAM_BOOL, 87 'description' => 'Whether questions should be auto-numbered.', 88 ), 89 'site_after_submit' => array( 90 'type' => PARAM_TEXT, 91 'optional' => true, 92 'description' => 'Link to next page after submission.', 93 ), 94 'page_after_submit' => array( 95 'type' => PARAM_RAW, 96 'optional' => true, 97 'description' => 'Text to display after submission.', 98 ), 99 'page_after_submitformat' => array( 100 'choices' => array(FORMAT_HTML, FORMAT_MOODLE, FORMAT_PLAIN, FORMAT_MARKDOWN), 101 'type' => PARAM_INT, 102 'default' => FORMAT_MOODLE, 103 'description' => 'Text to display after submission format.', 104 ), 105 'publish_stats' => array( 106 'default' => 0, 107 'type' => PARAM_BOOL, 108 'description' => 'Whether stats should be published.', 109 ), 110 'timeopen' => array( 111 'type' => PARAM_INT, 112 'optional' => true, 113 'description' => 'Allow answers from this time.', 114 ), 115 'timeclose' => array( 116 'type' => PARAM_INT, 117 'optional' => true, 118 'description' => 'Allow answers until this time.', 119 ), 120 'timemodified' => array( 121 'type' => PARAM_INT, 122 'optional' => true, 123 'description' => 'The time this record was modified.', 124 ), 125 'completionsubmit' => array( 126 'default' => 0, 127 'type' => PARAM_BOOL, 128 'description' => 'If this field is set to 1, then the activity will be automatically marked as complete on submission.', 129 ), 130 ); 131 } 132 133 protected static function define_related() { 134 return array( 135 'context' => 'context' 136 ); 137 } 138 139 protected static function define_other_properties() { 140 return array( 141 'coursemodule' => array( 142 'type' => PARAM_INT 143 ), 144 'introfiles' => array( 145 'type' => external_files::get_properties_for_exporter(), 146 'multiple' => true 147 ), 148 'pageaftersubmitfiles' => array( 149 'type' => external_files::get_properties_for_exporter(), 150 'multiple' => true, 151 'optional' => true 152 ), 153 ); 154 } 155 156 protected function get_other_values(renderer_base $output) { 157 $context = $this->related['context']; 158 159 $values = array( 160 'coursemodule' => $context->instanceid, 161 ); 162 163 $values['introfiles'] = external_util::get_area_files($context->id, 'mod_feedback', 'intro', false, false); 164 165 if (!empty($this->data->page_after_submit)) { 166 $values['pageaftersubmitfiles'] = external_util::get_area_files($context->id, 'mod_feedback', 'page_after_submit'); 167 } 168 169 return $values; 170 } 171 172 /** 173 * Get the formatting parameters for the intro. 174 * 175 * @return array 176 */ 177 protected function get_format_parameters_for_intro() { 178 return [ 179 'component' => 'mod_feedback', 180 'filearea' => 'intro', 181 'options' => array('noclean' => true), 182 ]; 183 } 184 185 /** 186 * Get the formatting parameters for the page_after_submit. 187 * 188 * @return array 189 */ 190 protected function get_format_parameters_for_page_after_submit() { 191 return [ 192 'component' => 'mod_feedback', 193 'filearea' => 'page_after_submit', 194 'itemid' => 0 195 ]; 196 } 197 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body