MDL-38509 Version bump for plugins installation
[moodle.git] / question / type / essay / edit_essay_form.php
CommitLineData
aeb15530 1<?php
fe6ce234
DC
2// This file is part of Moodle - http://moodle.org/
3//
4// Moodle is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// Moodle is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16
271ffe3f 17/**
18 * Defines the editing form for the essay question type.
19 *
b04a4319
TH
20 * @package qtype
21 * @subpackage essay
22 * @copyright 2007 Jamie Pratt me@jamiep.org
23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
271ffe3f 24 */
25
b04a4319 26
a17b297d
TH
27defined('MOODLE_INTERNAL') || die();
28
29
271ffe3f 30/**
b04a4319
TH
31 * Essay question type editing form.
32 *
33 * @copyright 2007 Jamie Pratt me@jamiep.org
34 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
271ffe3f 35 */
6e34cd29 36class qtype_essay_edit_form extends question_edit_form {
894e8b4e
TH
37
38 protected function definition_inner($mform) {
39 $qtype = question_bank::get_qtype('essay');
40
41 $mform->addElement('select', 'responseformat',
b3ae5457 42 get_string('responseformat', 'qtype_essay'), $qtype->response_formats());
894e8b4e
TH
43 $mform->setDefault('responseformat', 'editor');
44
45 $mform->addElement('select', 'responsefieldlines',
b3ae5457 46 get_string('responsefieldlines', 'qtype_essay'), $qtype->response_sizes());
894e8b4e
TH
47 $mform->setDefault('responsefieldlines', 15);
48
49 $mform->addElement('select', 'attachments',
50 get_string('allowattachments', 'qtype_essay'), $qtype->attachment_options());
51 $mform->setDefault('attachments', 0);
52
53 $mform->addElement('editor', 'graderinfo', get_string('graderinfo', 'qtype_essay'),
54 array('rows' => 10), $this->editoroptions);
55 }
56
121fd4c1 57 protected function data_preprocessing($question) {
894e8b4e
TH
58 $question = parent::data_preprocessing($question);
59
60 if (empty($question->options)) {
61 return $question;
62 }
63
64 $question->responseformat = $question->options->responseformat;
65 $question->responsefieldlines = $question->options->responsefieldlines;
66 $question->attachments = $question->options->attachments;
67
68 $draftid = file_get_submitted_draft_itemid('graderinfo');
69 $question->graderinfo = array();
70 $question->graderinfo['text'] = file_prepare_draft_area(
71 $draftid, // draftid
72 $this->context->id, // context
73 'qtype_essay', // component
74 'graderinfo', // filarea
75 !empty($question->id) ? (int) $question->id : null, // itemid
76 $this->fileoptions, // options
77 $question->options->graderinfo // text
78 );
79 $question->graderinfo['format'] = $question->options->graderinfoformat;
80 $question->graderinfo['itemid'] = $draftid;
81
82 return $question;
83 }
84
6d03299d 85 public function qtype() {
271ffe3f 86 return 'essay';
87 }
271ffe3f 88}