3 * A moodle form field type for question categories.
5 * @copyright Jamie Pratt
7 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
12 require_once("$CFG->libdir/form/selectgroups.php");
13 require_once("$CFG->libdir/questionlib.php");
16 * HTML class for a drop down element to select a question category.
19 class MoodleQuickForm_questioncategory
extends MoodleQuickForm_selectgroups
{
20 var $_options = array('top'=>false, 'currentcat'=>0, 'nochildrenof' => -1);
25 * @param string $elementName Select name attribute
26 * @param mixed $elementLabel Label(s) for the select
27 * @param mixed $attributes Either a typical HTML attribute string or an associative array
28 * @param array $options additional options. Recognised options are courseid, published and
29 * only_editable, corresponding to the arguments of question_category_options from moodlelib.php.
33 function MoodleQuickForm_questioncategory($elementName = null, $elementLabel = null, $options = null, $attributes = null) {
34 MoodleQuickForm_selectgroups
::MoodleQuickForm_selectgroups($elementName, $elementLabel, array(), $attributes);
35 $this->_type
= 'questioncategory';
36 if (is_array($options)) {
37 $this->_options
= $options +
$this->_options
;
38 $this->loadArrayOptGroups(
39 question_category_options($this->_options
['contexts'], $this->_options
['top'], $this->_options
['currentcat'],
40 false, $this->_options
['nochildrenof']));