|
Moodle
2.2.1
http://www.collinsharper.com
|
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 00036 class qtype_essay_edit_form extends question_edit_form { 00037 00038 protected function definition_inner($mform) { 00039 $qtype = question_bank::get_qtype('essay'); 00040 00041 $mform->addElement('select', 'responseformat', 00042 get_string('responseformat', 'qtype_essay'), $qtype->response_formats()); 00043 $mform->setDefault('responseformat', 'editor'); 00044 00045 $mform->addElement('select', 'responsefieldlines', 00046 get_string('responsefieldlines', 'qtype_essay'), $qtype->response_sizes()); 00047 $mform->setDefault('responsefieldlines', 15); 00048 00049 $mform->addElement('select', 'attachments', 00050 get_string('allowattachments', 'qtype_essay'), $qtype->attachment_options()); 00051 $mform->setDefault('attachments', 0); 00052 00053 $mform->addElement('editor', 'graderinfo', get_string('graderinfo', 'qtype_essay'), 00054 array('rows' => 10), $this->editoroptions); 00055 } 00056 00057 protected function data_preprocessing($question) { 00058 $question = parent::data_preprocessing($question); 00059 00060 if (empty($question->options)) { 00061 return $question; 00062 } 00063 00064 $question->responseformat = $question->options->responseformat; 00065 $question->responsefieldlines = $question->options->responsefieldlines; 00066 $question->attachments = $question->options->attachments; 00067 00068 $draftid = file_get_submitted_draft_itemid('graderinfo'); 00069 $question->graderinfo = array(); 00070 $question->graderinfo['text'] = file_prepare_draft_area( 00071 $draftid, // draftid 00072 $this->context->id, // context 00073 'qtype_essay', // component 00074 'graderinfo', // filarea 00075 !empty($question->id) ? (int) $question->id : null, // itemid 00076 $this->fileoptions, // options 00077 $question->options->graderinfo // text 00078 ); 00079 $question->graderinfo['format'] = $question->options->graderinfoformat; 00080 $question->graderinfo['itemid'] = $draftid; 00081 00082 return $question; 00083 } 00084 00085 public function qtype() { 00086 return 'essay'; 00087 } 00088 }