MDL-11517 reserved word MOD used in table alias in questions backup code
[moodle-pu.git] / mod / quiz / mod_form.php
blobff9b30047c3f66464ae5b6bb85466db909bc2a4c
1 <?php // $Id$
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 {
7 var $_feedbacks;
9 function definition() {
11 global $COURSE, $CFG;
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 $mform->setType('name', PARAM_TEXT);
19 $mform->addRule('name', null, 'required', null, 'client');
21 $mform->addElement('htmleditor', 'intro', get_string("introduction", "quiz"));
22 $mform->setType('intro', PARAM_RAW);
23 $mform->setHelpButton('intro', array('richtext', get_string('helprichtext')));
25 //-------------------------------------------------------------------------------
26 $mform->addElement('header', 'timinghdr', get_string('timing', 'form'));
27 $mform->addElement('date_time_selector', 'timeopen', get_string("quizopen", "quiz"), array('optional'=>true));
28 $mform->setHelpButton('timeopen', array('timeopen', get_string('quizopens', 'quiz'), 'quiz'));
30 $mform->addElement('date_time_selector', 'timeclose', get_string("quizcloses", "quiz"), array('optional'=>true));
31 $mform->setHelpButton('timeclose', array('timeopen', get_string('quizcloses', 'quiz'), 'quiz'));
34 $timelimitgrp=array();
35 $timelimitgrp[] = &$mform->createElement('text', 'timelimit');
36 $timelimitgrp[] = &$mform->createElement('checkbox', 'timelimitenable', '', get_string('enable'));
37 $mform->addGroup($timelimitgrp, 'timelimitgrp', get_string('timelimitmin', 'quiz'), array(' '), false);
38 $mform->setType('timelimit', PARAM_TEXT);
39 $timelimitgrprules = array();
40 $timelimitgrprules['timelimit'][] = array(null, 'numeric', null, 'client');
41 $mform->addGroupRule('timelimitgrp', $timelimitgrprules);
42 $mform->disabledIf('timelimitgrp', 'timelimitenable');
43 $mform->setAdvanced('timelimitgrp', $CFG->quiz_fix_timelimit);
44 $mform->setHelpButton('timelimitgrp', array("timelimit", get_string("quiztimer","quiz"), "quiz"));
45 $mform->setDefault('timelimit', $CFG->quiz_timelimit);
48 //enforced time delay between quiz attempts add-on
49 $timedelayoptions = array();
50 $timedelayoptions[0] = get_string('none');
51 $timedelayoptions[1800] = get_string('numminutes', '', 30);
52 $timedelayoptions[3600] = get_string('numminutes', '', 60);
53 for($i=2; $i<=23; $i++) {
54 $seconds = $i*3600;
55 $timedelayoptions[$seconds] = get_string('numhours', '', $i);
57 $timedelayoptions[86400] = get_string('numhours', '', 24);
58 for($i=2; $i<=7; $i++) {
59 $seconds = $i*86400;
60 $timedelayoptions[$seconds] = get_string('numdays', '', $i);
62 $mform->addElement('select', 'delay1', get_string("delay1", "quiz"), $timedelayoptions);
63 $mform->setHelpButton('delay1', array("timedelay1", get_string("delay1", "quiz"), "quiz"));
64 $mform->setAdvanced('delay1', $CFG->quiz_fix_delay1);
65 $mform->setDefault('delay1', $CFG->quiz_delay1);
67 $mform->addElement('select', 'delay2', get_string("delay2", "quiz"), $timedelayoptions);
68 $mform->setHelpButton('delay2', array("timedelay2", get_string("delay2", "quiz"), "quiz"));
69 $mform->setAdvanced('delay2', $CFG->quiz_fix_delay2);
70 $mform->setDefault('delay2', $CFG->quiz_delay2);
72 //-------------------------------------------------------------------------------
73 $mform->addElement('header', 'displayhdr', get_string('display', 'form'));
74 $perpage = array();
75 for ($i = 0; $i <= 50; ++$i) {
76 $perpage[$i] = $i;
78 $perpage[0] = get_string('allinone', 'quiz');
79 $mform->addElement('select', 'questionsperpage', get_string('questionsperpage', 'quiz'), $perpage);
80 $mform->setHelpButton('questionsperpage', array('questionsperpage', get_string('questionsperpage', 'quiz'), 'quiz'));
81 $mform->setAdvanced('questionsperpage', $CFG->quiz_fix_questionsperpage);
82 $mform->setDefault('questionsperpage', $CFG->quiz_questionsperpage);
84 $mform->addElement('selectyesno', 'shufflequestions', get_string("shufflequestions", "quiz"));
85 $mform->setHelpButton('shufflequestions', array("shufflequestions", get_string("shufflequestions","quiz"), "quiz"));
86 $mform->setAdvanced('shufflequestions', $CFG->quiz_fix_shufflequestions);
87 $mform->setDefault('shufflequestions', $CFG->quiz_shufflequestions);
89 $mform->addElement('selectyesno', 'shuffleanswers', get_string("shufflewithin", "quiz"));
90 $mform->setHelpButton('shuffleanswers', array("shufflewithin", get_string("shufflewithin","quiz"), "quiz"));
91 $mform->setAdvanced('shuffleanswers', $CFG->quiz_fix_shuffleanswers);
92 $mform->setDefault('shuffleanswers', $CFG->quiz_shuffleanswers);
94 //-------------------------------------------------------------------------------
95 $mform->addElement('header', 'attemptshdr', get_string('attempts', 'quiz'));
96 $attemptoptions = array();
97 $attemptoptions[0] = get_string("attemptsunlimited", "quiz");
98 $attemptoptions[1] = "1 ".moodle_strtolower(get_string("attempt", "quiz"));
99 for ($i=2;$i<=6;$i++) {
100 $attemptoptions[$i] = "$i ".moodle_strtolower(get_string("attempts", "quiz"));
102 $mform->addElement('select', 'attempts', get_string("attemptsallowed", "quiz"), $attemptoptions);
103 $mform->setHelpButton('attempts', array("attempts", get_string("attemptsallowed","quiz"), "quiz"));
104 $mform->setAdvanced('attempts', $CFG->quiz_fix_attempts);
105 $mform->setDefault('attempts', $CFG->quiz_attempts);
107 $mform->addElement('selectyesno', 'attemptonlast', get_string("eachattemptbuildsonthelast", "quiz"));
108 $mform->setHelpButton('attemptonlast', array("repeatattempts", get_string("eachattemptbuildsonthelast", "quiz"), "quiz"));
109 $mform->setAdvanced('attemptonlast', $CFG->quiz_fix_attemptonlast);
110 $mform->setDefault('attemptonlast', $CFG->quiz_attemptonlast);
112 $mform->addElement('selectyesno', 'adaptive', get_string("adaptive", "quiz"));
113 $mform->setHelpButton('adaptive', array("adaptive", get_string("adaptive","quiz"), "quiz"));
114 $mform->setAdvanced('adaptive', $CFG->quiz_fix_adaptive);
115 $mform->setDefault('adaptive', $CFG->quiz_optionflags & QUESTION_ADAPTIVE);
118 //-------------------------------------------------------------------------------
119 $mform->addElement('header', 'gradeshdr', get_string('grades', 'grades'));
120 $mform->addElement('select', 'grademethod', get_string("grademethod", "quiz"), quiz_get_grading_options());
121 $mform->setHelpButton('grademethod', array("grademethod", get_string("grademethod","quiz"), "quiz"));
122 $mform->setAdvanced('grademethod', $CFG->quiz_fix_grademethod);
123 $mform->setDefault('grademethod', $CFG->quiz_grademethod);
125 $mform->addElement('selectyesno', 'penaltyscheme', get_string("penaltyscheme", "quiz"));
126 $mform->setHelpButton('penaltyscheme', array("penaltyscheme", get_string("penaltyscheme","quiz"), "quiz"));
127 $mform->setAdvanced('penaltyscheme', $CFG->quiz_fix_penaltyscheme);
128 $mform->setDefault('penaltyscheme', $CFG->quiz_penaltyscheme);
130 $options = array(
131 0 => '0',
132 1 => '1',
133 2 => '2',
134 3 => '3');
135 $mform->addElement('select', 'decimalpoints', get_string("decimaldigits", "quiz"), $options);
136 $mform->setHelpButton('decimalpoints', array("decimalpoints", get_string("decimaldigits","quiz"), "quiz"));
137 $mform->setAdvanced('decimalpoints', $CFG->quiz_fix_decimalpoints);
138 $mform->setDefault('decimalpoints', $CFG->quiz_decimalpoints);
140 $mform->addElement('hidden', 'grade', $CFG->quiz_maximumgrade);
142 //-------------------------------------------------------------------------------
143 $mform->addElement('header', 'reviewoptionshdr', get_string("reviewoptions", "quiz"));
144 $mform->setHelpButton('reviewoptionshdr', array("review2", get_string("allowreview","quiz"), "quiz"));
145 $mform->setAdvanced('reviewoptionshdr', $CFG->quiz_fix_review);
147 $immediatelyoptionsgrp=array();
148 $immediatelyoptionsgrp[] = &$mform->createElement('checkbox', 'responsesimmediately', '', get_string('responses', 'quiz'));
149 $immediatelyoptionsgrp[] = &$mform->createElement('checkbox', 'answersimmediately', '', get_string('answers', 'quiz'));
150 $immediatelyoptionsgrp[] = &$mform->createElement('checkbox', 'feedbackimmediately', '', get_string('feedback', 'quiz'));
151 $immediatelyoptionsgrp[] = &$mform->createElement('checkbox', 'generalfeedbackimmediately', '', get_string('generalfeedback', 'quiz'));
152 $immediatelyoptionsgrp[] = &$mform->createElement('checkbox', 'scoreimmediately', '', get_string('scores', 'quiz'));
153 $immediatelyoptionsgrp[] = &$mform->createElement('checkbox', 'overallfeedbackimmediately', '', get_string('overallfeedback', 'quiz'));
154 $mform->addGroup($immediatelyoptionsgrp, 'immediatelyoptionsgrp', get_string("reviewimmediately", "quiz"), null, false);
155 $mform->setDefault('responsesimmediately', $CFG->quiz_review & QUIZ_REVIEW_RESPONSES & QUIZ_REVIEW_IMMEDIATELY);
156 $mform->setDefault('answersimmediately', $CFG->quiz_review & QUIZ_REVIEW_ANSWERS & QUIZ_REVIEW_IMMEDIATELY);
157 $mform->setDefault('feedbackimmediately', $CFG->quiz_review & QUIZ_REVIEW_FEEDBACK & QUIZ_REVIEW_IMMEDIATELY);
158 $mform->setDefault('generalfeedbackimmediately', $CFG->quiz_review & QUIZ_REVIEW_GENERALFEEDBACK & QUIZ_REVIEW_IMMEDIATELY);
159 $mform->setDefault('scoreimmediately', $CFG->quiz_review & QUIZ_REVIEW_SCORES & QUIZ_REVIEW_IMMEDIATELY);
160 $mform->setDefault('overallfeedbackimmediately', $CFG->quiz_review & QUIZ_REVIEW_OVERALLFEEDBACK & QUIZ_REVIEW_IMMEDIATELY);
162 $openoptionsgrp=array();
163 $openoptionsgrp[] = &$mform->createElement('checkbox', 'responsesopen', '', get_string('responses', 'quiz'));
164 $openoptionsgrp[] = &$mform->createElement('checkbox', 'answersopen', '', get_string('answers', 'quiz'));
165 $openoptionsgrp[] = &$mform->createElement('checkbox', 'feedbackopen', '', get_string('feedback', 'quiz'));
166 $openoptionsgrp[] = &$mform->createElement('checkbox', 'generalfeedbackopen', '', get_string('generalfeedback', 'quiz'));
167 $openoptionsgrp[] = &$mform->createElement('checkbox', 'scoreopen', '', get_string('scores', 'quiz'));
168 $openoptionsgrp[] = &$mform->createElement('checkbox', 'overallfeedbackopen', '', get_string('overallfeedback', 'quiz'));
169 $mform->addGroup($openoptionsgrp, 'openoptionsgrp', get_string("reviewopen", "quiz"), array(' '), false);
170 $mform->setDefault('responsesopen', $CFG->quiz_review & QUIZ_REVIEW_RESPONSES & QUIZ_REVIEW_OPEN);
171 $mform->setDefault('answersopen', $CFG->quiz_review & QUIZ_REVIEW_ANSWERS & QUIZ_REVIEW_OPEN);
172 $mform->setDefault('feedbackopen', $CFG->quiz_review & QUIZ_REVIEW_FEEDBACK & QUIZ_REVIEW_OPEN);
173 $mform->setDefault('generalfeedbackopen', $CFG->quiz_review & QUIZ_REVIEW_GENERALFEEDBACK & QUIZ_REVIEW_OPEN);
174 $mform->setDefault('scoreopen', $CFG->quiz_review & QUIZ_REVIEW_SCORES & QUIZ_REVIEW_OPEN);
175 $mform->setDefault('overallfeedbackopen', $CFG->quiz_review & QUIZ_REVIEW_OVERALLFEEDBACK & QUIZ_REVIEW_OPEN);
178 $closedoptionsgrp=array();
179 $closedoptionsgrp[] = &$mform->createElement('checkbox', 'responsesclosed', '', get_string('responses', 'quiz'));
180 $closedoptionsgrp[] = &$mform->createElement('checkbox', 'answersclosed', '', get_string('answers', 'quiz'));
181 $closedoptionsgrp[] = &$mform->createElement('checkbox', 'feedbackclosed', '', get_string('feedback', 'quiz'));
182 $closedoptionsgrp[] = &$mform->createElement('checkbox', 'generalfeedbackclosed', '', get_string('generalfeedback', 'quiz'));
183 $closedoptionsgrp[] = &$mform->createElement('checkbox', 'scoreclosed', '', get_string('scores', 'quiz'));
184 $closedoptionsgrp[] = &$mform->createElement('checkbox', 'overallfeedbackclosed', '', get_string('overallfeedback', 'quiz'));
185 $mform->addGroup($closedoptionsgrp, 'closedoptionsgrp', get_string("reviewclosed", "quiz"), array(' '), false);
186 $mform->setDefault('responsesclosed', $CFG->quiz_review & QUIZ_REVIEW_RESPONSES & QUIZ_REVIEW_CLOSED);
187 $mform->setDefault('answersclosed', $CFG->quiz_review & QUIZ_REVIEW_ANSWERS & QUIZ_REVIEW_CLOSED);
188 $mform->setDefault('feedbackclosed', $CFG->quiz_review & QUIZ_REVIEW_FEEDBACK & QUIZ_REVIEW_CLOSED);
189 $mform->setDefault('generalfeedbackclosed', $CFG->quiz_review & QUIZ_REVIEW_GENERALFEEDBACK & QUIZ_REVIEW_CLOSED);
190 $mform->setDefault('scoreclosed', $CFG->quiz_review & QUIZ_REVIEW_SCORES & QUIZ_REVIEW_CLOSED);
191 $mform->setDefault('overallfeedbackclosed', $CFG->quiz_review & QUIZ_REVIEW_OVERALLFEEDBACK & QUIZ_REVIEW_CLOSED);
193 //-------------------------------------------------------------------------------
194 $mform->addElement('header', 'security', get_string('security', 'form'));
196 $mform->addElement('selectyesno', 'popup', get_string("popup", "quiz"));
197 $mform->setHelpButton('popup', array("popup", get_string("popup", "quiz"), "quiz"));
198 $mform->setAdvanced('popup', $CFG->quiz_fix_popup);
199 $mform->setDefault('popup', $CFG->quiz_popup);
201 $mform->addElement('passwordunmask', 'quizpassword', get_string("requirepassword", "quiz"));
202 $mform->setType('quizpassword', PARAM_TEXT);
203 $mform->setHelpButton('quizpassword', array("requirepassword", get_string("requirepassword", "quiz"), "quiz"));
204 $mform->setAdvanced('quizpassword', $CFG->quiz_fix_password);
205 $mform->setDefault('quizpassword', $CFG->quiz_password);
207 $mform->addElement('text', 'subnet', get_string("requiresubnet", "quiz"));
208 $mform->setType('subnet', PARAM_TEXT);
209 $mform->setHelpButton('subnet', array("requiresubnet", get_string("requiresubnet", "quiz"), "quiz"));
210 $mform->setAdvanced('subnet', $CFG->quiz_fix_subnet);
211 $mform->setDefault('subnet', $CFG->quiz_subnet);
213 //-------------------------------------------------------------------------------
214 $features = new stdClass;
215 $features->groups = true;
216 $features->groupings = true;
217 $features->groupmembersonly = true;
218 $this->standard_coursemodule_elements($features);
219 //-------------------------------------------------------------------------------
220 $mform->addElement('header', 'overallfeedbackhdr', get_string('overallfeedback', 'quiz'));
221 $mform->setHelpButton('overallfeedbackhdr', array('overallfeedback', get_string('overallfeedback', 'quiz'), 'quiz'));
223 $mform->addElement('static', 'gradeboundarystatic1', get_string('gradeboundary', 'quiz'), '100%');
225 $repeatarray=array();
226 $repeatarray[] = &MoodleQuickForm::createElement('text', 'feedbacktext', get_string('feedback', 'quiz'), array('size' => 50));
227 $repeatarray[] = &MoodleQuickForm::createElement('text', 'feedbackboundaries', get_string('gradeboundary', 'quiz'), array('size' => 10));
229 if (!empty($this->_instance)) {
230 $this->_feedbacks = get_records('quiz_feedback', 'quizid', $this->_instance, 'mingrade DESC');
231 } else {
232 $this->_feedbacks = array();
234 $numfeedbacks = max(count($this->_feedbacks) * 1.5, 5);
236 $mform->setType('feedbacktext', PARAM_RAW);
237 $mform->setType('feedbackboundaries', PARAM_NOTAGS);
239 $nextel=$this->repeat_elements($repeatarray, $numfeedbacks-1,
240 array(), 'boundary_repeats', 'boundary_add_fields', 3);
242 //put some extra elements in before the button
243 $insertEl = &MoodleQuickForm::createElement('text', "feedbacktext[$nextel]", get_string('feedback', 'quiz'), array('size' => 50));
244 $mform->insertElementBefore($insertEl, 'boundary_add_fields');
246 $insertEl = &MoodleQuickForm::createElement('static', 'gradeboundarystatic2', get_string('gradeboundary', 'quiz'), '0%');
247 $mform->insertElementBefore($insertEl, 'boundary_add_fields');
249 //-------------------------------------------------------------------------------
250 // buttons
251 $this->add_action_buttons();
254 function data_preprocessing(&$default_values){
255 if (count($this->_feedbacks)) {
256 $key = 0;
257 foreach ($this->_feedbacks as $feedback){
258 $default_values['feedbacktext['.$key.']'] = $feedback->feedbacktext;
259 if ($feedback->mingrade > 0) {
260 $default_values['feedbackboundaries['.$key.']'] = (100.0 * $feedback->mingrade / $default_values['grade']) . '%';
262 $key++;
266 if (empty($default_values['timelimit'])) {
267 $default_values['timelimitenable'] = 0;
268 } else {
269 $default_values['timelimitenable'] = 1;
272 if (isset($default_values['review'])){
273 $review = (int)$default_values['review'];
274 unset($default_values['review']);
276 $default_values['responsesimmediately'] = $review & QUIZ_REVIEW_RESPONSES & QUIZ_REVIEW_IMMEDIATELY;
277 $default_values['answersimmediately'] = $review & QUIZ_REVIEW_ANSWERS & QUIZ_REVIEW_IMMEDIATELY;
278 $default_values['feedbackimmediately'] = $review & QUIZ_REVIEW_FEEDBACK & QUIZ_REVIEW_IMMEDIATELY;
279 $default_values['generalfeedbackimmediately'] = $review & QUIZ_REVIEW_GENERALFEEDBACK & QUIZ_REVIEW_IMMEDIATELY;
280 $default_values['scoreimmediately'] = $review & QUIZ_REVIEW_SCORES & QUIZ_REVIEW_IMMEDIATELY;
281 $default_values['overallfeedbackimmediately'] = $review & QUIZ_REVIEW_OVERALLFEEDBACK & QUIZ_REVIEW_IMMEDIATELY;
283 $default_values['responsesopen'] = $review & QUIZ_REVIEW_RESPONSES & QUIZ_REVIEW_OPEN;
284 $default_values['answersopen'] = $review & QUIZ_REVIEW_ANSWERS & QUIZ_REVIEW_OPEN;
285 $default_values['feedbackopen'] = $review & QUIZ_REVIEW_FEEDBACK & QUIZ_REVIEW_OPEN;
286 $default_values['generalfeedbackopen'] = $review & QUIZ_REVIEW_GENERALFEEDBACK & QUIZ_REVIEW_OPEN;
287 $default_values['scoreopen'] = $review & QUIZ_REVIEW_SCORES & QUIZ_REVIEW_OPEN;
288 $default_values['overallfeedbackopen'] = $review & QUIZ_REVIEW_OVERALLFEEDBACK & QUIZ_REVIEW_OPEN;
290 $default_values['responsesclosed'] = $review & QUIZ_REVIEW_RESPONSES & QUIZ_REVIEW_CLOSED;
291 $default_values['answersclosed'] = $review & QUIZ_REVIEW_ANSWERS & QUIZ_REVIEW_CLOSED;
292 $default_values['feedbackclosed'] = $review & QUIZ_REVIEW_FEEDBACK & QUIZ_REVIEW_CLOSED;
293 $default_values['generalfeedbackclosed'] = $review & QUIZ_REVIEW_GENERALFEEDBACK & QUIZ_REVIEW_CLOSED;
294 $default_values['scoreclosed'] = $review & QUIZ_REVIEW_SCORES & QUIZ_REVIEW_CLOSED;
295 $default_values['overallfeedbackclosed'] = $review & QUIZ_REVIEW_OVERALLFEEDBACK & QUIZ_REVIEW_CLOSED;
298 if (isset($default_values['optionflags'])){
299 $default_values['adaptive'] = $default_values['optionflags'] & QUESTION_ADAPTIVE;
300 unset($default_values['optionflags']);
303 // Password field - different in form to stop browsers that remember passwords
304 // getting confused.
305 if (isset($default_values['password'])) {
306 $default_values['quizpassword'] = $default_values['password'];
307 unset($default_values['password']);
311 function validation($data){
312 $errors = parent::validation($data);
313 if ($errors === true) {
314 $errors = array();
317 // Check open and close times are consistent.
318 if ($data['timeopen'] != 0 && $data['timeclose'] != 0 && $data['timeclose'] < $data['timeopen']) {
319 $errors['timeclose'] = get_string('closebeforeopen', 'quiz');
322 // Check the boundary value is a number or a percentage, and in range.
323 $i = 0;
324 while (!empty($data['feedbackboundaries'][$i] )) {
325 $boundary = trim($data['feedbackboundaries'][$i]);
326 if (strlen($boundary) > 0 && $boundary[strlen($boundary) - 1] == '%') {
327 $boundary = trim(substr($boundary, 0, -1));
328 if (is_numeric($boundary)) {
329 $boundary = $boundary * $data['grade'] / 100.0;
330 } else {
331 $errors["feedbackboundaries[$i]"] = get_string('feedbackerrorboundaryformat', 'quiz', $i + 1);
334 if (is_numeric($boundary) && $boundary <= 0 || $boundary >= $data['grade'] ) {
335 $errors["feedbackboundaries[$i]"] = get_string('feedbackerrorboundaryoutofrange', 'quiz', $i + 1);
337 if (is_numeric($boundary) && $i > 0 && $boundary >= $data['feedbackboundaries'][$i - 1]) {
338 $errors["feedbackboundaries[$i]"] = get_string('feedbackerrororder', 'quiz', $i + 1);
340 $data['feedbackboundaries'][$i] = $boundary;
341 $i += 1;
343 $numboundaries = $i;
345 // Check there is nothing in the remaining unused fields.
346 for ($i = $numboundaries; $i < count($data['feedbackboundaries'] ); $i += 1) {
347 if (!empty($data['feedbackboundaries'][$i] ) && trim($data['feedbackboundaries'][$i] ) != '') {
348 $errors["feedbackboundaries[$i]"] = get_string('feedbackerrorjunkinboundary', 'quiz', $i + 1);
351 for ($i = $numboundaries + 1; $i < count($data['feedbacktext'] ); $i += 1) {
352 if (!empty($data['feedbacktext'][$i] ) && trim($data['feedbacktext'][$i] ) != '') {
353 $errors["feedbacktext[$i]"] = get_string('feedbackerrorjunkinfeedback', 'quiz', $i + 1);
357 if (count($errors) == 0) {
358 return true;
359 } else {
360 return $errors;