MDL-20636 Question import, support for files in hints.
[moodle.git] / question / category_form.php
CommitLineData
aeb15530 1<?php
515ed4c3 2
aa9bdbe3
TH
3// This file is part of Moodle - http://moodle.org/
4//
5// Moodle is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// Moodle is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
17
18/**
19 * Defines the form for editing question categories.
20 *
21 * @package moodlecore
22 * @subpackage questionbank
23 * @copyright 2007 Jamie Pratt me@jamiep.org
24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 */
26
27
a17b297d 28defined('MOODLE_INTERNAL') || die();
bfebaf64 29
515ed4c3 30require_once($CFG->libdir.'/formslib.php');
31
aa9bdbe3
TH
32
33/**
34 * Form for editing qusetions categories (name, description, etc.)
35 *
36 * @copyright 2007 Jamie Pratt me@jamiep.org
37 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
38 */
515ed4c3 39class question_category_edit_form extends moodleform {
40
41 function definition() {
f34488b2 42 global $CFG, $DB;
aa9bdbe3 43 $mform = $this->_form;
515ed4c3 44
45 $contexts = $this->_customdata['contexts'];
46 $currentcat = $this->_customdata['currentcat'];
42663bb7 47
5e8a85aa 48 $mform->addElement('header', 'categoryheader', get_string('addcategory', 'question'));
515ed4c3 49
5fcefc97 50 $questioncategoryel = $mform->addElement('questioncategory', 'parent', get_string('parentcategory', 'question'),
515ed4c3 51 array('contexts'=>$contexts, 'top'=>true, 'currentcat'=>$currentcat, 'nochildrenof'=>$currentcat));
52 $mform->setType('parent', PARAM_SEQUENCE);
df4e2244 53 if (question_is_only_toplevel_category_in_context($currentcat)) {
515ed4c3 54 $mform->hardFreeze('parent');
55 }
5fcefc97 56 $mform->addHelpButton('parent', 'parentcategory', 'question');
515ed4c3 57
42663bb7 58 $mform->addElement('text', 'name', get_string('name'),'maxlength="254" size="50"');
515ed4c3 59 $mform->setDefault('name', '');
5e8a85aa 60 $mform->addRule('name', get_string('categorynamecantbeblank', 'question'), 'required', null, 'client');
515ed4c3 61 $mform->setType('name', PARAM_MULTILANG);
62
5e8a85aa 63 $mform->addElement('textarea', 'info', get_string('categoryinfo', 'question'), array('rows'=> '10', 'cols'=>'45'));
515ed4c3 64 $mform->setDefault('info', '');
65 $mform->setType('info', PARAM_MULTILANG);
42663bb7 66
5e8a85aa 67 $this->add_action_buttons(false, get_string('addcategory', 'question'));
42663bb7 68
515ed4c3 69 $mform->addElement('hidden', 'id', 0);
70 $mform->setType('id', PARAM_INT);
71 }
72}
aeb15530 73