MDL-20636 Fix @package names and PHPdoc layout.
[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
bfebaf64
MD
28if (!defined('MOODLE_INTERNAL')) {
29 die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
30}
31
515ed4c3 32require_once($CFG->libdir.'/formslib.php');
33
aa9bdbe3
TH
34
35/**
36 * Form for editing qusetions categories (name, description, etc.)
37 *
38 * @copyright 2007 Jamie Pratt me@jamiep.org
39 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
40 */
515ed4c3 41class question_category_edit_form extends moodleform {
42
43 function definition() {
f34488b2 44 global $CFG, $DB;
aa9bdbe3 45 $mform = $this->_form;
515ed4c3 46
47 $contexts = $this->_customdata['contexts'];
48 $currentcat = $this->_customdata['currentcat'];
49//--------------------------------------------------------------------------------
50 $mform->addElement('header', 'categoryheader', get_string('addcategory', 'quiz'));
515ed4c3 51
5fcefc97 52 $questioncategoryel = $mform->addElement('questioncategory', 'parent', get_string('parentcategory', 'question'),
515ed4c3 53 array('contexts'=>$contexts, 'top'=>true, 'currentcat'=>$currentcat, 'nochildrenof'=>$currentcat));
54 $mform->setType('parent', PARAM_SEQUENCE);
df4e2244 55 if (question_is_only_toplevel_category_in_context($currentcat)) {
515ed4c3 56 $mform->hardFreeze('parent');
57 }
5fcefc97 58 $mform->addHelpButton('parent', 'parentcategory', 'question');
515ed4c3 59
60 $mform->addElement('text','name', get_string('name'),'maxlength="254" size="50"');
61 $mform->setDefault('name', '');
62 $mform->addRule('name', get_string('categorynamecantbeblank', 'quiz'), 'required', null, 'client');
63 $mform->setType('name', PARAM_MULTILANG);
64
65 $mform->addElement('textarea', 'info', get_string('categoryinfo', 'quiz'), array('rows'=> '10', 'cols'=>'45'));
66 $mform->setDefault('info', '');
67 $mform->setType('info', PARAM_MULTILANG);
68//--------------------------------------------------------------------------------
69 $this->add_action_buttons(false, get_string('addcategory', 'quiz'));
70//--------------------------------------------------------------------------------
71 $mform->addElement('hidden', 'id', 0);
72 $mform->setType('id', PARAM_INT);
73 }
74}
aeb15530 75