2 require_once ($CFG->dirroot
.'/course/moodleform_mod.php');
4 require_once("$CFG->dirroot/mod/quiz/locallib.php");
6 class mod_quiz_mod_form
extends moodleform_mod
{
9 function definition() {
12 $mform =& $this->_form
;
14 //-------------------------------------------------------------------------------
15 $mform->addElement('header', 'general', get_string('general', 'form'));
17 $mform->addElement('text', 'name', get_string('name'), array('size'=>'64'));
18 if (!empty($CFG->formatstringstriptags
)) {
19 $mform->setType('name', PARAM_TEXT
);
21 $mform->setType('name', PARAM_CLEAN
);
23 $mform->addRule('name', null, 'required', null, 'client');
25 $mform->addElement('htmleditor', 'intro', get_string("introduction", "quiz"));
26 $mform->setType('intro', PARAM_RAW
);
27 $mform->setHelpButton('intro', array('richtext', get_string('helprichtext')));
29 //-------------------------------------------------------------------------------
30 $mform->addElement('header', 'timinghdr', get_string('timing', 'form'));
31 $mform->addElement('date_time_selector', 'timeopen', get_string('quizopen', 'quiz'), array('optional'=>true));
32 $mform->setHelpButton('timeopen', array('timeopen', get_string('quizopen', 'quiz'), 'quiz'));
34 $mform->addElement('date_time_selector', 'timeclose', get_string('quizclose', 'quiz'), array('optional'=>true));
35 $mform->setHelpButton('timeclose', array('timeopen', get_string('quizclose', 'quiz'), 'quiz'));
38 $timelimitgrp=array();
39 $timelimitgrp[] = &$mform->createElement('text', 'timelimit');
40 $timelimitgrp[] = &$mform->createElement('checkbox', 'timelimitenable', '', get_string('enable'));
41 $mform->addGroup($timelimitgrp, 'timelimitgrp', get_string('timelimitmin', 'quiz'), array(' '), false);
42 $mform->setType('timelimit', PARAM_TEXT
);
43 $timelimitgrprules = array();
44 $timelimitgrprules['timelimit'][] = array(null, 'numeric', null, 'client');
45 $mform->addGroupRule('timelimitgrp', $timelimitgrprules);
46 $mform->disabledIf('timelimitgrp', 'timelimitenable');
47 $mform->setAdvanced('timelimitgrp', $CFG->quiz_fix_timelimit
);
48 $mform->setHelpButton('timelimitgrp', array("timelimit", get_string("quiztimer","quiz"), "quiz"));
49 $mform->setDefault('timelimit', $CFG->quiz_timelimit
);
50 $mform->setDefault('timelimitenable', !empty($CFG->quiz_timelimit
));
53 //enforced time delay between quiz attempts add-on
54 $timedelayoptions = array();
55 $timedelayoptions[0] = get_string('none');
56 $timedelayoptions[1800] = get_string('numminutes', '', 30);
57 $timedelayoptions[3600] = get_string('numminutes', '', 60);
58 for($i=2; $i<=23; $i++
) {
60 $timedelayoptions[$seconds] = get_string('numhours', '', $i);
62 $timedelayoptions[86400] = get_string('numhours', '', 24);
63 for($i=2; $i<=7; $i++
) {
65 $timedelayoptions[$seconds] = get_string('numdays', '', $i);
67 $mform->addElement('select', 'delay1', get_string("delay1", "quiz"), $timedelayoptions);
68 $mform->setHelpButton('delay1', array("timedelay1", get_string("delay1", "quiz"), "quiz"));
69 $mform->setAdvanced('delay1', $CFG->quiz_fix_delay1
);
70 $mform->setDefault('delay1', $CFG->quiz_delay1
);
72 $mform->addElement('select', 'delay2', get_string("delay2", "quiz"), $timedelayoptions);
73 $mform->setHelpButton('delay2', array("timedelay2", get_string("delay2", "quiz"), "quiz"));
74 $mform->setAdvanced('delay2', $CFG->quiz_fix_delay2
);
75 $mform->setDefault('delay2', $CFG->quiz_delay2
);
77 //-------------------------------------------------------------------------------
78 $mform->addElement('header', 'displayhdr', get_string('display', 'form'));
80 for ($i = 0; $i <= 50; ++
$i) {
83 $perpage[0] = get_string('allinone', 'quiz');
84 $mform->addElement('select', 'questionsperpage', get_string('questionsperpage', 'quiz'), $perpage);
85 $mform->setHelpButton('questionsperpage', array('questionsperpage', get_string('questionsperpage', 'quiz'), 'quiz'));
86 $mform->setAdvanced('questionsperpage', $CFG->quiz_fix_questionsperpage
);
87 $mform->setDefault('questionsperpage', $CFG->quiz_questionsperpage
);
89 $mform->addElement('selectyesno', 'shufflequestions', get_string("shufflequestions", "quiz"));
90 $mform->setHelpButton('shufflequestions', array("shufflequestions", get_string("shufflequestions","quiz"), "quiz"));
91 $mform->setAdvanced('shufflequestions', $CFG->quiz_fix_shufflequestions
);
92 $mform->setDefault('shufflequestions', $CFG->quiz_shufflequestions
);
94 $mform->addElement('selectyesno', 'shuffleanswers', get_string("shufflewithin", "quiz"));
95 $mform->setHelpButton('shuffleanswers', array("shufflewithin", get_string("shufflewithin","quiz"), "quiz"));
96 $mform->setAdvanced('shuffleanswers', $CFG->quiz_fix_shuffleanswers
);
97 $mform->setDefault('shuffleanswers', $CFG->quiz_shuffleanswers
);
99 //-------------------------------------------------------------------------------
100 $mform->addElement('header', 'attemptshdr', get_string('attempts', 'quiz'));
101 $attemptoptions = array('0' => get_string('unlimited'));
102 for ($i = 1; $i <= 10; $i++
) {
103 $attemptoptions[$i] = $i;
105 $mform->addElement('select', 'attempts', get_string("attemptsallowed", "quiz"), $attemptoptions);
106 $mform->setHelpButton('attempts', array("attempts", get_string("attemptsallowed","quiz"), "quiz"));
107 $mform->setAdvanced('attempts', $CFG->quiz_fix_attempts
);
108 $mform->setDefault('attempts', $CFG->quiz_attempts
);
110 $mform->addElement('selectyesno', 'attemptonlast', get_string("eachattemptbuildsonthelast", "quiz"));
111 $mform->setHelpButton('attemptonlast', array("repeatattempts", get_string("eachattemptbuildsonthelast", "quiz"), "quiz"));
112 $mform->setAdvanced('attemptonlast', $CFG->quiz_fix_attemptonlast
);
113 $mform->setDefault('attemptonlast', $CFG->quiz_attemptonlast
);
115 $mform->addElement('selectyesno', 'adaptive', get_string("adaptive", "quiz"));
116 $mform->setHelpButton('adaptive', array("adaptive", get_string("adaptive","quiz"), "quiz"));
117 $mform->setAdvanced('adaptive', $CFG->quiz_fix_adaptive
);
118 $mform->setDefault('adaptive', $CFG->quiz_optionflags
& QUESTION_ADAPTIVE
);
121 //-------------------------------------------------------------------------------
122 $mform->addElement('header', 'gradeshdr', get_string('grades', 'grades'));
123 $mform->addElement('select', 'grademethod', get_string("grademethod", "quiz"), quiz_get_grading_options());
124 $mform->setHelpButton('grademethod', array("grademethod", get_string("grademethod","quiz"), "quiz"));
125 $mform->setAdvanced('grademethod', $CFG->quiz_fix_grademethod
);
126 $mform->setDefault('grademethod', $CFG->quiz_grademethod
);
128 $mform->addElement('selectyesno', 'penaltyscheme', get_string("penaltyscheme", "quiz"));
129 $mform->setHelpButton('penaltyscheme', array("penaltyscheme", get_string("penaltyscheme","quiz"), "quiz"));
130 $mform->setAdvanced('penaltyscheme', $CFG->quiz_fix_penaltyscheme
);
131 $mform->setDefault('penaltyscheme', $CFG->quiz_penaltyscheme
);
138 $mform->addElement('select', 'decimalpoints', get_string("decimaldigits", "quiz"), $options);
139 $mform->setHelpButton('decimalpoints', array("decimalpoints", get_string("decimaldigits","quiz"), "quiz"));
140 $mform->setAdvanced('decimalpoints', $CFG->quiz_fix_decimalpoints
);
141 $mform->setDefault('decimalpoints', $CFG->quiz_decimalpoints
);
143 //-------------------------------------------------------------------------------
144 $mform->addElement('header', 'reviewoptionshdr', get_string('reviewoptionsheading', 'quiz'));
145 $mform->setHelpButton('reviewoptionshdr', array('reviewoptions', get_string('reviewoptionsheading','quiz'), 'quiz'));
146 $mform->setAdvanced('reviewoptionshdr', $CFG->quiz_fix_review
);
148 $immediatelyoptionsgrp=array();
149 $immediatelyoptionsgrp[] = &$mform->createElement('checkbox', 'responsesimmediately', '', get_string('responses', 'quiz'));
150 $immediatelyoptionsgrp[] = &$mform->createElement('checkbox', 'answersimmediately', '', get_string('answers', 'quiz'));
151 $immediatelyoptionsgrp[] = &$mform->createElement('checkbox', 'feedbackimmediately', '', get_string('feedback', 'quiz'));
152 $immediatelyoptionsgrp[] = &$mform->createElement('checkbox', 'generalfeedbackimmediately', '', get_string('generalfeedback', 'quiz'));
153 $immediatelyoptionsgrp[] = &$mform->createElement('checkbox', 'scoreimmediately', '', get_string('scores', 'quiz'));
154 $immediatelyoptionsgrp[] = &$mform->createElement('checkbox', 'overallfeedbackimmediately', '', get_string('overallfeedback', 'quiz'));
155 $mform->addGroup($immediatelyoptionsgrp, 'immediatelyoptionsgrp', get_string("reviewimmediately", "quiz"), null, false);
156 $mform->setDefault('responsesimmediately', $CFG->quiz_review
& QUIZ_REVIEW_RESPONSES
& QUIZ_REVIEW_IMMEDIATELY
);
157 $mform->setDefault('answersimmediately', $CFG->quiz_review
& QUIZ_REVIEW_ANSWERS
& QUIZ_REVIEW_IMMEDIATELY
);
158 $mform->setDefault('feedbackimmediately', $CFG->quiz_review
& QUIZ_REVIEW_FEEDBACK
& QUIZ_REVIEW_IMMEDIATELY
);
159 $mform->setDefault('generalfeedbackimmediately', $CFG->quiz_review
& QUIZ_REVIEW_GENERALFEEDBACK
& QUIZ_REVIEW_IMMEDIATELY
);
160 $mform->setDefault('scoreimmediately', $CFG->quiz_review
& QUIZ_REVIEW_SCORES
& QUIZ_REVIEW_IMMEDIATELY
);
161 $mform->setDefault('overallfeedbackimmediately', $CFG->quiz_review
& QUIZ_REVIEW_OVERALLFEEDBACK
& QUIZ_REVIEW_IMMEDIATELY
);
163 $openoptionsgrp=array();
164 $openoptionsgrp[] = &$mform->createElement('checkbox', 'responsesopen', '', get_string('responses', 'quiz'));
165 $openoptionsgrp[] = &$mform->createElement('checkbox', 'answersopen', '', get_string('answers', 'quiz'));
166 $openoptionsgrp[] = &$mform->createElement('checkbox', 'feedbackopen', '', get_string('feedback', 'quiz'));
167 $openoptionsgrp[] = &$mform->createElement('checkbox', 'generalfeedbackopen', '', get_string('generalfeedback', 'quiz'));
168 $openoptionsgrp[] = &$mform->createElement('checkbox', 'scoreopen', '', get_string('scores', 'quiz'));
169 $openoptionsgrp[] = &$mform->createElement('checkbox', 'overallfeedbackopen', '', get_string('overallfeedback', 'quiz'));
170 $mform->addGroup($openoptionsgrp, 'openoptionsgrp', get_string("reviewopen", "quiz"), array(' '), false);
171 $mform->setDefault('responsesopen', $CFG->quiz_review
& QUIZ_REVIEW_RESPONSES
& QUIZ_REVIEW_OPEN
);
172 $mform->setDefault('answersopen', $CFG->quiz_review
& QUIZ_REVIEW_ANSWERS
& QUIZ_REVIEW_OPEN
);
173 $mform->setDefault('feedbackopen', $CFG->quiz_review
& QUIZ_REVIEW_FEEDBACK
& QUIZ_REVIEW_OPEN
);
174 $mform->setDefault('generalfeedbackopen', $CFG->quiz_review
& QUIZ_REVIEW_GENERALFEEDBACK
& QUIZ_REVIEW_OPEN
);
175 $mform->setDefault('scoreopen', $CFG->quiz_review
& QUIZ_REVIEW_SCORES
& QUIZ_REVIEW_OPEN
);
176 $mform->setDefault('overallfeedbackopen', $CFG->quiz_review
& QUIZ_REVIEW_OVERALLFEEDBACK
& QUIZ_REVIEW_OPEN
);
179 $closedoptionsgrp=array();
180 $closedoptionsgrp[] = &$mform->createElement('checkbox', 'responsesclosed', '', get_string('responses', 'quiz'));
181 $closedoptionsgrp[] = &$mform->createElement('checkbox', 'answersclosed', '', get_string('answers', 'quiz'));
182 $closedoptionsgrp[] = &$mform->createElement('checkbox', 'feedbackclosed', '', get_string('feedback', 'quiz'));
183 $closedoptionsgrp[] = &$mform->createElement('checkbox', 'generalfeedbackclosed', '', get_string('generalfeedback', 'quiz'));
184 $closedoptionsgrp[] = &$mform->createElement('checkbox', 'scoreclosed', '', get_string('scores', 'quiz'));
185 $closedoptionsgrp[] = &$mform->createElement('checkbox', 'overallfeedbackclosed', '', get_string('overallfeedback', 'quiz'));
186 $mform->addGroup($closedoptionsgrp, 'closedoptionsgrp', get_string("reviewclosed", "quiz"), array(' '), false);
187 $mform->setDefault('responsesclosed', $CFG->quiz_review
& QUIZ_REVIEW_RESPONSES
& QUIZ_REVIEW_CLOSED
);
188 $mform->setDefault('answersclosed', $CFG->quiz_review
& QUIZ_REVIEW_ANSWERS
& QUIZ_REVIEW_CLOSED
);
189 $mform->setDefault('feedbackclosed', $CFG->quiz_review
& QUIZ_REVIEW_FEEDBACK
& QUIZ_REVIEW_CLOSED
);
190 $mform->setDefault('generalfeedbackclosed', $CFG->quiz_review
& QUIZ_REVIEW_GENERALFEEDBACK
& QUIZ_REVIEW_CLOSED
);
191 $mform->setDefault('scoreclosed', $CFG->quiz_review
& QUIZ_REVIEW_SCORES
& QUIZ_REVIEW_CLOSED
);
192 $mform->setDefault('overallfeedbackclosed', $CFG->quiz_review
& QUIZ_REVIEW_OVERALLFEEDBACK
& QUIZ_REVIEW_CLOSED
);
194 //-------------------------------------------------------------------------------
195 $mform->addElement('header', 'security', get_string('security', 'form'));
198 0 => get_string('none', 'quiz'),
199 1 => get_string('popupwithjavascriptsupport', 'quiz'));
200 if (!empty($CFG->enablesafebrowserintegration
)) {
201 $options[2] = get_string('requiresafeexambrowser', 'quiz');
203 $mform->addElement('select', 'popup', get_string('browsersecurity', 'quiz'), $options);
204 $mform->setHelpButton('popup', array('browsersecurity', get_string('browsersecurity', 'quiz'), 'quiz'));
205 $mform->setAdvanced('popup', $CFG->quiz_fix_popup
);
206 $mform->setDefault('popup', $CFG->quiz_popup
);
208 $mform->addElement('passwordunmask', 'quizpassword', get_string("requirepassword", "quiz"));
209 $mform->setType('quizpassword', PARAM_TEXT
);
210 $mform->setHelpButton('quizpassword', array("requirepassword", get_string("requirepassword", "quiz"), "quiz"));
211 $mform->setAdvanced('quizpassword', $CFG->quiz_fix_password
);
212 $mform->setDefault('quizpassword', $CFG->quiz_password
);
214 $mform->addElement('text', 'subnet', get_string("requiresubnet", "quiz"));
215 $mform->setType('subnet', PARAM_TEXT
);
216 $mform->setHelpButton('subnet', array("requiresubnet", get_string("requiresubnet", "quiz"), "quiz"));
217 $mform->setAdvanced('subnet', $CFG->quiz_fix_subnet
);
218 $mform->setDefault('subnet', $CFG->quiz_subnet
);
220 //-------------------------------------------------------------------------------
221 $features = new stdClass
;
222 $features->groups
= true;
223 $features->groupings
= true;
224 $features->groupmembersonly
= true;
225 $this->standard_coursemodule_elements($features);
226 //-------------------------------------------------------------------------------
227 $mform->addElement('header', 'overallfeedbackhdr', get_string('overallfeedback', 'quiz'));
228 $mform->setHelpButton('overallfeedbackhdr', array('overallfeedback', get_string('overallfeedback', 'quiz'), 'quiz'));
230 $mform->addElement('hidden', 'grade', $CFG->quiz_maximumgrade
);
231 $mform->setType('grade', PARAM_RAW
);
232 if (empty($this->_cm
)) {
233 $needwarning = $CFG->quiz_maximumgrade
== 0;
235 $quizgrade = get_field('quiz', 'grade', 'id', $this->_instance
);
236 $needwarning = $quizgrade == 0;
239 $mform->addElement('static', 'nogradewarning', '', get_string('nogradewarning', 'quiz'));
242 $mform->addElement('static', 'gradeboundarystatic1', get_string('gradeboundary', 'quiz'), '100%');
244 $repeatarray = array();
245 $repeatarray[] = &MoodleQuickForm
::createElement('text', 'feedbacktext', get_string('feedback', 'quiz'), array('size' => 50));
246 $mform->setType('feedbacktext', PARAM_RAW
);
247 $repeatarray[] = &MoodleQuickForm
::createElement('text', 'feedbackboundaries', get_string('gradeboundary', 'quiz'), array('size' => 10));
248 $mform->setType('feedbackboundaries', PARAM_NOTAGS
);
250 if (!empty($this->_instance
)) {
251 $this->_feedbacks
= get_records('quiz_feedback', 'quizid', $this->_instance
, 'mingrade DESC');
253 $this->_feedbacks
= array();
255 $numfeedbacks = max(count($this->_feedbacks
) * 1.5, 5);
257 $nextel = $this->repeat_elements($repeatarray, $numfeedbacks - 1,
258 array(), 'boundary_repeats', 'boundary_add_fields', 3,
259 get_string('addmoreoverallfeedbacks', 'quiz'), true);
261 // Put some extra elements in before the button
262 $insertEl = &MoodleQuickForm
::createElement('text', "feedbacktext[$nextel]", get_string('feedback', 'quiz'), array('size' => 50));
263 $mform->insertElementBefore($insertEl, 'boundary_add_fields');
265 $insertEl = &MoodleQuickForm
::createElement('static', 'gradeboundarystatic2', get_string('gradeboundary', 'quiz'), '0%');
266 $mform->insertElementBefore($insertEl, 'boundary_add_fields');
268 // Add the disabledif rules. We cannot do this using the $repeatoptions parameter to
269 // repeat_elements becuase we don't want to dissable the first feedbacktext.
270 for ($i = 0; $i < $nextel; $i++
) {
271 $mform->disabledIf('feedbackboundaries[' . $i . ']', 'grade', 'eq', 0);
272 $mform->disabledIf('feedbacktext[' . ($i +
1) . ']', 'grade', 'eq', 0);
275 //-------------------------------------------------------------------------------
277 $this->add_action_buttons();
280 function data_preprocessing(&$default_values){
281 if (count($this->_feedbacks
)) {
283 foreach ($this->_feedbacks
as $feedback){
284 $default_values['feedbacktext['.$key.']'] = $feedback->feedbacktext
;
285 if ($default_values['grade'] == 0) {
286 // When a quiz is un-graded, there can only be one lot of
287 // feedback. If the quiz previously had a maximum grade and
288 // several lots of feedback, we must now avoid putting text
289 // into input boxes that are disabled, but which the
290 // validation will insist are blank.
293 if ($feedback->mingrade
> 0) {
294 $default_values['feedbackboundaries['.$key.']'] = (100.0 * $feedback->mingrade
/ $default_values['grade']) . '%';
300 if (isset($default_values['timelimit'])) {
301 $default_values['timelimitenable'] = $default_values['timelimit'] > 0;
304 if (isset($default_values['review'])){
305 $review = (int)$default_values['review'];
306 unset($default_values['review']);
308 $default_values['responsesimmediately'] = $review & QUIZ_REVIEW_RESPONSES
& QUIZ_REVIEW_IMMEDIATELY
;
309 $default_values['answersimmediately'] = $review & QUIZ_REVIEW_ANSWERS
& QUIZ_REVIEW_IMMEDIATELY
;
310 $default_values['feedbackimmediately'] = $review & QUIZ_REVIEW_FEEDBACK
& QUIZ_REVIEW_IMMEDIATELY
;
311 $default_values['generalfeedbackimmediately'] = $review & QUIZ_REVIEW_GENERALFEEDBACK
& QUIZ_REVIEW_IMMEDIATELY
;
312 $default_values['scoreimmediately'] = $review & QUIZ_REVIEW_SCORES
& QUIZ_REVIEW_IMMEDIATELY
;
313 $default_values['overallfeedbackimmediately'] = $review & QUIZ_REVIEW_OVERALLFEEDBACK
& QUIZ_REVIEW_IMMEDIATELY
;
315 $default_values['responsesopen'] = $review & QUIZ_REVIEW_RESPONSES
& QUIZ_REVIEW_OPEN
;
316 $default_values['answersopen'] = $review & QUIZ_REVIEW_ANSWERS
& QUIZ_REVIEW_OPEN
;
317 $default_values['feedbackopen'] = $review & QUIZ_REVIEW_FEEDBACK
& QUIZ_REVIEW_OPEN
;
318 $default_values['generalfeedbackopen'] = $review & QUIZ_REVIEW_GENERALFEEDBACK
& QUIZ_REVIEW_OPEN
;
319 $default_values['scoreopen'] = $review & QUIZ_REVIEW_SCORES
& QUIZ_REVIEW_OPEN
;
320 $default_values['overallfeedbackopen'] = $review & QUIZ_REVIEW_OVERALLFEEDBACK
& QUIZ_REVIEW_OPEN
;
322 $default_values['responsesclosed'] = $review & QUIZ_REVIEW_RESPONSES
& QUIZ_REVIEW_CLOSED
;
323 $default_values['answersclosed'] = $review & QUIZ_REVIEW_ANSWERS
& QUIZ_REVIEW_CLOSED
;
324 $default_values['feedbackclosed'] = $review & QUIZ_REVIEW_FEEDBACK
& QUIZ_REVIEW_CLOSED
;
325 $default_values['generalfeedbackclosed'] = $review & QUIZ_REVIEW_GENERALFEEDBACK
& QUIZ_REVIEW_CLOSED
;
326 $default_values['scoreclosed'] = $review & QUIZ_REVIEW_SCORES
& QUIZ_REVIEW_CLOSED
;
327 $default_values['overallfeedbackclosed'] = $review & QUIZ_REVIEW_OVERALLFEEDBACK
& QUIZ_REVIEW_CLOSED
;
330 if (isset($default_values['optionflags'])){
331 $default_values['adaptive'] = $default_values['optionflags'] & QUESTION_ADAPTIVE
;
332 unset($default_values['optionflags']);
335 // Password field - different in form to stop browsers that remember passwords
337 if (isset($default_values['password'])) {
338 $default_values['quizpassword'] = $default_values['password'];
339 unset($default_values['password']);
343 function validation($data, $files) {
344 $errors = parent
::validation($data, $files);
346 // Check open and close times are consistent.
347 if ($data['timeopen'] != 0 && $data['timeclose'] != 0 && $data['timeclose'] < $data['timeopen']) {
348 $errors['timeclose'] = get_string('closebeforeopen', 'quiz');
351 // Check the boundary value is a number or a percentage, and in range.
353 while (!empty($data['feedbackboundaries'][$i] )) {
354 $boundary = trim($data['feedbackboundaries'][$i]);
355 if (strlen($boundary) > 0 && $boundary[strlen($boundary) - 1] == '%') {
356 $boundary = trim(substr($boundary, 0, -1));
357 if (is_numeric($boundary)) {
358 $boundary = $boundary * $data['grade'] / 100.0;
360 $errors["feedbackboundaries[$i]"] = get_string('feedbackerrorboundaryformat', 'quiz', $i +
1);
363 if (is_numeric($boundary) && $boundary <= 0 ||
$boundary >= $data['grade'] ) {
364 $errors["feedbackboundaries[$i]"] = get_string('feedbackerrorboundaryoutofrange', 'quiz', $i +
1);
366 if (is_numeric($boundary) && $i > 0 && $boundary >= $data['feedbackboundaries'][$i - 1]) {
367 $errors["feedbackboundaries[$i]"] = get_string('feedbackerrororder', 'quiz', $i +
1);
369 $data['feedbackboundaries'][$i] = $boundary;
374 // Check there is nothing in the remaining unused fields.
375 if (!empty($data['feedbackboundaries'])) {
376 for ($i = $numboundaries; $i < count($data['feedbackboundaries']); $i +
= 1) {
377 if (!empty($data['feedbackboundaries'][$i] ) && trim($data['feedbackboundaries'][$i] ) != '') {
378 $errors["feedbackboundaries[$i]"] = get_string('feedbackerrorjunkinboundary', 'quiz', $i +
1);
382 for ($i = $numboundaries +
1; $i < count($data['feedbacktext']); $i +
= 1) {
383 if (!empty($data['feedbacktext'][$i] ) && trim($data['feedbacktext'][$i] ) != '') {
384 $errors["feedbacktext[$i]"] = get_string('feedbackerrorjunkinfeedback', 'quiz', $i +
1);
388 if (count($errors) == 0) {