3 * A moodle form field type for question categories.
5 * @copyright © 2006 The Open University
6 * @author T.J.Hunt@open.ac.uk
7 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
12 require_once("$CFG->libdir/form/select.php");
15 * HTML class for a drop down element to select a question category.
18 class MoodleQuickForm_questioncategory
extends MoodleQuickForm_select
{
23 * @param string $elementName Select name attribute
24 * @param mixed $elementLabel Label(s) for the select
25 * @param mixed $attributes Either a typical HTML attribute string or an associative array
26 * @param array $options additional options. Recognised options are courseid, published and
27 * only_editable, corresponding to the arguments of question_category_options from moodlelib.php.
31 function MoodleQuickForm_questioncategory($elementName = null,
32 $elementLabel = null, $attributes = null, $options = null) {
33 HTML_QuickForm_element
::HTML_QuickForm_element($elementName, $elementLabel, $attributes, null);
36 $this->_type
= 'questioncategory';
37 if (!empty($options['courseid'])) {
38 $this->_courseid
= $options['courseid'];
40 $this->_courseid
= $COURSE->id
;
42 if (!empty($options['published'])) {
43 $this->_published
= $options['published'];
45 $this->_published
= false;
47 if (!empty($options['only_editable'])) {
48 $this->_only_editable
= $options['only_editable'];
50 $this->_only_editable
= false;
55 * Called by HTML_QuickForm whenever form event is made on this element
57 * @param string $event Name of event
58 * @param mixed $arg event arguments
59 * @param object $caller calling object
63 function onQuickFormEvent($event, $arg, &$caller) {
66 $this->load(question_category_options($this->_courseid
, $this->_published
, $this->_only_editable
));
69 return parent
::onQuickFormEvent($event, $arg, $caller);