listlib: MDL-17422 Paging in listlib was badly screwed
[moodle.git] / question / category_form.php
CommitLineData
515ed4c3 1<?php //$Id$
2
3require_once($CFG->libdir.'/formslib.php');
4
5class question_category_edit_form extends moodleform {
6
7 function definition() {
f34488b2 8 global $CFG, $DB;
515ed4c3 9 $mform =& $this->_form;
10
11 $contexts = $this->_customdata['contexts'];
12 $currentcat = $this->_customdata['currentcat'];
13//--------------------------------------------------------------------------------
14 $mform->addElement('header', 'categoryheader', get_string('addcategory', 'quiz'));
515ed4c3 15
16 $questioncategoryel = $mform->addElement('questioncategory', 'parent', get_string('parent', 'quiz'),
17 array('contexts'=>$contexts, 'top'=>true, 'currentcat'=>$currentcat, 'nochildrenof'=>$currentcat));
18 $mform->setType('parent', PARAM_SEQUENCE);
1e69a656 19 // This next test is actually looking to see if $currentcat is the id of
20 // a category that already exists, and is the only top-level category in
21 // it context. If so, we stop it from being moved.
f34488b2 22 if (1 == $DB->count_records_sql("SELECT count(*)
23 FROM {question_categories} c1,
24 {question_categories} c2
25 WHERE c2.id = ?
1e69a656 26 AND c1.contextid = c2.contextid
27 AND c1.parent = 0 AND c2.parent = 0", array($currentcat))){
515ed4c3 28 $mform->hardFreeze('parent');
29 }
35241c76 30 $mform->setHelpButton('parent', array('categoryparent', get_string('parent', 'quiz'), 'question'));
515ed4c3 31
32 $mform->addElement('text','name', get_string('name'),'maxlength="254" size="50"');
33 $mform->setDefault('name', '');
34 $mform->addRule('name', get_string('categorynamecantbeblank', 'quiz'), 'required', null, 'client');
35 $mform->setType('name', PARAM_MULTILANG);
36
37 $mform->addElement('textarea', 'info', get_string('categoryinfo', 'quiz'), array('rows'=> '10', 'cols'=>'45'));
38 $mform->setDefault('info', '');
39 $mform->setType('info', PARAM_MULTILANG);
40//--------------------------------------------------------------------------------
41 $this->add_action_buttons(false, get_string('addcategory', 'quiz'));
42//--------------------------------------------------------------------------------
43 $mform->addElement('hidden', 'id', 0);
44 $mform->setType('id', PARAM_INT);
45 }
46}
47?>