case 'default' :
$mform->setDefault($realelementname, $params);
break;
- case 'type' :
- $mform->setType($realelementname, $params);
- break;
case 'helpbutton' :
$mform->setHelpButton($realelementname, $params);
break;
* @access public
*/
function MoodleQuickForm($formName, $method, $action, $target='', $attributes=null){
- global $CFG;
static $formcounter = 1;
HTML_Common::HTML_Common($attributes);
}
}
$renderer->setAdvancedElements($this->_advancedElements);
- if (count($this->_advancedElements)){
- }
}
parent::accept($renderer);
}
$this->_submitFiles = array();
} else {
if (1 == get_magic_quotes_gpc()) {
- foreach ($files as $elname=>$file) {
+ foreach (array_keys($files) as $elname) {
// dangerous characters in filenames are cleaned later in upload_manager
$files[$elname]['name'] = stripslashes($files[$elname]['name']);
}
{
parent::addGroupRule($group, $arg1, $type, $format, $howmany, $validation, $reset);
if (is_array($arg1)) {
- foreach ($arg1 as $elementIndex => $rules) {
+ foreach ($arg1 as $rules) {
foreach ($rules as $rule) {
$validation = (isset($rule[3]) && 'client' == $rule[3])? 'client': 'server';
} elseif (is_string($arg1)) {
if ($validation == 'client') {
- $this->updateAttributes(array('onsubmit' => 'try { var myValidator = validate_' . $formname . '; } catch(e) { return true; } return myValidator(this);'));
+ $this->updateAttributes(array('onsubmit' => 'try { var myValidator = validate_' . $this->_formName . '; } catch(e) { return true; } return myValidator(this);'));
}
}
} // end func addGroupRule
} elseif ($dependent) {
$element = array();
$element[] =& $this->getElement($elementName);
- foreach ($rule['dependent'] as $idx => $elName) {
+ foreach ($rule['dependent'] as $elName) {
$element[] =& $this->getElement($elName);
}
} else {
}
$repeateloptions = array();
- $repeateloptions['limit'] = array(
- 'default'=>0,
- 'type'=>PARAM_INT,
- 'disabledif'=>array('limitanswers', 'eq', 0));
- $repeateloptions['option'] = array(
- 'type'=>PARAM_TEXT,
- 'helpbutton'=>array('options', get_string('modulenameplural', 'choice'), 'choice'));
- $repeateloptions['optionid'] = array('type'=>PARAM_INT);
+ $repeateloptions['limit']['default'] = 0;
+ $repeateloptions['limit']['disabledif'] = array('limitanswers', 'eq', 0);
+ $mform->setType('limit', PARAM_INT);
+
+ $repeateloptions['option']['helpbutton'] = array('options', get_string('modulenameplural', 'choice'), 'choice');
+ $mform->setType('option', PARAM_TEXT);
+
+ $mform->setType('optionid', PARAM_INT);
$this->repeat_elements($repeatarray, $repeatno,
$repeateloptions, 'option_repeats', 'option_add_fields', 3);
}
$numfeedbacks = max(count($this->_feedbacks) * 1.5, 5);
- $repeateloptions = array();
- $repeateloptions ['feedbacktext'] = array('type'=>PARAM_TEXT);
- $repeateloptions ['feedbackboundaries'] = array('type'=>PARAM_TEXT);
+ $mform->setType('feedbacktext', PARAM_TEXT);
+ $mform->setType('feedbackboundaries', PARAM_NOTAGS);
$nextel=$this->repeat_elements($repeatarray, $numfeedbacks-1,
- $repeateloptions, 'boundary_repeats', 'boundary_add_fields', 3);
+ array(), 'boundary_repeats', 'boundary_add_fields', 3);
//put some extra elements in before the button
$insertEl = &MoodleQuickForm::createElement('text', "feedbacktext[$nextel]", get_string('feedback', 'quiz'));
$mform->insertElementBefore($insertEl, 'boundary_add_fields');
- $mform->setType("feedbacktext[$nextel]", PARAM_TEXT);
$insertEl = &MoodleQuickForm::createElement('static', 'gradeboundarystatic2', get_string('gradeboundary', 'quiz'), '0%');
$mform->insertElementBefore($insertEl, 'boundary_add_fields');
$mform->addGroup($anslengrp, 'anslengrp', get_string('correctanswershows', 'qtype_calculated'), null, false);
$mform->addElement('htmleditor', 'feedback[0]', get_string('feedback', 'quiz'));
- $mform->setType('feedback[0]', PARAM_RAW);
+ $mform->setType('feedback', PARAM_RAW);
//------------------------------------------------------------------------------------------
$repeated = array();
- $repeatedoptions = array();
$repeated[] =& $mform->createElement('header', 'unithdr', get_string('unithdr', 'qtype_numerical', '{no}'));
$repeated[] =& $mform->createElement('text', 'unit', get_string('unit', 'quiz'));
- $repeatedoptions['unit']['type'] = PARAM_NOTAGS;
+ $mform->setType('unit', PARAM_NOTAGS);
$repeated[] =& $mform->createElement('text', 'multiplier', get_string('multiplier', 'quiz'));
- $repeatedoptions['multiplier']['type'] = PARAM_NUMBER;
+ $mform->setType('multiplier', PARAM_NUMBER);
if (isset($this->question->options)){
$countunits = count($this->question->options->units);
$countunits = 0;
}
$repeatsatstart = $countunits + 1;
- $this->repeat_elements($repeated, $repeatsatstart, $repeatedoptions, 'nounits', 'addunits', 2, get_string('addmoreunitblanks', 'qtype_calculated', '{no}'));
+ $this->repeat_elements($repeated, $repeatsatstart, array(), 'nounits', 'addunits', 2, get_string('addmoreunitblanks', 'qtype_calculated', '{no}'));
$firstunit = $mform->getElement('multiplier[0]');
$firstunit->freeze();
}
$repeatsatstart = (QUESTION_NUMANS_START > ($countsubquestions + QUESTION_NUMANS_ADD))?
QUESTION_NUMANS_START : ($countsubquestions + QUESTION_NUMANS_ADD);
- $repeatedoptions = array();
- $repeatedoptions['subanswer']['type'] = PARAM_TEXT;
- $repeatedoptions['subquestion']['type'] = PARAM_TEXT;
+ $mform->setType('subanswer', PARAM_TEXT);
+ $mform->setType('subquestion', PARAM_TEXT);
- $this->repeat_elements($repeated, $repeatsatstart, $repeatedoptions, 'noanswers', 'addanswers', QUESTION_NUMANS_ADD, get_string('addmoreqblanks', 'qtype_match'));
+ $this->repeat_elements($repeated, $repeatsatstart, array(), 'noanswers', 'addanswers', QUESTION_NUMANS_ADD, get_string('addmoreqblanks', 'qtype_match'));
}
$repeatsatstart = (QUESTION_NUMANS_START > ($countanswers + QUESTION_NUMANS_ADD))?
QUESTION_NUMANS_START : ($countanswers + QUESTION_NUMANS_ADD);
$repeatedoptions = array();
- $repeatedoptions['answer']['type'] = PARAM_NOTAGS;//text with no multilang support
$repeatedoptions['fraction']['default'] = 0;
+ $mform->setType('answer', PARAM_NOTAGS);
$this->repeat_elements($repeated, $repeatsatstart, $repeatedoptions, 'noanswers', 'addanswers', QUESTION_NUMANS_ADD, get_string('addmorechoiceblanks', 'qtype_multichoice'));
}
$repeatsatstart = (QUESTION_NUMANS_START > ($countanswers + QUESTION_NUMANS_ADD))?
QUESTION_NUMANS_START : ($countanswers + QUESTION_NUMANS_ADD);
$repeatedoptions = array();
- $repeatedoptions['answer']['type'] = PARAM_NOTAGS;//text with no multilang support
$repeatedoptions['fraction']['default'] = 0;
+ $mform->setType('answer', PARAM_NOTAGS);
$this->repeat_elements($repeated, $repeatsatstart, $repeatedoptions, 'noanswers', 'addanswers', QUESTION_NUMANS_ADD, get_string('addmorechoiceblanks', 'qtype_multichoice'));
$mform->addElement('header', 'overallfeedbackhdr', get_string('overallfeedback', 'qtype_multichoice'));
$repeated[] =& $mform->createElement('header', 'answerhdr', get_string('answerno', 'qtype_numerical', '{no}'));
$repeated[] =& $mform->createElement('text', 'answer', get_string('answer', 'quiz'));
- $repeatedoptions['answer']['type'] = PARAM_NUMBER;
+ $mform->setType('answer', PARAM_NUMBER);
$repeated[] =& $mform->createElement('text', 'tolerance', get_string('acceptederror', 'quiz'));
- $repeatedoptions['tolerance']['type'] = PARAM_NUMBER;
+ $mform->setType('tolerance', PARAM_NUMBER);
$repeated[] =& $mform->createElement('select', 'fraction', get_string('grade'), $gradeoptions);
$repeatedoptions['fraction']['default'] = 0;
$repeated[] =& $mform->createElement('htmleditor', 'feedback', get_string('feedback', 'quiz'));
- $repeatedoptions['feedback']['type'] = PARAM_RAW;
+ $mform->setType('feedback', PARAM_RAW);
if (isset($this->question->options)){
//------------------------------------------------------------------------------------------
$repeated = array();
- $repeatedoptions = array();
$repeated[] =& $mform->createElement('header', 'unithdr', get_string('unithdr', 'qtype_numerical', '{no}'));
$repeated[] =& $mform->createElement('text', 'unit', get_string('unit', 'quiz'));
- $repeatedoptions['unit']['type'] = PARAM_NOTAGS;
+ $mform->setType('unit', PARAM_NOTAGS);
$repeated[] =& $mform->createElement('text', 'multiplier', get_string('multiplier', 'quiz'));
- $repeatedoptions['multiplier']['type'] = PARAM_NUMBER;
+ $mform->setType('multiplier', PARAM_NOTAGS);
if (isset($this->question->options)){
$countunits = count($this->question->options->units);
$countunits = 0;
}
$repeatsatstart = $countunits + 2;
- $this->repeat_elements($repeated, $repeatsatstart, $repeatedoptions, 'nounits', 'addunits', 2, get_string('addmoreunitblanks', 'qtype_numerical'));
+ $this->repeat_elements($repeated, $repeatsatstart, array(), 'nounits', 'addunits', 2, get_string('addmoreunitblanks', 'qtype_numerical'));
$firstunit = $mform->getElement('multiplier[0]');
$firstunit->freeze();
$repeatsatstart = (QUESTION_NUMANS_START > ($countanswers + QUESTION_NUMANS_ADD))?
QUESTION_NUMANS_START : ($countanswers + QUESTION_NUMANS_ADD);
$repeatedoptions = array();
- $repeatedoptions['answer']['type'] = PARAM_TEXT;
+ $mform->setType('answer', PARAM_NOTAGS);
$repeatedoptions['fraction']['default'] = 0;
$this->repeat_elements($repeated, $repeatsatstart, $repeatedoptions, 'noanswers', 'addanswers', QUESTION_NUMANS_ADD, get_string('addmoreanswerblanks', 'qtype_shortanswer'));