MDL-43646 "disapprove" changed to "undo approval"
[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
60527d0c
JMV
53 $mform->addElement('editor', 'responsetemplate', get_string('responsetemplate', 'qtype_essay'),
54 array('rows' => 10), array_merge($this->editoroptions, array('maxfiles' => 0)));
55 $mform->addHelpButton('responsetemplate', 'responsetemplate', 'qtype_essay');
56
894e8b4e
TH
57 $mform->addElement('editor', 'graderinfo', get_string('graderinfo', 'qtype_essay'),
58 array('rows' => 10), $this->editoroptions);
59 }
60
121fd4c1 61 protected function data_preprocessing($question) {
894e8b4e
TH
62 $question = parent::data_preprocessing($question);
63
64 if (empty($question->options)) {
65 return $question;
66 }
67
68 $question->responseformat = $question->options->responseformat;
69 $question->responsefieldlines = $question->options->responsefieldlines;
70 $question->attachments = $question->options->attachments;
71
72 $draftid = file_get_submitted_draft_itemid('graderinfo');
73 $question->graderinfo = array();
74 $question->graderinfo['text'] = file_prepare_draft_area(
3d9645ae 75 $draftid, // Draftid
894e8b4e
TH
76 $this->context->id, // context
77 'qtype_essay', // component
78 'graderinfo', // filarea
79 !empty($question->id) ? (int) $question->id : null, // itemid
80 $this->fileoptions, // options
3d9645ae 81 $question->options->graderinfo // text.
894e8b4e
TH
82 );
83 $question->graderinfo['format'] = $question->options->graderinfoformat;
84 $question->graderinfo['itemid'] = $draftid;
85
60527d0c
JMV
86 $question->responsetemplate = array(
87 'text' => $question->options->responsetemplate,
88 'format' => $question->options->responsetemplateformat,
89 );
90
894e8b4e
TH
91 return $question;
92 }
93
6d03299d 94 public function qtype() {
271ffe3f 95 return 'essay';
96 }
271ffe3f 97}