From: jamiesensei Date: Sun, 7 Jan 2007 12:46:47 +0000 (+0000) Subject: various formslib work including bug fixes for MDL-8039 id attribute collision between... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=271ffe3f254ef814fd79a133c7fedf5fb600468e;p=moodle.git various formslib work including bug fixes for MDL-8039 id attribute collision between forms and page ids. Also added editor helpbutton. This is a fix for MDL-6941 need the ability to associate several helptopics with htmleditor. Also started on converting forms for question types to formslib. --- diff --git a/course/import/groups/import_form.php b/course/import/groups/import_form.php index 10c1b07a41..8391f7fd2e 100755 --- a/course/import/groups/import_form.php +++ b/course/import/groups/import_form.php @@ -12,7 +12,7 @@ class course_import_groups_form extends moodleform { $strimportgroups = get_string("importgroups"); $this->set_upload_manager(new upload_manager('userfile', true, false, '', false, $maxuploadsize, true, true)); - $this->set_max_file_size('', $maxuploadsize); + //$this->set_max_file_size('', $maxuploadsize); $mform->addElement('header', 'general', '');//fill in the data depending on page params //later using set_defaults diff --git a/lang/en_utf8/qtype_match.php b/lang/en_utf8/qtype_match.php new file mode 100644 index 0000000000..203cb0fa54 --- /dev/null +++ b/lang/en_utf8/qtype_match.php @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/lang/en_utf8/qtype_multichoice.php b/lang/en_utf8/qtype_multichoice.php index ab23104a5e..7b04cd2a1b 100644 --- a/lang/en_utf8/qtype_multichoice.php +++ b/lang/en_utf8/qtype_multichoice.php @@ -1,22 +1,27 @@ -Instead, they add up to $a%%
Do you want to go back and fix this question?'; $string['fractionsnomax'] = 'One of the answers should be 100%%, so that it is
possible to get a full grade for this question.
Do you want to go back and fix this question?'; +$string['incorrectfeedback'] = 'For any incorrect answer'; $string['notenoughanswers'] = 'This type of question requires at least $a answers'; +$string['overallfeedback'] = 'Overall Feedback'; $string['overallcorrectfeedback'] = 'Feedback for any correct answer'; $string['overallincorrectfeedback'] = 'Feedback for any incorrect answer'; $string['overallpartiallycorrectfeedback'] = 'Feedback for any partially correct answer'; +$string['partiallycorrectfeedback'] = 'For any partially correct answer'; $string['shuffleanswers'] = 'Shuffle answers'; $string['singleanswer'] = 'Choose one answer.'; diff --git a/lang/en_utf8/qtype_shortanswer.php b/lang/en_utf8/qtype_shortanswer.php new file mode 100644 index 0000000000..f79f8cd0c9 --- /dev/null +++ b/lang/en_utf8/qtype_shortanswer.php @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/lib/form/editorhelp.php b/lib/form/editorhelp.php index 1f82f57652..2a43afa172 100644 --- a/lib/form/editorhelp.php +++ b/lib/form/editorhelp.php @@ -35,7 +35,7 @@ for ($i=1; ; $i++){ $title = optional_param("title$i", '', PARAM_NOTAGS); $module = optional_param("module$i", 'moodle', PARAM_ALPHAEXT); $func[$i] = 'helpbutton'; - $topics[$i] = array($keyword, $title, $module); + $topics[$i] = helplink($keyword, $title, $module); } } diff --git a/lib/formslib.php b/lib/formslib.php index 09962abd54..fe6b1e8a12 100644 --- a/lib/formslib.php +++ b/lib/formslib.php @@ -446,11 +446,15 @@ class moodleform { * @param string $repeathiddenname name for hidden element storing no of repeats in this form * @param string $addfieldsname name for button to add more fields * @param int $addfieldsno how many fields to add at a time - * @param array $addstring array of params for get_string for name of button, $a is no of fields that - * will be added. + * @param string $addstring name of button, {no} is replaced by no of blanks that will be added. * @return int no of repeats of element in this page */ - function repeat_elements($elementobjs, $repeats, $options, $repeathiddenname, $addfieldsname, $addfieldsno=5, $addstring=array('addfields', 'form')){ + function repeat_elements($elementobjs, $repeats, $options, $repeathiddenname, $addfieldsname, $addfieldsno=5, $addstring=null){ + if ($addstring===null){ + $addstring = get_string('addfields', 'form', $addfieldsno); + } else { + $addstring = str_ireplace('{no}', $addfieldsno, $addstring); + } $repeats = optional_param($repeathiddenname, $repeats, PARAM_INT); $addfields = optional_param($addfieldsname, '', PARAM_TEXT); if (!empty($addfields)){ @@ -463,12 +467,16 @@ class moodleform { $mform->setConstants(array($repeathiddenname=>$repeats)); for ($i=0; $i<$repeats; $i++) { foreach ($elementobjs as $elementobj){ - $elementclone=clone($elementobj); + $elementclone = clone($elementobj); $name=$elementclone->getName(); $elementclone->setName($name."[$i]"); if (is_a($elementclone, 'HTML_QuickForm_header')){ $value=$elementclone->_text; - $elementclone->setValue($value.' '.($i+1)); + $elementclone->setValue(str_replace('{no}', ($i+1), $value)); + + } else { + $value=$elementclone->getLabel(); + $elementclone->setLabel(str_replace('{no}', ($i+1), $value)); } $mform->addElement($elementclone); @@ -503,7 +511,7 @@ class moodleform { } } } - $mform->addElement('submit', $addfieldsname, get_string('addfields', 'form', $addfieldsno)); + $mform->addElement('submit', $addfieldsname, $addstring); $mform->closeHeaderBefore($addfieldsname); @@ -597,12 +605,14 @@ class MoodleQuickForm extends HTML_QuickForm_DHTMLRulesTableless { */ function MoodleQuickForm($formName, $method, $action, $target='', $attributes=null){ global $CFG; + static $formcounter = 1; HTML_Common::HTML_Common($attributes); $target = empty($target) ? array() : array('target' => $target); $this->_formName = $formName; //no 'name' atttribute for form in xhtml strict : - $attributes = array('action'=>$action, 'method'=>$method, 'id'=>strtr($formName, '_', '-')) + $target; + $attributes = array('action'=>$action, 'method'=>$method, 'id'=>'mform'.$formcounter) + $target; + $formcounter++; $this->updateAttributes($attributes); //this is custom stuff for Moodle : @@ -1127,7 +1137,7 @@ function validate_' . $this->_formName . '(frm) { function getLockOptionEndScript(){ $js = '