Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/question/type/missingtype/edit_missingtype_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 
00037 class qtype_missingtype_edit_form extends question_edit_form {
00038     public function __construct($submiturl, $question, $category, $contexts, $formeditable = true) {
00039         parent::__construct($submiturl, $question, $category, $contexts, false);
00040     }
00041 
00047     protected function definition_inner($mform) {
00048         $this->add_per_answer_fields($mform, get_string('answerno', 'qtype_missingtype', '{no}'),
00049                 question_bank::fraction_options_full());
00050     }
00051 
00052     public function set_data($question) {
00053         if (isset($question->options) && is_array($question->options->answers)) {
00054             $answers = $question->options->answers;
00055             $default_values = array();
00056             $key = 0;
00057             foreach ($answers as $answer) {
00058                 $default_values['answer['.$key.']'] = $answer->answer;
00059                 $default_values['fraction['.$key.']'] = $answer->fraction;
00060                 $default_values['feedback['.$key.']'] = $answer->feedback;
00061                 $key++;
00062             }
00063             $question = (object)((array)$question + $default_values);
00064         }
00065         parent::set_data($question);
00066     }
00067 
00068     public function qtype() {
00069         return 'missingtype';
00070     }
00071 
00072     public function validation($data, $files) {
00073         $errors = parent::validation($data, $files);
00074         $errors['name'] = get_string('cannotchangeamissingqtype', 'qtype_missingtype');
00075         return $errors;
00076     }
00077 }
 All Data Structures Namespaces Files Functions Variables Enumerations