Differences Between: [Versions 310 and 402] [Versions 311 and 402] [Versions 39 and 402] [Versions 400 and 402] [Versions 401 and 402]
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 * This file defines a base class for all grading strategy editing forms. 19 * 20 * @package mod_workshop 21 * @copyright 2009 David Mudrak <david.mudrak@gmail.com> 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 defined('MOODLE_INTERNAL') || die(); 26 27 require_once($CFG->libdir . '/formslib.php'); // parent class definition 28 29 /** 30 * Base class for editing all the strategy grading forms. 31 * 32 * This defines the common fields that all strategy grading forms need. 33 * Strategies should define their own class that inherits from this one, and 34 * implements the definition_inner() method. 35 * 36 * @uses moodleform 37 */ 38 class workshop_edit_strategy_form extends moodleform { 39 40 /** strategy logic instance that this class is editor of */ 41 protected $strategy; 42 43 /** @var workshop workshop. */ 44 protected $workshop; 45 46 /** 47 * Add the fields that are common for all grading strategies. 48 * 49 * If the strategy does not support all these fields, then you can override 50 * this method and remove the ones you don't want with 51 * $mform->removeElement(). 52 * Stretegy subclassess should define their own fields in definition_inner() 53 * 54 * @return void 55 */ 56 public function definition() { 57 global $CFG; 58 59 $mform = $this->_form; 60 $this->workshop = $this->_customdata['workshop']; 61 $this->strategy = $this->_customdata['strategy']; 62 63 $mform->addElement('hidden', 'workshopid', $this->workshop->id); // workshopid 64 $mform->setType('workshopid', PARAM_INT); 65 66 $mform->addElement('hidden', 'strategy', $this->workshop->strategy); // strategy name 67 $mform->setType('strategy', PARAM_PLUGIN); 68 69 $this->definition_inner($mform); 70 71 // todo - tags support 72 //if (!empty($CFG->usetags)) { 73 // $mform->addElement('header', 'tagsheader', get_string('tags')); 74 // $mform->addElement('tags', 'tags', get_string('tags')); 75 //} 76 77 $buttonarray = array(); 78 $buttonarray[] = $mform->createElement('submit', 'saveandcontinue', get_string('saveandcontinue', 'workshop')); 79 $buttonarray[] = $mform->createElement('submit', 'saveandpreview', get_string('saveandpreview', 'workshop')); 80 $buttonarray[] = $mform->createElement('submit', 'saveandclose', get_string('saveandclose', 'workshop')); 81 $buttonarray[] = $mform->createElement('cancel'); 82 $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false); 83 $mform->closeHeaderBefore('buttonar'); 84 } 85 86 /** 87 * Validate the submitted form data. 88 * 89 * Grading strategy plugins can provide their own validation rules by 90 * overriding the {@link self::validation_inner()} method. 91 * 92 * @param array $data 93 * @param array $files 94 * @return array 95 */ 96 final public function validation($data, $files) { 97 return array_merge( 98 parent::validation($data, $files), 99 $this->validation_inner($data, $files) 100 ); 101 } 102 103 /** 104 * Add any strategy specific form fields. 105 * 106 * @param stdClass $mform the form being built. 107 */ 108 protected function definition_inner(&$mform) { 109 // By default, do nothing. 110 } 111 112 /** 113 * Add strategy specific validation rules. 114 * 115 * @param array $data 116 * @param array $files 117 * @return array 118 */ 119 protected function validation_inner($data, $files) { 120 return array(); 121 } 122 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body