From 947d3349aba8ef816c4844a0f1a37c667caa74bc Mon Sep 17 00:00:00 2001 From: tjhunt Date: Tue, 9 Oct 2007 15:45:11 +0000 Subject: [PATCH] MDL-9076 - Move the 'Add 3 more overall feedbacks' button inside that group of elements on the quiz settings form. To make this possible, I added an extra argument to the repeat_elements method, which other people may find helpful on other forms. backported from HEAD. --- lang/en_utf8/quiz.php | 1 + lib/formslib.php | 8 ++++++-- mod/quiz/mod_form.php | 3 ++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lang/en_utf8/quiz.php b/lang/en_utf8/quiz.php index c7fafe5129e..96002c6040f 100644 --- a/lang/en_utf8/quiz.php +++ b/lang/en_utf8/quiz.php @@ -10,6 +10,7 @@ $string['action'] = 'Action'; $string['adaptive'] = 'Adaptive mode'; $string['addcategory'] = 'Add category'; $string['addingquestions'] = 'This side of the page is where you manage your database of questions. Questions are stored in categories to help you keep them organised, and can be used by any quiz in your course or even other courses if you choose to \'publish\' them.

After you select or create a question category you will be able to create or edit questions. You can select any of these questions to add to your quiz over on the other side of this page.'; +$string['addmoreoverallfeedbacks'] = 'Add {no} more feedback fields'; $string['addquestions'] = 'Add questions'; $string['addquestionstoquiz'] = 'Add questions to current quiz'; $string['addrandom'] = 'Add $a random questions'; diff --git a/lib/formslib.php b/lib/formslib.php index 8c4a78de719..a925fd75198 100644 --- a/lib/formslib.php +++ b/lib/formslib.php @@ -446,9 +446,11 @@ class moodleform { * @param string $addfieldsname name for button to add more fields * @param int $addfieldsno how many fields to add at a time * @param string $addstring name of button, {no} is replaced by no of blanks that will be added. + * @param boolean $addbuttoninside if true, don't call closeHeaderBefore($addfieldsname). Default false. * @return int no of repeats of element in this page */ - function repeat_elements($elementobjs, $repeats, $options, $repeathiddenname, $addfieldsname, $addfieldsno=5, $addstring=null){ + function repeat_elements($elementobjs, $repeats, $options, $repeathiddenname, + $addfieldsname, $addfieldsno=5, $addstring=null, $addbuttoninside=false){ if ($addstring===null){ $addstring = get_string('addfields', 'form', $addfieldsno); } else { @@ -520,7 +522,9 @@ class moodleform { } $mform->addElement('submit', $addfieldsname, $addstring); - $mform->closeHeaderBefore($addfieldsname); + if (!$addbuttoninside) { + $mform->closeHeaderBefore($addfieldsname); + } return $repeats; } diff --git a/mod/quiz/mod_form.php b/mod/quiz/mod_form.php index 0ae840a22d1..515346f3f1e 100644 --- a/mod/quiz/mod_form.php +++ b/mod/quiz/mod_form.php @@ -227,7 +227,8 @@ class mod_quiz_mod_form extends moodleform_mod { $mform->setType('feedbackboundaries', PARAM_NOTAGS); $nextel=$this->repeat_elements($repeatarray, $numfeedbacks-1, - array(), 'boundary_repeats', 'boundary_add_fields', 3); + array(), 'boundary_repeats', 'boundary_add_fields', 3, + get_string('addmoreoverallfeedbacks', 'quiz'), true); //put some extra elements in before the button $insertEl = &MoodleQuickForm::createElement('text', "feedbacktext[$nextel]", get_string('feedback', 'quiz'), array('size' => 50));