empty array as default value for a multiselect config variable.
[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
8 * @package questions
9 */
10
11/**
12 * random editing form definition.
13 */
14class question_edit_random_form extends question_edit_form {
15 /**
16 * Build the form definition.
17 *
18 * This adds all the form files that the default question type supports.
19 * If your question type does not support all these fields, then you can
20 * override this method and remove the ones you don't want with $mform->removeElement().
21 */
22 function definition() {
23 global $COURSE, $CFG;
24
25 $qtype = $this->qtype();
26 $langfile = "qtype_$qtype";
27
28 $mform =& $this->_form;
29
30 // Standard fields at the start of the form.
31 $mform->addElement('header', 'generalheader', get_string("general", 'form'));
32
33 $mform->addElement('questioncategory', 'category', get_string('category', 'quiz'),
34 array('courseid' => $COURSE->id, 'published' => true, 'only_editable' => true));
35
36 $mform->addElement('text', 'name', get_string('questionname', 'quiz'),
37 array('size' => 50));
38 $mform->setType('name', PARAM_TEXT);
39 $mform->addRule('name', null, 'required', null, 'client');
40
41 $mform->addElement('advcheckbox', 'questiontext', get_string("recurse", "quiz"), null, null, array(0, 1));
42
43 // Standard fields at the end of the form.
24f7485b 44 $mform->addElement('hidden', 'questiontextformat', 0);
45 $mform->setType('questiontextformat', PARAM_INT);
46
6e9b6ba2 47 $mform->addElement('hidden', 'id');
48 $mform->setType('id', PARAM_INT);
49
50 $mform->addElement('hidden', 'qtype');
51 $mform->setType('qtype', PARAM_ALPHA);
52
53 $mform->addElement('hidden', 'inpopup');
54 $mform->setType('inpopup', PARAM_INT);
55
56 $mform->addElement('hidden', 'versioning');
57 $mform->setType('versioning', PARAM_BOOL);
58
59 $buttonarray = array();
60 $buttonarray[] = &$mform->createElement('submit', 'submitbutton', get_string('savechanges'));
24f7485b 61
6e9b6ba2 62 $buttonarray[] = &$mform->createElement('cancel');
63 $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false);
64 $mform->closeHeaderBefore('buttonar');
65 }
66
67 function set_defaults($question) {
68 if (empty($question->name)) {
69 $question->name = get_string("random", "quiz");
70 }
71 parent::set_defaults($question);
72 }
73
74 function qtype() {
75 return 'random';
76 }
77}
78?>