gradebook MDL-25358 improved validation of scales
[moodle.git] / question / type / random / edit_random_form.php
CommitLineData
aeb15530 1<?php
6e9b6ba2 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
aeb15530 34 $mform->addElement('questioncategory', 'category', get_string('category', 'quiz'),
271e6dec 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
24e8b9b6 39 $mform->addElement('hidden', 'name');
40 $mform->setType('name', PARAM_ALPHA);
41 $mform->setDefault('name', '');
42
43 $mform->addElement('hidden', 'tags[]');
44 $mform->setType('tags[]', PARAM_ALPHA);
45 $mform->setDefault('tags[]', '');
46
6e9b6ba2 47 // Standard fields at the end of the form.
24f7485b 48 $mform->addElement('hidden', 'questiontextformat', 0);
49 $mform->setType('questiontextformat', PARAM_INT);
50
6e9b6ba2 51 $mform->addElement('hidden', 'id');
52 $mform->setType('id', PARAM_INT);
53
54 $mform->addElement('hidden', 'qtype');
55 $mform->setType('qtype', PARAM_ALPHA);
56
57 $mform->addElement('hidden', 'inpopup');
58 $mform->setType('inpopup', PARAM_INT);
59
60 $mform->addElement('hidden', 'versioning');
61 $mform->setType('versioning', PARAM_BOOL);
62
271e6dec 63 $mform->addElement('hidden', 'cmid');
64 $mform->setType('cmid', PARAM_INT);
65 $mform->setDefault('cmid', 0);
66
67 $mform->addElement('hidden', 'courseid');
68 $mform->setType('courseid', PARAM_INT);
69 $mform->setDefault('courseid', 0);
70
71 $mform->addElement('hidden', 'returnurl');
72 $mform->setType('returnurl', PARAM_LOCALURL);
73 $mform->setDefault('returnurl', 0);
74
6e9b6ba2 75 $buttonarray = array();
76 $buttonarray[] = &$mform->createElement('submit', 'submitbutton', get_string('savechanges'));
24f7485b 77
6e9b6ba2 78 $buttonarray[] = &$mform->createElement('cancel');
79 $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false);
80 $mform->closeHeaderBefore('buttonar');
81 }
fe6ce234 82
3efbe6bc 83 function validation($fromform, $files) {
84 //validation of category
85 //is not relevant for this question type
86 return array();
87 }
fe6ce234 88
6e9b6ba2 89 function qtype() {
90 return 'random';
91 }
92}