|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 // This file is part of Moodle - http://moodle.org/ 00003 // 00004 // Moodle is free software: you can redistribute it and/or modify 00005 // it under the terms of the GNU General Public License as published by 00006 // the Free Software Foundation, either version 3 of the License, or 00007 // (at your option) any later version. 00008 // 00009 // Moodle is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00016 00027 defined('MOODLE_INTERNAL') || die(); 00028 00029 00036 class qtype_random_edit_form extends question_edit_form { 00044 protected function definition() { 00045 $mform = $this->_form; 00046 00047 // Standard fields at the start of the form. 00048 $mform->addElement('header', 'generalheader', get_string("general", 'form')); 00049 00050 $mform->addElement('questioncategory', 'category', get_string('category', 'question'), 00051 array('contexts' => $this->contexts->having_cap('moodle/question:useall'))); 00052 00053 $mform->addElement('advcheckbox', 'questiontext[text]', 00054 get_string('includingsubcategories', 'qtype_random'), null, null, array(0, 1)); 00055 00056 $mform->addElement('hidden', 'qtype'); 00057 $mform->setType('qtype', PARAM_ALPHA); 00058 00059 $this->add_hidden_fields(); 00060 00061 $buttonarray = array(); 00062 $buttonarray[] = $mform->createElement('submit', 'submitbutton', get_string('savechanges')); 00063 $buttonarray[] = $mform->createElement('cancel'); 00064 $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false); 00065 $mform->closeHeaderBefore('buttonar'); 00066 } 00067 00068 public function set_data($question) { 00069 $question->questiontext = array('text' => $question->questiontext); 00070 // We don't want the complex stuff in the base class to run. 00071 moodleform::set_data($question); 00072 } 00073 00074 public function validation($fromform, $files) { 00075 //validation of category 00076 //is not relevant for this question type 00077 return array(); 00078 } 00079 00080 public function qtype() { 00081 return 'random'; 00082 } 00083 }