Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/mod/quiz/mod_form.php
Go to the documentation of this file.
00001 <?php
00002 // This file is part of Moodle - http://moodle.org/
00003 //
00004 // Moodle is free software: you can redistribute it and/or modify
00005 // it under the terms of the GNU General Public License as published by
00006 // the Free Software Foundation, either version 3 of the License, or
00007 // (at your option) any later version.
00008 //
00009 // Moodle is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
00016 
00027 defined('MOODLE_INTERNAL') || die();
00028 
00029 require_once($CFG->dirroot . '/course/moodleform_mod.php');
00030 require_once($CFG->dirroot . '/mod/quiz/locallib.php');
00031 
00032 
00039 class mod_quiz_mod_form extends moodleform_mod {
00040     protected $_feedbacks;
00041     protected static $reviewfields = array(); // Initialised in the constructor.
00042 
00043     public function __construct($current, $section, $cm, $course) {
00044         self::$reviewfields = array(
00045             'attempt' => get_string('theattempt', 'quiz'),
00046             'correctness' => get_string('whethercorrect', 'question'),
00047             'marks' => get_string('marks', 'question'),
00048             'specificfeedback' => get_string('specificfeedback', 'question'),
00049             'generalfeedback' => get_string('generalfeedback', 'question'),
00050             'rightanswer' => get_string('rightanswer', 'question'),
00051             'overallfeedback' => get_string('overallfeedback', 'quiz'),
00052         );
00053         parent::__construct($current, $section, $cm, $course);
00054     }
00055 
00056     protected function definition() {
00057         global $COURSE, $CFG, $DB, $PAGE;
00058         $quizconfig = get_config('quiz');
00059         $mform = $this->_form;
00060 
00061         //-------------------------------------------------------------------------------
00062         $mform->addElement('header', 'general', get_string('general', 'form'));
00063 
00064         // Name.
00065         $mform->addElement('text', 'name', get_string('name'), array('size'=>'64'));
00066         if (!empty($CFG->formatstringstriptags)) {
00067             $mform->setType('name', PARAM_TEXT);
00068         } else {
00069             $mform->setType('name', PARAM_CLEANHTML);
00070         }
00071         $mform->addRule('name', null, 'required', null, 'client');
00072 
00073         // Introduction.
00074         $this->add_intro_editor(false, get_string('introduction', 'quiz'));
00075 
00076         // Open and close dates.
00077         $mform->addElement('date_time_selector', 'timeopen', get_string('quizopen', 'quiz'),
00078                 array('optional' => true, 'step' => 1));
00079         $mform->addHelpButton('timeopen', 'quizopenclose', 'quiz');
00080 
00081         $mform->addElement('date_time_selector', 'timeclose', get_string('quizclose', 'quiz'),
00082                 array('optional' => true, 'step' => 1));
00083 
00084         // Time limit.
00085         $mform->addElement('duration', 'timelimit', get_string('timelimit', 'quiz'),
00086                 array('optional' => true));
00087         $mform->addHelpButton('timelimit', 'timelimit', 'quiz');
00088         $mform->setAdvanced('timelimit', $quizconfig->timelimit_adv);
00089         $mform->setDefault('timelimit', $quizconfig->timelimit);
00090 
00091         // Number of attempts.
00092         $attemptoptions = array('0' => get_string('unlimited'));
00093         for ($i = 1; $i <= QUIZ_MAX_ATTEMPT_OPTION; $i++) {
00094             $attemptoptions[$i] = $i;
00095         }
00096         $mform->addElement('select', 'attempts', get_string('attemptsallowed', 'quiz'),
00097                 $attemptoptions);
00098         $mform->setAdvanced('attempts', $quizconfig->attempts_adv);
00099         $mform->setDefault('attempts', $quizconfig->attempts);
00100 
00101         // Grading method.
00102         $mform->addElement('select', 'grademethod', get_string('grademethod', 'quiz'),
00103                 quiz_get_grading_options());
00104         $mform->addHelpButton('grademethod', 'grademethod', 'quiz');
00105         $mform->setAdvanced('grademethod', $quizconfig->grademethod_adv);
00106         $mform->setDefault('grademethod', $quizconfig->grademethod);
00107         $mform->disabledIf('grademethod', 'attempts', 'eq', 1);
00108 
00109         //-------------------------------------------------------------------------------
00110         // Grade settings
00111         $this->standard_grading_coursemodule_elements();
00112 
00113         $mform->removeElement('grade');
00114         $mform->addElement('hidden', 'grade', $quizconfig->maximumgrade);
00115         $mform->setType('grade', PARAM_NUMBER);
00116 
00117         //-------------------------------------------------------------------------------
00118         $mform->addElement('header', 'layouthdr', get_string('layout', 'quiz'));
00119 
00120         // Shuffle questions.
00121         $shuffleoptions = array(
00122             0 => get_string('asshownoneditscreen', 'quiz'),
00123             1 => get_string('shuffledrandomly', 'quiz')
00124         );
00125         $mform->addElement('select', 'shufflequestions', get_string('questionorder', 'quiz'),
00126                 $shuffleoptions, array('id' => 'id_shufflequestions'));
00127         $mform->setAdvanced('shufflequestions', $quizconfig->shufflequestions_adv);
00128         $mform->setDefault('shufflequestions', $quizconfig->shufflequestions);
00129 
00130         // Questions per page.
00131         $pageoptions = array();
00132         $pageoptions[0] = get_string('neverallononepage', 'quiz');
00133         $pageoptions[1] = get_string('everyquestion', 'quiz');
00134         for ($i = 2; $i <= QUIZ_MAX_QPP_OPTION; ++$i) {
00135             $pageoptions[$i] = get_string('everynquestions', 'quiz', $i);
00136         }
00137 
00138         $pagegroup = array();
00139         $pagegroup[] = $mform->createElement('select', 'questionsperpage',
00140                 get_string('newpage', 'quiz'), $pageoptions, array('id' => 'id_questionsperpage'));
00141         $mform->setDefault('questionsperpage', $quizconfig->questionsperpage);
00142 
00143         if (!empty($this->_cm)) {
00144             $pagegroup[] = $mform->createElement('checkbox', 'repaginatenow', '',
00145                     get_string('repaginatenow', 'quiz'), array('id' => 'id_repaginatenow'));
00146             $mform->disabledIf('repaginatenow', 'shufflequestions', 'eq', 1);
00147             $PAGE->requires->yui2_lib('event');
00148             $PAGE->requires->js('/mod/quiz/edit.js');
00149             $PAGE->requires->js_init_call('quiz_settings_init');
00150         }
00151 
00152         $mform->addGroup($pagegroup, 'questionsperpagegrp',
00153                 get_string('newpage', 'quiz'), null, false);
00154         $mform->addHelpButton('questionsperpagegrp', 'newpage', 'quiz');
00155         $mform->setAdvanced('questionsperpagegrp', $quizconfig->questionsperpage_adv);
00156 
00157         //-------------------------------------------------------------------------------
00158         $mform->addElement('header', 'interactionhdr', get_string('questionbehaviour', 'quiz'));
00159 
00160         // Shuffle within questions.
00161         $mform->addElement('selectyesno', 'shuffleanswers', get_string('shufflewithin', 'quiz'));
00162         $mform->addHelpButton('shuffleanswers', 'shufflewithin', 'quiz');
00163         $mform->setAdvanced('shuffleanswers', $quizconfig->shuffleanswers_adv);
00164         $mform->setDefault('shuffleanswers', $quizconfig->shuffleanswers);
00165 
00166         // How questions behave (question behaviour).
00167         if (!empty($this->current->preferredbehaviour)) {
00168             $currentbehaviour = $this->current->preferredbehaviour;
00169         } else {
00170             $currentbehaviour = '';
00171         }
00172         $behaviours = question_engine::get_behaviour_options($currentbehaviour);
00173         $mform->addElement('select', 'preferredbehaviour',
00174                 get_string('howquestionsbehave', 'question'), $behaviours);
00175         $mform->addHelpButton('preferredbehaviour', 'howquestionsbehave', 'question');
00176         $mform->setDefault('preferredbehaviour', $quizconfig->preferredbehaviour);
00177 
00178         // Each attempt builds on last.
00179         $mform->addElement('selectyesno', 'attemptonlast',
00180                 get_string('eachattemptbuildsonthelast', 'quiz'));
00181         $mform->addHelpButton('attemptonlast', 'eachattemptbuildsonthelast', 'quiz');
00182         $mform->setAdvanced('attemptonlast', $quizconfig->attemptonlast_adv);
00183         $mform->setDefault('attemptonlast', $quizconfig->attemptonlast);
00184         $mform->disabledIf('attemptonlast', 'attempts', 'eq', 1);
00185 
00186         //-------------------------------------------------------------------------------
00187         $mform->addElement('header', 'reviewoptionshdr',
00188                 get_string('reviewoptionsheading', 'quiz'));
00189         $mform->addHelpButton('reviewoptionshdr', 'reviewoptionsheading', 'quiz');
00190 
00191         // Review options.
00192         $this->add_review_options_group($mform, $quizconfig, 'during',
00193                 mod_quiz_display_options::DURING);
00194         $this->add_review_options_group($mform, $quizconfig, 'immediately',
00195                 mod_quiz_display_options::IMMEDIATELY_AFTER);
00196         $this->add_review_options_group($mform, $quizconfig, 'open',
00197                 mod_quiz_display_options::LATER_WHILE_OPEN);
00198         $this->add_review_options_group($mform, $quizconfig, 'closed',
00199                 mod_quiz_display_options::AFTER_CLOSE);
00200 
00201         foreach ($behaviours as $behaviour => $notused) {
00202             $unusedoptions = question_engine::get_behaviour_unused_display_options($behaviour);
00203             foreach ($unusedoptions as $unusedoption) {
00204                 $mform->disabledIf($unusedoption . 'during', 'preferredbehaviour',
00205                         'eq', $behaviour);
00206             }
00207         }
00208         $mform->disabledIf('attemptduring', 'preferredbehaviour',
00209                 'neq', 'wontmatch');
00210         $mform->disabledIf('overallfeedbackduring', 'preferredbehaviour',
00211                 'neq', 'wontmatch');
00212 
00213         //-------------------------------------------------------------------------------
00214         $mform->addElement('header', 'display', get_string('display', 'form'));
00215 
00216         // Show user picture.
00217         $mform->addElement('selectyesno', 'showuserpicture',
00218                 get_string('showuserpicture', 'quiz'));
00219         $mform->addHelpButton('showuserpicture', 'showuserpicture', 'quiz');
00220         $mform->setAdvanced('showuserpicture', $quizconfig->showuserpicture_adv);
00221         $mform->setDefault('showuserpicture', $quizconfig->showuserpicture);
00222 
00223         // Overall decimal points.
00224         $options = array();
00225         for ($i = 0; $i <= QUIZ_MAX_DECIMAL_OPTION; $i++) {
00226             $options[$i] = $i;
00227         }
00228         $mform->addElement('select', 'decimalpoints', get_string('decimalplaces', 'quiz'),
00229                 $options);
00230         $mform->addHelpButton('decimalpoints', 'decimalplaces', 'quiz');
00231         $mform->setAdvanced('decimalpoints', $quizconfig->decimalpoints_adv);
00232         $mform->setDefault('decimalpoints', $quizconfig->decimalpoints);
00233 
00234         // Question decimal points.
00235         $options = array(-1 => get_string('sameasoverall', 'quiz'));
00236         for ($i = 0; $i <= QUIZ_MAX_Q_DECIMAL_OPTION; $i++) {
00237             $options[$i] = $i;
00238         }
00239         $mform->addElement('select', 'questiondecimalpoints',
00240                 get_string('decimalplacesquestion', 'quiz'), $options);
00241         $mform->addHelpButton('questiondecimalpoints', 'decimalplacesquestion', 'quiz');
00242         $mform->setAdvanced('questiondecimalpoints', $quizconfig->questiondecimalpoints_adv);
00243         $mform->setDefault('questiondecimalpoints', $quizconfig->questiondecimalpoints);
00244 
00245         // Show blocks during quiz attempt
00246         $mform->addElement('selectyesno', 'showblocks', get_string('showblocks', 'quiz'));
00247         $mform->addHelpButton('showblocks', 'showblocks', 'quiz');
00248         $mform->setAdvanced('showblocks', $quizconfig->showblocks_adv);
00249         $mform->setDefault('showblocks', $quizconfig->showblocks);
00250 
00251         //-------------------------------------------------------------------------------
00252         $mform->addElement('header', 'security', get_string('extraattemptrestrictions', 'quiz'));
00253 
00254         // Require password to begin quiz attempt.
00255         $mform->addElement('passwordunmask', 'quizpassword', get_string('requirepassword', 'quiz'));
00256         $mform->setType('quizpassword', PARAM_TEXT);
00257         $mform->addHelpButton('quizpassword', 'requirepassword', 'quiz');
00258         $mform->setAdvanced('quizpassword', $quizconfig->password_adv);
00259         $mform->setDefault('quizpassword', $quizconfig->password);
00260 
00261         // IP address.
00262         $mform->addElement('text', 'subnet', get_string('requiresubnet', 'quiz'));
00263         $mform->setType('subnet', PARAM_TEXT);
00264         $mform->addHelpButton('subnet', 'requiresubnet', 'quiz');
00265         $mform->setAdvanced('subnet', $quizconfig->subnet_adv);
00266         $mform->setDefault('subnet', $quizconfig->subnet);
00267 
00268         // Enforced time delay between quiz attempts.
00269         $mform->addElement('duration', 'delay1', get_string('delay1st2nd', 'quiz'),
00270                 array('optional' => true));
00271         $mform->addHelpButton('delay1', 'delay1st2nd', 'quiz');
00272         $mform->setAdvanced('delay1', $quizconfig->delay1_adv);
00273         $mform->setDefault('delay1', $quizconfig->delay1);
00274         $mform->disabledIf('delay1', 'attempts', 'eq', 1);
00275 
00276         $mform->addElement('duration', 'delay2', get_string('delaylater', 'quiz'),
00277                 array('optional' => true));
00278         $mform->addHelpButton('delay2', 'delaylater', 'quiz');
00279         $mform->setAdvanced('delay2', $quizconfig->delay2_adv);
00280         $mform->setDefault('delay2', $quizconfig->delay2);
00281         $mform->disabledIf('delay2', 'attempts', 'eq', 1);
00282         $mform->disabledIf('delay2', 'attempts', 'eq', 2);
00283 
00284         // 'Secure' window.
00285         $mform->addElement('select', 'browsersecurity', get_string('browsersecurity', 'quiz'),
00286                 quiz_access_manager::get_browser_security_choices());
00287         $mform->addHelpButton('browsersecurity', 'browsersecurity', 'quiz');
00288         $mform->setAdvanced('browsersecurity', $quizconfig->browsersecurity_adv);
00289         $mform->setDefault('browsersecurity', $quizconfig->browsersecurity);
00290 
00291         // Any other rule plugins.
00292         quiz_access_manager::add_settings_form_fields($this, $mform);
00293 
00294         //-------------------------------------------------------------------------------
00295         $mform->addElement('header', 'overallfeedbackhdr', get_string('overallfeedback', 'quiz'));
00296         $mform->addHelpButton('overallfeedbackhdr', 'overallfeedback', 'quiz');
00297 
00298         if (isset($this->current->grade)) {
00299             $needwarning = $this->current->grade === 0;
00300         } else {
00301             $needwarning = $quizconfig->maximumgrade == 0;
00302         }
00303         if ($needwarning) {
00304             $mform->addElement('static', 'nogradewarning', '',
00305                     get_string('nogradewarning', 'quiz'));
00306         }
00307 
00308         $mform->addElement('static', 'gradeboundarystatic1',
00309                 get_string('gradeboundary', 'quiz'), '100%');
00310 
00311         $repeatarray = array();
00312         $repeatedoptions = array();
00313         $repeatarray[] = MoodleQuickForm::createElement('editor', 'feedbacktext',
00314                 get_string('feedback', 'quiz'), null, array('maxfiles' => EDITOR_UNLIMITED_FILES,
00315                         'noclean' => true, 'context' => $this->context));
00316         $repeatarray[] = MoodleQuickForm::createElement('text', 'feedbackboundaries',
00317                 get_string('gradeboundary', 'quiz'), array('size' => 10));
00318         $repeatedoptions['feedbacktext']['type'] = PARAM_RAW;
00319         $repeatedoptions['feedbackboundaries']['type'] = PARAM_RAW;
00320 
00321         if (!empty($this->_instance)) {
00322             $this->_feedbacks = $DB->get_records('quiz_feedback',
00323                     array('quizid' => $this->_instance), 'mingrade DESC');
00324         } else {
00325             $this->_feedbacks = array();
00326         }
00327         $numfeedbacks = max(count($this->_feedbacks) * 1.5, 5);
00328 
00329         $nextel = $this->repeat_elements($repeatarray, $numfeedbacks - 1,
00330                 $repeatedoptions, 'boundary_repeats', 'boundary_add_fields', 3,
00331                 get_string('addmoreoverallfeedbacks', 'quiz'), true);
00332 
00333         // Put some extra elements in before the button
00334         $mform->insertElementBefore(MoodleQuickForm::createElement('editor',
00335                 "feedbacktext[$nextel]", get_string('feedback', 'quiz'), null,
00336                 array('maxfiles' => EDITOR_UNLIMITED_FILES, 'noclean' => true,
00337                       'context' => $this->context)),
00338                 'boundary_add_fields');
00339         $mform->insertElementBefore(MoodleQuickForm::createElement('static',
00340                 'gradeboundarystatic2', get_string('gradeboundary', 'quiz'), '0%'),
00341                 'boundary_add_fields');
00342 
00343         // Add the disabledif rules. We cannot do this using the $repeatoptions parameter to
00344         // repeat_elements because we don't want to dissable the first feedbacktext.
00345         for ($i = 0; $i < $nextel; $i++) {
00346             $mform->disabledIf('feedbackboundaries[' . $i . ']', 'grade', 'eq', 0);
00347             $mform->disabledIf('feedbacktext[' . ($i + 1) . ']', 'grade', 'eq', 0);
00348         }
00349 
00350         //-------------------------------------------------------------------------------
00351         $this->standard_coursemodule_elements();
00352 
00353         //-------------------------------------------------------------------------------
00354         // buttons
00355         $this->add_action_buttons();
00356     }
00357 
00358     protected function add_review_options_group($mform, $quizconfig, $whenname, $when) {
00359         $group = array();
00360         foreach (self::$reviewfields as $field => $label) {
00361             $group[] = $mform->createElement('checkbox', $field . $whenname, '', $label);
00362         }
00363         $mform->addGroup($group, $whenname . 'optionsgrp',
00364                 get_string('review' . $whenname, 'quiz'), null, false);
00365 
00366         foreach (self::$reviewfields as $field => $notused) {
00367             $cfgfield = 'review' . $field;
00368             if ($quizconfig->$cfgfield & $when) {
00369                 $mform->setDefault($field . $whenname, 1);
00370             } else {
00371                 $mform->setDefault($field . $whenname, 0);
00372             }
00373         }
00374 
00375         $mform->disabledIf('correctness' . $whenname, 'attempt' . $whenname);
00376         $mform->disabledIf('specificfeedback' . $whenname, 'attempt' . $whenname);
00377         $mform->disabledIf('generalfeedback' . $whenname, 'attempt' . $whenname);
00378         $mform->disabledIf('rightanswer' . $whenname, 'attempt' . $whenname);
00379     }
00380 
00381     protected function preprocessing_review_settings(&$toform, $whenname, $when) {
00382         foreach (self::$reviewfields as $field => $notused) {
00383             $fieldname = 'review' . $field;
00384             if (array_key_exists($fieldname, $toform)) {
00385                 $toform[$field . $whenname] = $toform[$fieldname] & $when;
00386             }
00387         }
00388     }
00389 
00390     public function data_preprocessing(&$toform) {
00391         if (isset($toform['grade'])) {
00392             // Convert to a real number, so we don't get 0.0000.
00393             $toform['grade'] = $toform['grade'] + 0;
00394         }
00395 
00396         if (count($this->_feedbacks)) {
00397             $key = 0;
00398             foreach ($this->_feedbacks as $feedback) {
00399                 $draftid = file_get_submitted_draft_itemid('feedbacktext['.$key.']');
00400                 $toform['feedbacktext['.$key.']']['text'] = file_prepare_draft_area(
00401                     $draftid,               // draftid
00402                     $this->context->id,     // context
00403                     'mod_quiz',             // component
00404                     'feedback',             // filarea
00405                     !empty($feedback->id) ? (int) $feedback->id : null, // itemid
00406                     null,
00407                     $feedback->feedbacktext // text
00408                 );
00409                 $toform['feedbacktext['.$key.']']['format'] = $feedback->feedbacktextformat;
00410                 $toform['feedbacktext['.$key.']']['itemid'] = $draftid;
00411 
00412                 if ($toform['grade'] == 0) {
00413                     // When a quiz is un-graded, there can only be one lot of
00414                     // feedback. If the quiz previously had a maximum grade and
00415                     // several lots of feedback, we must now avoid putting text
00416                     // into input boxes that are disabled, but which the
00417                     // validation will insist are blank.
00418                     break;
00419                 }
00420 
00421                 if ($feedback->mingrade > 0) {
00422                     $toform['feedbackboundaries['.$key.']'] =
00423                             (100.0 * $feedback->mingrade / $toform['grade']) . '%';
00424                 }
00425                 $key++;
00426             }
00427         }
00428 
00429         if (isset($toform['timelimit'])) {
00430             $toform['timelimitenable'] = $toform['timelimit'] > 0;
00431         }
00432 
00433         $this->preprocessing_review_settings($toform, 'during',
00434                 mod_quiz_display_options::DURING);
00435         $this->preprocessing_review_settings($toform, 'immediately',
00436                 mod_quiz_display_options::IMMEDIATELY_AFTER);
00437         $this->preprocessing_review_settings($toform, 'open',
00438                 mod_quiz_display_options::LATER_WHILE_OPEN);
00439         $this->preprocessing_review_settings($toform, 'closed',
00440                 mod_quiz_display_options::AFTER_CLOSE);
00441         $toform['attemptduring'] = true;
00442         $toform['overallfeedbackduring'] = false;
00443 
00444         // Password field - different in form to stop browsers that remember
00445         // passwords from getting confused.
00446         if (isset($toform['password'])) {
00447             $toform['quizpassword'] = $toform['password'];
00448             unset($toform['password']);
00449         }
00450 
00451         // Load any settings belonging to the access rules.
00452         if (!empty($toform['instance'])) {
00453             $accesssettings = quiz_access_manager::load_settings($toform['instance']);
00454             foreach ($accesssettings as $name => $value) {
00455                 $toform[$name] = $value;
00456             }
00457         }
00458     }
00459 
00460     public function validation($data, $files) {
00461         $errors = parent::validation($data, $files);
00462 
00463         // Check open and close times are consistent.
00464         if ($data['timeopen'] != 0 && $data['timeclose'] != 0 &&
00465                 $data['timeclose'] < $data['timeopen']) {
00466             $errors['timeclose'] = get_string('closebeforeopen', 'quiz');
00467         }
00468 
00469         // Check the boundary value is a number or a percentage, and in range.
00470         $i = 0;
00471         while (!empty($data['feedbackboundaries'][$i] )) {
00472             $boundary = trim($data['feedbackboundaries'][$i]);
00473             if (strlen($boundary) > 0 && $boundary[strlen($boundary) - 1] == '%') {
00474                 $boundary = trim(substr($boundary, 0, -1));
00475                 if (is_numeric($boundary)) {
00476                     $boundary = $boundary * $data['grade'] / 100.0;
00477                 } else {
00478                     $errors["feedbackboundaries[$i]"] =
00479                             get_string('feedbackerrorboundaryformat', 'quiz', $i + 1);
00480                 }
00481             }
00482             if (is_numeric($boundary) && $boundary <= 0 || $boundary >= $data['grade'] ) {
00483                 $errors["feedbackboundaries[$i]"] =
00484                         get_string('feedbackerrorboundaryoutofrange', 'quiz', $i + 1);
00485             }
00486             if (is_numeric($boundary) && $i > 0 &&
00487                     $boundary >= $data['feedbackboundaries'][$i - 1]) {
00488                 $errors["feedbackboundaries[$i]"] =
00489                         get_string('feedbackerrororder', 'quiz', $i + 1);
00490             }
00491             $data['feedbackboundaries'][$i] = $boundary;
00492             $i += 1;
00493         }
00494         $numboundaries = $i;
00495 
00496         // Check there is nothing in the remaining unused fields.
00497         if (!empty($data['feedbackboundaries'])) {
00498             for ($i = $numboundaries; $i < count($data['feedbackboundaries']); $i += 1) {
00499                 if (!empty($data['feedbackboundaries'][$i] ) &&
00500                         trim($data['feedbackboundaries'][$i] ) != '') {
00501                     $errors["feedbackboundaries[$i]"] =
00502                             get_string('feedbackerrorjunkinboundary', 'quiz', $i + 1);
00503                 }
00504             }
00505         }
00506         for ($i = $numboundaries + 1; $i < count($data['feedbacktext']); $i += 1) {
00507             if (!empty($data['feedbacktext'][$i]['text']) &&
00508                     trim($data['feedbacktext'][$i]['text'] ) != '') {
00509                 $errors["feedbacktext[$i]"] =
00510                         get_string('feedbackerrorjunkinfeedback', 'quiz', $i + 1);
00511             }
00512         }
00513 
00514         return $errors;
00515     }
00516 }
 All Data Structures Namespaces Files Functions Variables Enumerations