merging MOODLE_19_QUESTIONS with HEAD
[moodle.git] / question / type / random / edit_random_form.php
CommitLineData
6e9b6ba2 1<?php
2/**
3 * Defines the editing form for the random question type.
4 *
5 * @copyright &copy; 2007 Jamie Pratt
6 * @author Jamie Pratt me@jamiep.org
7 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
830e47a8 8 * @package questionbank
9 * @subpackage questiontypes
6e9b6ba2 10 */
11
12/**
13 * random editing form definition.
14 */
15class question_edit_random_form extends question_edit_form {
16 /**
17 * Build the form definition.
18 *
19 * This adds all the form files that the default question type supports.
20 * If your question type does not support all these fields, then you can
21 * override this method and remove the ones you don't want with $mform->removeElement().
22 */
23 function definition() {
24 global $COURSE, $CFG;
25
26 $qtype = $this->qtype();
27 $langfile = "qtype_$qtype";
28
29 $mform =& $this->_form;
30
31 // Standard fields at the start of the form.
32 $mform->addElement('header', 'generalheader', get_string("general", 'form'));
33
34 $mform->addElement('questioncategory', 'category', get_string('category', 'quiz'),
35 array('courseid' => $COURSE->id, 'published' => true, 'only_editable' => true));
36
37 $mform->addElement('text', 'name', get_string('questionname', 'quiz'),
38 array('size' => 50));
39 $mform->setType('name', PARAM_TEXT);
40 $mform->addRule('name', null, 'required', null, 'client');
41
42 $mform->addElement('advcheckbox', 'questiontext', get_string("recurse", "quiz"), null, null, array(0, 1));
43
44 // Standard fields at the end of the form.
24f7485b 45 $mform->addElement('hidden', 'questiontextformat', 0);
46 $mform->setType('questiontextformat', PARAM_INT);
47
6e9b6ba2 48 $mform->addElement('hidden', 'id');
49 $mform->setType('id', PARAM_INT);
50
51 $mform->addElement('hidden', 'qtype');
52 $mform->setType('qtype', PARAM_ALPHA);
53
54 $mform->addElement('hidden', 'inpopup');
55 $mform->setType('inpopup', PARAM_INT);
56
57 $mform->addElement('hidden', 'versioning');
58 $mform->setType('versioning', PARAM_BOOL);
59
60 $buttonarray = array();
61 $buttonarray[] = &$mform->createElement('submit', 'submitbutton', get_string('savechanges'));
24f7485b 62
6e9b6ba2 63 $buttonarray[] = &$mform->createElement('cancel');
64 $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false);
65 $mform->closeHeaderBefore('buttonar');
66 }
67
32db0d42 68 function set_data($question) {
6e9b6ba2 69 if (empty($question->name)) {
70 $question->name = get_string("random", "quiz");
71 }
32db0d42 72 parent::set_data($question);
6e9b6ba2 73 }
74
75 function qtype() {
76 return 'random';
77 }
78}
79?>