MDL-10201 Merged from MOODLE_19_STABLE
[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
271e6dec 34 $mform->addElement('questioncategory', 'category', get_string('category', 'quiz'),
35 array('contexts' => $this->contexts->having_cap('moodle/question:useall')));
6e9b6ba2 36
6e9b6ba2 37 $mform->addElement('advcheckbox', 'questiontext', get_string("recurse", "quiz"), null, null, array(0, 1));
38
39 // Standard fields at the end of the form.
24f7485b 40 $mform->addElement('hidden', 'questiontextformat', 0);
41 $mform->setType('questiontextformat', PARAM_INT);
42
6e9b6ba2 43 $mform->addElement('hidden', 'id');
44 $mform->setType('id', PARAM_INT);
45
46 $mform->addElement('hidden', 'qtype');
47 $mform->setType('qtype', PARAM_ALPHA);
48
49 $mform->addElement('hidden', 'inpopup');
50 $mform->setType('inpopup', PARAM_INT);
51
52 $mform->addElement('hidden', 'versioning');
53 $mform->setType('versioning', PARAM_BOOL);
54
271e6dec 55 $mform->addElement('hidden', 'cmid');
56 $mform->setType('cmid', PARAM_INT);
57 $mform->setDefault('cmid', 0);
58
59 $mform->addElement('hidden', 'courseid');
60 $mform->setType('courseid', PARAM_INT);
61 $mform->setDefault('courseid', 0);
62
63 $mform->addElement('hidden', 'returnurl');
64 $mform->setType('returnurl', PARAM_LOCALURL);
65 $mform->setDefault('returnurl', 0);
66
6e9b6ba2 67 $buttonarray = array();
68 $buttonarray[] = &$mform->createElement('submit', 'submitbutton', get_string('savechanges'));
24f7485b 69
6e9b6ba2 70 $buttonarray[] = &$mform->createElement('cancel');
71 $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false);
72 $mform->closeHeaderBefore('buttonar');
73 }
74
6e9b6ba2 75 function qtype() {
76 return 'random';
77 }
78}
79?>