mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
questioncategory formslib.php form control.
This commit is contained in:
parent
abcaf2cfa5
commit
9e93222df2
2 changed files with 73 additions and 0 deletions
72
lib/form/questioncategory.php
Normal file
72
lib/form/questioncategory.php
Normal file
|
@ -0,0 +1,72 @@
|
|||
<?php
|
||||
/**
|
||||
* A moodle form field type for question categories.
|
||||
*
|
||||
* @copyright © 2006 The Open University
|
||||
* @author T.J.Hunt@open.ac.uk
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package moodleforms
|
||||
*//** */
|
||||
|
||||
global $CFG;
|
||||
require_once("$CFG->libdir/form/select.php");
|
||||
|
||||
/**
|
||||
* HTML class for a drop down element to select a question category.
|
||||
* @access public
|
||||
*/
|
||||
class MoodleQuickForm_questioncategory extends MoodleQuickForm_select {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $elementName Select name attribute
|
||||
* @param mixed $elementLabel Label(s) for the select
|
||||
* @param mixed $attributes Either a typical HTML attribute string or an associative array
|
||||
* @param array $options additional options. Recognised options are courseid, published and
|
||||
* only_editable, corresponding to the arguments of question_category_options from moodlelib.php.
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function MoodleQuickForm_questioncategory($elementName = null,
|
||||
$elementLabel = null, $attributes = null, $options = null) {
|
||||
HTML_QuickForm_element::HTML_QuickForm_element($elementName, $elementLabel, $attributes, null);
|
||||
|
||||
global $COURSE;
|
||||
$this->_type = 'questioncategory';
|
||||
if (!empty($options['courseid'])) {
|
||||
$this->_courseid = $options['courseid'];
|
||||
} else {
|
||||
$this->_courseid = $COURSE->id;
|
||||
}
|
||||
if (!empty($options['published'])) {
|
||||
$this->_published = $options['published'];
|
||||
} else {
|
||||
$this->_published = false;
|
||||
}
|
||||
if (!empty($options['only_editable'])) {
|
||||
$this->_only_editable = $options['only_editable'];
|
||||
} else {
|
||||
$this->_only_editable = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by HTML_QuickForm whenever form event is made on this element
|
||||
*
|
||||
* @param string $event Name of event
|
||||
* @param mixed $arg event arguments
|
||||
* @param object $caller calling object
|
||||
* @access public
|
||||
* @return mixed
|
||||
*/
|
||||
function onQuickFormEvent($event, $arg, &$caller) {
|
||||
switch ($event) {
|
||||
case 'createElement':
|
||||
$this->load(question_category_options($this->_courseid, $this->_published, $this->_only_editable));
|
||||
break;
|
||||
}
|
||||
return parent::onQuickFormEvent($event, $arg, $caller);
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -1473,5 +1473,6 @@ MoodleQuickForm::registerElementType('button', "$CFG->libdir/form/button.php", '
|
|||
MoodleQuickForm::registerElementType('choosecoursefile', "$CFG->libdir/form/choosecoursefile.php", 'MoodleQuickForm_choosecoursefile');
|
||||
MoodleQuickForm::registerElementType('header', "$CFG->libdir/form/header.php", 'MoodleQuickForm_header');
|
||||
MoodleQuickForm::registerElementType('submit', "$CFG->libdir/form/submit.php", 'MoodleQuickForm_submit');
|
||||
MoodleQuickForm::registerElementType('questioncategory', "$CFG->libdir/form/questioncategory.php", 'MoodleQuickForm_questioncategory');
|
||||
|
||||
?>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue