Differences Between: [Versions 310 and 403] [Versions 311 and 403] [Versions 39 and 403] [Versions 400 and 403] [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 workshop data. 19 * 20 * @package mod_workshop 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_workshop\external; 25 defined('MOODLE_INTERNAL') || die(); 26 27 use core\external\exporter; 28 use renderer_base; 29 use core_external\util as external_util; 30 use core_external\external_files; 31 32 /** 33 * Class for exporting partial workshop 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 workshop_summary_exporter extends exporter { 39 40 protected static function define_properties() { 41 42 return array( 43 'id' => array( 44 'type' => PARAM_INT, 45 'description' => 'The primary key of the record.', 46 ), 47 'course' => array( 48 'type' => PARAM_INT, 49 'description' => 'Course id this workshop is part of.', 50 ), 51 'name' => array( 52 'type' => PARAM_TEXT, 53 'description' => 'Workshop name.', 54 ), 55 'intro' => array( 56 'default' => '', 57 'type' => PARAM_RAW, 58 'description' => 'Workshop introduction text.', 59 'null' => NULL_ALLOWED, 60 ), 61 'introformat' => array( 62 'choices' => array(FORMAT_HTML, FORMAT_MOODLE, FORMAT_PLAIN, FORMAT_MARKDOWN), 63 'type' => PARAM_INT, 64 'default' => FORMAT_MOODLE, 65 'description' => 'Workshop intro text format.', 66 ), 67 'lang' => array( 68 'type' => PARAM_LANG, 69 'description' => 'Forced activity language', 70 'null' => NULL_ALLOWED, 71 ), 72 'instructauthors' => array( 73 'type' => PARAM_RAW, 74 'description' => 'Instructions for the submission phase.', 75 'optional' => true, 76 'null' => NULL_ALLOWED, 77 ), 78 'instructauthorsformat' => array( 79 'choices' => array(FORMAT_HTML, FORMAT_MOODLE, FORMAT_PLAIN, FORMAT_MARKDOWN), 80 'type' => PARAM_INT, 81 'default' => FORMAT_MOODLE, 82 'description' => 'Instructions text format.', 83 ), 84 'instructreviewers' => array( 85 'type' => PARAM_RAW, 86 'description' => 'Instructions for the assessment phase.', 87 'optional' => true, 88 'null' => NULL_ALLOWED, 89 ), 90 'instructreviewersformat' => array( 91 'choices' => array(FORMAT_HTML, FORMAT_MOODLE, FORMAT_PLAIN, FORMAT_MARKDOWN), 92 'type' => PARAM_INT, 93 'default' => FORMAT_MOODLE, 94 'description' => 'Instructions text format.', 95 ), 96 'timemodified' => array( 97 'type' => PARAM_INT, 98 'description' => 'The timestamp when the module was modified.', 99 'optional' => true, 100 ), 101 'phase' => array( 102 'type' => PARAM_INT, 103 'default' => 0, 104 'description' => 'The current phase of workshop (0 = not available, 1 = submission, 2 = assessment, 3 = closed).', 105 'optional' => true, 106 ), 107 'useexamples' => array( 108 'type' => PARAM_BOOL, 109 'default' => false, 110 'description' => 'Optional feature: students practise evaluating on example submissions from teacher.', 111 'optional' => true, 112 ), 113 'usepeerassessment' => array( 114 'type' => PARAM_BOOL, 115 'default' => false, 116 'description' => 'Optional feature: students perform peer assessment of others\' work.', 117 'optional' => true, 118 ), 119 'useselfassessment' => array( 120 'type' => PARAM_BOOL, 121 'default' => false, 122 'description' => 'Optional feature: students perform self assessment of their own work.', 123 'optional' => true, 124 ), 125 'grade' => array( 126 'type' => PARAM_FLOAT, 127 'default' => 80, 128 'description' => 'The maximum grade for submission.', 129 'optional' => true, 130 ), 131 'gradinggrade' => array( 132 'type' => PARAM_FLOAT, 133 'default' => 20, 134 'description' => 'The maximum grade for assessment.', 135 'optional' => true, 136 ), 137 'strategy' => array( 138 'type' => PARAM_PLUGIN, 139 'description' => 'The type of the current grading strategy used in this workshop.', 140 'optional' => true, 141 ), 142 'evaluation' => array( 143 'type' => PARAM_PLUGIN, 144 'description' => 'The recently used grading evaluation method.', 145 'optional' => true, 146 ), 147 'gradedecimals' => array( 148 'type' => PARAM_INT, 149 'default' => 0, 150 'description' => 'Number of digits that should be shown after the decimal point when displaying grades.', 151 'optional' => true, 152 ), 153 'submissiontypetext' => array ( 154 'type' => PARAM_INT, 155 'default' => 1, 156 'description' => 'Indicates whether text is required as part of each submission. ' . 157 '0 for no, 1 for optional, 2 for required.', 158 'optional' => true 159 ), 160 'submissiontypefile' => array ( 161 'type' => PARAM_INT, 162 'default' => 1, 163 'description' => 'Indicates whether a file upload is required as part of each submission. ' . 164 '0 for no, 1 for optional, 2 for required.', 165 'optional' => true 166 ), 167 'nattachments' => array( 168 'type' => PARAM_INT, 169 'default' => 1, 170 'description' => 'Maximum number of submission attachments.', 171 'optional' => true, 172 ), 173 'submissionfiletypes' => array( 174 'type' => PARAM_RAW, 175 'description' => 'Comma separated list of file extensions.', 176 'optional' => true, 177 'null' => NULL_ALLOWED, 178 ), 179 'latesubmissions' => array( 180 'type' => PARAM_BOOL, 181 'default' => false, 182 'description' => 'Allow submitting the work after the deadline.', 183 'optional' => true, 184 ), 185 'maxbytes' => array( 186 'type' => PARAM_INT, 187 'default' => 100000, 188 'description' => 'Maximum size of the one attached file.', 189 'optional' => true, 190 ), 191 'examplesmode' => array( 192 'type' => PARAM_INT, 193 'default' => 0, 194 'description' => '0 = example assessments are voluntary, 1 = examples must be assessed before submission, 195 2 = examples are available after own submission and must be assessed before peer/self assessment phase.', 196 'optional' => true, 197 ), 198 'submissionstart' => array( 199 'type' => PARAM_INT, 200 'default' => 0, 201 'description' => '0 = will be started manually, greater than 0 the timestamp of the start of the submission phase.', 202 'optional' => true, 203 ), 204 'submissionend' => array( 205 'type' => PARAM_INT, 206 'default' => 0, 207 'description' => '0 = will be closed manually, greater than 0 the timestamp of the end of the submission phase.', 208 'optional' => true, 209 ), 210 'assessmentstart' => array( 211 'type' => PARAM_INT, 212 'default' => 0, 213 'description' => '0 = will be started manually, greater than 0 the timestamp of the start of the assessment phase.', 214 'optional' => true, 215 ), 216 'assessmentend' => array( 217 'type' => PARAM_INT, 218 'default' => 0, 219 'description' => '0 = will be closed manually, greater than 0 the timestamp of the end of the assessment phase.', 220 'optional' => true, 221 ), 222 'phaseswitchassessment' => array( 223 'type' => PARAM_BOOL, 224 'default' => false, 225 'description' => 'Automatically switch to the assessment phase after the submissions deadline.', 226 'optional' => true, 227 ), 228 'conclusion' => array( 229 'type' => PARAM_RAW, 230 'description' => 'A text to be displayed at the end of the workshop.', 231 'optional' => true, 232 'null' => NULL_ALLOWED, 233 ), 234 'conclusionformat' => array( 235 'choices' => array(FORMAT_HTML, FORMAT_MOODLE, FORMAT_PLAIN, FORMAT_MARKDOWN), 236 'type' => PARAM_INT, 237 'default' => FORMAT_MOODLE, 238 'description' => 'Workshop conclusion text format.', 239 ), 240 'overallfeedbackmode' => array( 241 'type' => PARAM_INT, 242 'default' => 1, 243 'description' => 'Mode of the overall feedback support.', 244 'optional' => true, 245 ), 246 'overallfeedbackfiles' => array( 247 'type' => PARAM_INT, 248 'default' => 0, 249 'description' => 'Number of allowed attachments to the overall feedback.', 250 'optional' => true, 251 ), 252 'overallfeedbackfiletypes' => array( 253 'type' => PARAM_RAW, 254 'description' => 'Comma separated list of file extensions.', 255 'optional' => true, 256 'null' => NULL_ALLOWED, 257 ), 258 'overallfeedbackmaxbytes' => array( 259 'type' => PARAM_INT, 260 'default' => 100000, 261 'description' => 'Maximum size of one file attached to the overall feedback.', 262 'optional' => true, 263 ), 264 ); 265 } 266 267 protected static function define_related() { 268 return array( 269 'context' => 'context' 270 ); 271 } 272 273 protected static function define_other_properties() { 274 return array( 275 'coursemodule' => array( 276 'type' => PARAM_INT 277 ), 278 'introfiles' => array( 279 'type' => external_files::get_properties_for_exporter(), 280 'multiple' => true 281 ), 282 'instructauthorsfiles' => array( 283 'type' => external_files::get_properties_for_exporter(), 284 'multiple' => true, 285 'optional' => true 286 ), 287 'instructreviewersfiles' => array( 288 'type' => external_files::get_properties_for_exporter(), 289 'multiple' => true, 290 'optional' => true 291 ), 292 'conclusionfiles' => array( 293 'type' => external_files::get_properties_for_exporter(), 294 'multiple' => true, 295 'optional' => true 296 ), 297 ); 298 } 299 300 protected function get_other_values(renderer_base $output) { 301 $context = $this->related['context']; 302 303 $values = array( 304 'coursemodule' => $context->instanceid, 305 ); 306 307 $values['introfiles'] = external_util::get_area_files($context->id, 'mod_workshop', 'intro', false, false); 308 309 if (!empty($this->data->instructauthors)) { 310 $values['instructauthorsfiles'] = external_util::get_area_files($context->id, 'mod_workshop', 'instructauthors'); 311 } 312 313 if (!empty($this->data->instructreviewers)) { 314 $values['instructreviewersfiles'] = external_util::get_area_files($context->id, 'mod_workshop', 'instructreviewers'); 315 } 316 317 if (!empty($this->data->conclusion)) { 318 $values['conclusionfiles'] = external_util::get_area_files($context->id, 'mod_workshop', 'conclusion'); 319 } 320 321 return $values; 322 } 323 324 /** 325 * Get the formatting parameters for the intro. 326 * 327 * @return array with the formatting parameters 328 */ 329 protected function get_format_parameters_for_intro() { 330 return [ 331 'component' => 'mod_workshop', 332 'filearea' => 'intro', 333 'options' => array('noclean' => true), 334 ]; 335 } 336 337 /** 338 * Get the formatting parameters for the instructauthors. 339 * 340 * @return array with the formatting parameters 341 */ 342 protected function get_format_parameters_for_instructauthors() { 343 return [ 344 'component' => 'mod_workshop', 345 'filearea' => 'instructauthors', 346 'itemid' => 0 347 ]; 348 } 349 350 /** 351 * Get the formatting parameters for the instructreviewers. 352 * 353 * @return array with the formatting parameters 354 */ 355 protected function get_format_parameters_for_instructreviewers() { 356 return [ 357 'component' => 'mod_workshop', 358 'filearea' => 'instructreviewers', 359 'itemid' => 0 360 ]; 361 } 362 363 /** 364 * Get the formatting parameters for the conclusion. 365 * 366 * @return array with the formatting parameters 367 */ 368 protected function get_format_parameters_for_conclusion() { 369 return [ 370 'component' => 'mod_workshop', 371 'filearea' => 'conclusion', 372 'itemid' => 0 373 ]; 374 } 375 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body