merging MOODLE_19_QUESTIONS with HEAD

This commit is contained in:
jamiesensei 2007-08-09 21:51:09 +00:00
parent 3bee1ead40
commit 271e6decda
47 changed files with 2807 additions and 1546 deletions

View file

@ -2,20 +2,22 @@
/**
* A moodle form field type for question categories.
*
* @copyright © 2006 The Open University
* @author T.J.Hunt@open.ac.uk
* @copyright Jamie Pratt
* @author Jamie Pratt
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package moodleforms
*//** */
*/
global $CFG;
require_once("$CFG->libdir/form/select.php");
require_once("$CFG->libdir/form/selectgroups.php");
require_once("$CFG->libdir/questionlib.php");
/**
* HTML class for a drop down element to select a question category.
* @access public
*/
class MoodleQuickForm_questioncategory extends MoodleQuickForm_select {
class MoodleQuickForm_questioncategory extends MoodleQuickForm_selectgroups {
var $_options = array('top'=>false, 'currentcat'=>0, 'nochildrenof' => -1);
/**
* Constructor
@ -28,45 +30,16 @@ class MoodleQuickForm_questioncategory extends MoodleQuickForm_select {
* @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;
function MoodleQuickForm_questioncategory($elementName = null, $elementLabel = null, $options = null, $attributes = null) {
MoodleQuickForm_selectgroups::MoodleQuickForm_selectgroups($elementName, $elementLabel, array(), $attributes);
$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;
if (is_array($options)) {
$this->_options = $options + $this->_options;
$this->loadArrayOptGroups(
question_category_options($this->_options['contexts'], $this->_options['top'], $this->_options['currentcat'],
false, $this->_options['nochildrenof']));
}
}
/**
* 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);
}
}
?>