2 // This file is part of Moodle - http://moodle.org/
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.
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.
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/>.
18 * Defines the editing form for the random question type.
22 * @copyright 2007 Jamie Pratt me@jamiep.org
23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
27 defined('MOODLE_INTERNAL') || die();
31 * random editing form definition.
33 * @copyright 2007 Jamie Pratt me@jamiep.org
34 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
36 class qtype_random_edit_form extends question_edit_form {
38 * Build the form definition.
40 * This adds all the form files that the default question type supports.
41 * If your question type does not support all these fields, then you can
42 * override this method and remove the ones you don't want with $mform->removeElement().
44 protected function definition() {
45 $mform = $this->_form;
47 // Standard fields at the start of the form.
48 $mform->addElement('header', 'generalheader', get_string("general", 'form'));
50 $mform->addElement('questioncategory', 'category', get_string('category', 'question'),
51 array('contexts' => $this->contexts->having_cap('moodle/question:useall')));
53 $mform->addElement('advcheckbox', 'questiontext[text]',
54 get_string('includingsubcategories', 'qtype_random'), null, null, array(0, 1));
56 $mform->addElement('hidden', 'qtype');
57 $mform->setType('qtype', PARAM_ALPHA);
59 $this->add_hidden_fields();
61 $buttonarray = array();
62 $buttonarray[] = $mform->createElement('submit', 'submitbutton', get_string('savechanges'));
63 $buttonarray[] = $mform->createElement('cancel');
64 $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false);
65 $mform->closeHeaderBefore('buttonar');
68 public function set_data($question) {
69 $question->questiontext = array('text' => $question->questiontext);
70 // We don't want the complex stuff in the base class to run.
71 moodleform::set_data($question);
74 public function validation($fromform, $files) {
75 // Validation of category is not relevant for this question type.
80 public function qtype() {