MDL-20636 Conversion of the missingtype question type.
[moodle.git] / question / type / edit_question_form.php
CommitLineData
aeb15530 1<?php
fe6ce234
DC
2
3// This file is part of Moodle - http://moodle.org/
4//
5// Moodle is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// Moodle is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
17
2b7da645 18
36703ed7 19/**
20 * A base class for question editing forms.
21 *
2b7da645
TH
22 * @package moodlecore
23 * @subpackage questiontypes
36703ed7 24 * @copyright &copy; 2006 The Open University
36703ed7 25 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
fe6ce234 26 */
36703ed7 27
2b7da645 28
36703ed7 29/**
30 * Form definition base class. This defines the common fields that
31 * all question types need. Question types should define their own
32 * class that inherits from this one, and implements the definition_inner()
33 * method.
271e6dec 34 *
2b7da645
TH
35 * @copyright &copy; 2006 The Open University
36 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
36703ed7 37 */
2b7da645
TH
38abstract class question_edit_form extends moodleform {
39 const DEFAULT_NUM_HINTS = 2;
40
271ffe3f 41 /**
42 * Question object with options and answers already loaded by get_question_options
43 * Be careful how you use this it is needed sometimes to set up the structure of the
32db0d42 44 * form in definition_inner but data is always loaded into the form with set_data.
271ffe3f 45 * @var object
46 */
2b7da645
TH
47 protected $question;
48
49 protected $contexts;
50 protected $category;
51 protected $categorycontext;
271e6dec 52
fe6ce234
DC
53 /** @var object current context */
54 public $context;
55 /** @var array html editor options */
56 public $editoroptions;
57 /** @var array options to preapre draft area */
58 public $fileoptions;
59 /** @var object instance of question type */
60 public $instance;
61
2b7da645 62 public function __construct($submiturl, $question, $category, $contexts, $formeditable = true) {
fe6ce234 63 global $DB;
271e6dec 64
271ffe3f 65 $this->question = $question;
271e6dec 66 $this->contexts = $contexts;
67
5d548d3e 68 $record = $DB->get_record('question_categories', array('id' => $question->category), 'contextid');
fe6ce234
DC
69 $this->context = get_context_instance_by_id($record->contextid);
70
41dcc2a5
DC
71 $this->editoroptions = array('subdirs' => 1,'maxfiles' => EDITOR_UNLIMITED_FILES, 'context' => $this->context);
72 $this->fileoptions = array('subdirs' => 1, 'maxfiles' => -1, 'maxbytes' => -1);
fe6ce234 73
271e6dec 74 $this->category = $category;
75 $this->categorycontext = get_context_instance_by_id($category->contextid);
271e6dec 76
2b7da645 77 parent::__construct($submiturl, null, 'post', '', null, $formeditable);
271ffe3f 78 }
8e652f02 79
36703ed7 80 /**
81 * Build the form definition.
1d284fbd 82 *
295043c2 83 * This adds all the form fields that the default question type supports.
36703ed7 84 * If your question type does not support all these fields, then you can
85 * override this method and remove the ones you don't want with $mform->removeElement().
86 */
2b7da645 87 public function definition() {
f34488b2 88 global $COURSE, $CFG, $DB;
1d284fbd 89
36703ed7 90 $qtype = $this->qtype();
91 $langfile = "qtype_$qtype";
1d284fbd 92
2b7da645 93 $mform = $this->_form;
36703ed7 94
95 // Standard fields at the start of the form.
271ffe3f 96 $mform->addElement('header', 'generalheader', get_string("general", 'form'));
1d284fbd 97
2b7da645 98 if (!isset($this->question->id)) {
5d548d3e 99 // Adding question
2b7da645 100 $mform->addElement('questioncategory', 'category', get_string('category', 'question'),
522b89d1 101 array('contexts' => $this->contexts->having_cap('moodle/question:add')));
2b7da645 102 } elseif (!($this->question->formoptions->canmove || $this->question->formoptions->cansaveasnew)) {
5d548d3e 103 // Editing question with no permission to move from category.
2b7da645 104 $mform->addElement('questioncategory', 'category', get_string('category', 'question'),
271e6dec 105 array('contexts' => array($this->categorycontext)));
2b7da645 106 } elseif ($this->question->formoptions->movecontext) {
5d548d3e 107 // Moving question to another context.
2b7da645 108 $mform->addElement('questioncategory', 'categorymoveto', get_string('category', 'question'),
271e6dec 109 array('contexts' => $this->contexts->having_cap('moodle/question:add')));
110
111 } else {
5d548d3e 112 // Editing question with permission to move from category or save as new q
271e6dec 113 $currentgrp = array();
114 $currentgrp[0] =& $mform->createElement('questioncategory', 'category', get_string('categorycurrent', 'question'),
115 array('contexts' => array($this->categorycontext)));
2b7da645 116 if ($this->question->formoptions->canedit || $this->question->formoptions->cansaveasnew) {
271e6dec 117 //not move only form
118 $currentgrp[1] =& $mform->createElement('checkbox', 'usecurrentcat', '', get_string('categorycurrentuse', 'question'));
119 $mform->setDefault('usecurrentcat', 1);
120 }
121 $currentgrp[0]->freeze();
122 $currentgrp[0]->setPersistantFreeze(false);
123 $mform->addGroup($currentgrp, 'currentgrp', get_string('categorycurrent', 'question'), null, false);
124
125 $mform->addElement('questioncategory', 'categorymoveto', get_string('categorymoveto', 'question'),
126 array('contexts' => array($this->categorycontext)));
2b7da645 127 if ($this->question->formoptions->canedit || $this->question->formoptions->cansaveasnew) {
271e6dec 128 //not move only form
129 $mform->disabledIf('categorymoveto', 'usecurrentcat', 'checked');
130 }
131 }
375ed78a 132
2b7da645 133 $mform->addElement('text', 'name', get_string('questionname', 'question'), array('size' => 50));
271ffe3f 134 $mform->setType('name', PARAM_TEXT);
36703ed7 135 $mform->addRule('name', null, 'required', null, 'client');
1d284fbd 136
2b7da645 137 $mform->addElement('editor', 'questiontext', get_string('questiontext', 'question'),
5d548d3e 138 array('rows' => 15), $this->editoroptions);
36703ed7 139 $mform->setType('questiontext', PARAM_RAW);
1d284fbd 140
2b7da645 141 $mform->addElement('text', 'defaultmark', get_string('defaultmark', 'question'),
36703ed7 142 array('size' => 3));
2b7da645
TH
143 $mform->setType('defaultmark', PARAM_INT);
144 $mform->setDefault('defaultmark', 1);
145 $mform->addRule('defaultmark', null, 'required', null, 'client');
36703ed7 146
2b7da645 147 $mform->addElement('editor', 'generalfeedback', get_string('generalfeedback', 'question'),
5d548d3e 148 array('rows' => 10), $this->editoroptions);
36703ed7 149 $mform->setType('generalfeedback', PARAM_RAW);
2b7da645 150 $mform->addHelpButton('generalfeedback', 'generalfeedback', 'question');
1d284fbd 151
36703ed7 152 // Any questiontype specific fields.
153 $this->definition_inner($mform);
154
c599a682 155 if (!empty($CFG->usetags)) {
156 $mform->addElement('header', 'tagsheader', get_string('tags'));
157 $mform->addElement('tags', 'tags', get_string('tags'));
158 }
159
2b7da645 160 if (!empty($this->question->id)) {
271e6dec 161 $mform->addElement('header', 'createdmodifiedheader', get_string('createdmodifiedheader', 'question'));
7f389342 162 $a = new stdClass();
2b7da645 163 if (!empty($this->question->createdby)) {
271e6dec 164 $a->time = userdate($this->question->timecreated);
f34488b2 165 $a->user = fullname($DB->get_record('user', array('id' => $this->question->createdby)));
271e6dec 166 } else {
167 $a->time = get_string('unknown', 'question');
168 $a->user = get_string('unknown', 'question');
169 }
170 $mform->addElement('static', 'created', get_string('created', 'question'), get_string('byandon', 'question', $a));
2b7da645 171 if (!empty($this->question->modifiedby)) {
7f389342 172 $a = new stdClass();
271e6dec 173 $a->time = userdate($this->question->timemodified);
f34488b2 174 $a->user = fullname($DB->get_record('user', array('id' => $this->question->modifiedby)));
271e6dec 175 $mform->addElement('static', 'modified', get_string('modified', 'question'), get_string('byandon', 'question', $a));
176 }
177 }
178
36703ed7 179 // Standard fields at the end of the form.
180 $mform->addElement('hidden', 'id');
181 $mform->setType('id', PARAM_INT);
182
183 $mform->addElement('hidden', 'qtype');
184 $mform->setType('qtype', PARAM_ALPHA);
185
186 $mform->addElement('hidden', 'inpopup');
187 $mform->setType('inpopup', PARAM_INT);
188
189 $mform->addElement('hidden', 'versioning');
190 $mform->setType('versioning', PARAM_BOOL);
191
271e6dec 192 $mform->addElement('hidden', 'movecontext');
193 $mform->setType('movecontext', PARAM_BOOL);
194
9ab75b2b 195 $mform->addElement('hidden', 'cmid');
196 $mform->setType('cmid', PARAM_INT);
197 $mform->setDefault('cmid', 0);
198
271e6dec 199 $mform->addElement('hidden', 'courseid');
200 $mform->setType('courseid', PARAM_INT);
201 $mform->setDefault('courseid', 0);
202
7cd4fda6 203 $mform->addElement('hidden', 'returnurl');
204 $mform->setType('returnurl', PARAM_LOCALURL);
271e6dec 205 $mform->setDefault('returnurl', 0);
7cd4fda6 206
fa583f5f 207 $mform->addElement('hidden', 'appendqnumstring');
208 $mform->setType('appendqnumstring', PARAM_ALPHA);
209 $mform->setDefault('appendqnumstring', 0);
210
375ed78a 211 $buttonarray = array();
2b7da645 212 if (!empty($this->question->id)) {
271e6dec 213 //editing / moving question
2b7da645 214 if ($this->question->formoptions->movecontext) {
271e6dec 215 $buttonarray[] = &$mform->createElement('submit', 'submitbutton', get_string('moveq', 'question'));
2b7da645 216 } elseif ($this->question->formoptions->canedit || $this->question->formoptions->canmove ||$this->question->formoptions->movecontext) {
271e6dec 217 $buttonarray[] = &$mform->createElement('submit', 'submitbutton', get_string('savechanges'));
218 }
2b7da645
TH
219 if ($this->question->formoptions->cansaveasnew) {
220 $buttonarray[] = &$mform->createElement('submit', 'makecopy', get_string('makecopy', 'question'));
271e6dec 221 }
222 $buttonarray[] = &$mform->createElement('cancel');
223 } else {
224 // adding new question
225 $buttonarray[] = &$mform->createElement('submit', 'submitbutton', get_string('savechanges'));
226 $buttonarray[] = &$mform->createElement('cancel');
375ed78a 227 }
375ed78a 228 $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false);
229 $mform->closeHeaderBefore('buttonar');
271e6dec 230
5d548d3e 231 if ($this->question->formoptions->movecontext) {
271e6dec 232 $mform->hardFreezeAllVisibleExcept(array('categorymoveto', 'buttonar'));
2b7da645 233 } else if ((!empty($this->question->id)) && (!($this->question->formoptions->canedit || $this->question->formoptions->cansaveasnew))) {
271e6dec 234 $mform->hardFreezeAllVisibleExcept(array('categorymoveto', 'buttonar', 'currentgrp'));
235 }
36703ed7 236 }
fa583f5f 237
36703ed7 238 /**
239 * Add any question-type specific form fields.
1d284fbd 240 *
241 * @param object $mform the form being built.
36703ed7 242 */
2b7da645 243 protected function definition_inner($mform) {
36703ed7 244 // By default, do nothing.
245 }
1d284fbd 246
2aef1fe5 247 /**
248 * Get the list of form elements to repeat, one for each answer.
249 * @param object $mform the form being built.
250 * @param $label the label to use for each option.
251 * @param $gradeoptions the possible grades for each answer.
252 * @param $repeatedoptions reference to array of repeated options to fill
253 * @param $answersoption reference to return the name of $question->options field holding an array of answers
254 * @return array of form fields.
255 */
2b7da645 256 protected function get_per_answer_fields(&$mform, $label, $gradeoptions, &$repeatedoptions, &$answersoption) {
2aef1fe5 257 $repeated = array();
258 $repeated[] =& $mform->createElement('header', 'answerhdr', $label);
de58c9c4 259 $repeated[] =& $mform->createElement('text', 'answer', get_string('answer', 'quiz'), array('size' => 80));
2aef1fe5 260 $repeated[] =& $mform->createElement('select', 'fraction', get_string('grade'), $gradeoptions);
fe6ce234 261 $repeated[] =& $mform->createElement('editor', 'feedback', get_string('feedback', 'quiz'),
5d548d3e 262 array('rows' => 5), $this->editoroptions);
2aef1fe5 263 $repeatedoptions['answer']['type'] = PARAM_RAW;
264 $repeatedoptions['fraction']['default'] = 0;
265 $answersoption = 'answers';
266 return $repeated;
267 }
268
269 /**
270 * Add a set of form fields, obtained from get_per_answer_fields, to the form,
271 * one for each existing answer, with some blanks for some new ones.
272 * @param object $mform the form being built.
273 * @param $label the label to use for each option.
274 * @param $gradeoptions the possible grades for each answer.
275 * @param $minoptions the minimum number of answer blanks to display. Default QUESTION_NUMANS_START.
276 * @param $addoptions the number of answer blanks to add. Default QUESTION_NUMANS_ADD.
277 */
2b7da645 278 protected function add_per_answer_fields(&$mform, $label, $gradeoptions, $minoptions = QUESTION_NUMANS_START, $addoptions = QUESTION_NUMANS_ADD) {
2aef1fe5 279 $answersoption = '';
280 $repeatedoptions = array();
281 $repeated = $this->get_per_answer_fields($mform, $label, $gradeoptions, $repeatedoptions, $answersoption);
282
2b7da645 283 if (isset($this->question->options)) {
2aef1fe5 284 $countanswers = count($this->question->options->$answersoption);
285 } else {
286 $countanswers = 0;
287 }
2b7da645 288 if ($this->question->formoptions->repeatelements) {
2aef1fe5 289 $repeatsatstart = max($minoptions, $countanswers + $addoptions);
290 } else {
291 $repeatsatstart = $countanswers;
292 }
293
294 $this->repeat_elements($repeated, $repeatsatstart, $repeatedoptions, 'noanswers', 'addanswers', $addoptions, get_string('addmorechoiceblanks', 'qtype_multichoice'));
295 }
296
2b7da645
TH
297 protected function add_combined_feedback_fields($withshownumpartscorrect = false) {
298 $mform = $this->_form;
299
300 $mform->addElement('header', 'combinedfeedbackhdr', get_string('combinedfeedback', 'question'));
301
302 foreach (array('correctfeedback', 'partiallycorrectfeedback', 'incorrectfeedback') as $feedbackname) {
303 $mform->addElement('editor', $feedbackname, get_string($feedbackname, 'question'),
304 array('rows' => 5), $this->editoroptions);
305 $mform->setType($feedbackname, PARAM_RAW);
306
307 if ($withshownumpartscorrect && $feedbackname == 'partiallycorrectfeedback') {
308 $mform->addElement('checkbox', 'shownumcorrect', get_string('options', 'question'), get_string('shownumpartscorrect', 'question'));
309 }
310 }
311 }
312
313 protected function get_hint_fields($withclearwrong = false, $withshownumpartscorrect = false) {
314 $mform = $this->_form;
315
316 $repeated = array();
317 $repeated[] = $mform->createElement('header', 'answerhdr', get_string('hintn', 'question'));
7a719748
TH
318 $repeated[] = $mform->createElement('editor', 'hint', get_string('hinttext', 'question'),
319 array('rows' => 5), $this->editoroptions);
2b7da645
TH
320 $repeatedoptions['hint']['type'] = PARAM_RAW;
321
322 if ($withclearwrong) {
323 $repeated[] = $mform->createElement('checkbox', 'hintclearwrong', get_string('options', 'question'), get_string('clearwrongparts', 'question'));
324 }
325 if ($withshownumpartscorrect) {
326 $repeated[] = $mform->createElement('checkbox', 'hintshownumcorrect', '', get_string('shownumpartscorrect', 'question'));
327 }
328
329 return array($repeated, $repeatedoptions);
330 }
331
332 protected function add_interactive_settings($withclearwrong = false, $withshownumpartscorrect = false) {
333 $mform = $this->_form;
334
335 $mform->addElement('header', 'multitriesheader', get_string('settingsformultipletries', 'question'));
336
337 $penalties = array(
338 1.0000000,
339 0.5000000,
340 0.3333333,
341 0.2500000,
342 0.2000000,
343 0.1000000,
344 0.0000000
345 );
346 if (!empty($this->question->penalty) && !in_array($this->question->penalty, $penalties)) {
347 $penalties[] = $this->question->penalty;
348 sort($penalties);
349 }
350 $penaltyoptions = array();
351 foreach ($penalties as $penalty) {
352 $penaltyoptions["$penalty"] = (100 * $penalty) . '%';
353 }
354 $mform->addElement('select', 'penalty', get_string('penaltyforeachincorrecttry', 'question'),
355 $penaltyoptions);
356 $mform->addRule('penalty', null, 'required', null, 'client');
068b4594 357 $mform->addHelpButton('penalty', 'penaltyforeachincorrecttry', 'question');
2b7da645
TH
358 $mform->setDefault('penalty', 0.3333333);
359
360 if (isset($this->question->hints)) {
361 $counthints = count($this->question->hints);
362 } else {
363 $counthints = 0;
364 }
365
366 if ($this->question->formoptions->repeatelements) {
367 $repeatsatstart = max(self::DEFAULT_NUM_HINTS, $counthints);
368 } else {
369 $repeatsatstart = $counthints;
370 }
371
372 list($repeated, $repeatedoptions) = $this->get_hint_fields(
373 $withclearwrong, $withshownumpartscorrect);
374 $this->repeat_elements($repeated, $repeatsatstart, $repeatedoptions,
375 'numhints', 'addhint', 1, get_string('addanotherhint', 'question'));
376 }
377
378 public function set_data($question) {
36703ed7 379 global $QTYPES;
2b7da645
TH
380 $QTYPES[$question->qtype]->set_default_options($question);
381
fe6ce234
DC
382 // prepare question text
383 $draftid = file_get_submitted_draft_itemid('questiontext');
384
385 if (!empty($question->questiontext)) {
386 $questiontext = $question->questiontext;
387 } else {
388 $questiontext = '';
271ffe3f 389 }
41dcc2a5 390 $questiontext = file_prepare_draft_area($draftid, $this->context->id, 'question', 'questiontext', empty($question->id)?null:(int)$question->id, $this->fileoptions, $questiontext);
fe6ce234
DC
391
392 $question->questiontext = array();
393 $question->questiontext['text'] = $questiontext;
394 $question->questiontext['format'] = empty($question->questiontextformat) ? editors_get_preferred_format() : $question->questiontextformat;
395 $question->questiontext['itemid'] = $draftid;
396
397 // prepare general feedback
398 $draftid = file_get_submitted_draft_itemid('generalfeedback');
399
400 if (empty($question->generalfeedback)) {
401 $question->generalfeedback = '';
402 }
403
41dcc2a5 404 $feedback = file_prepare_draft_area($draftid, $this->context->id, 'question', 'generalfeedback', empty($question->id)?null:(int)$question->id, $this->fileoptions, $question->generalfeedback);
fe6ce234
DC
405 $question->generalfeedback = array();
406 $question->generalfeedback['text'] = $feedback;
407 $question->generalfeedback['format'] = empty($question->generalfeedbackformat) ? editors_get_preferred_format() : $question->generalfeedbackformat;
408 $question->generalfeedback['itemid'] = $draftid;
295043c2 409
9152f6a5 410 // Remove unnecessary trailing 0s form grade fields.
cfd24d98 411 if (isset($question->defaultgrade)) {
412 $question->defaultgrade = 0 + $question->defaultgrade;
413 }
414 if (isset($question->penalty)) {
415 $question->penalty = 0 + $question->penalty;
416 }
9152f6a5 417
295043c2 418 // Set any options.
419 $extra_question_fields = $QTYPES[$question->qtype]->extra_question_fields();
8e652f02 420 if (is_array($extra_question_fields) && !empty($question->options)) {
295043c2 421 array_shift($extra_question_fields);
422 foreach ($extra_question_fields as $field) {
b555ce76 423 if (isset($question->options->$field)) {
8e652f02 424 $question->$field = $question->options->$field;
425 }
295043c2 426 }
427 }
fe6ce234
DC
428 // subclass adds data_preprocessing code here
429 $question = $this->data_preprocessing($question);
2b7da645 430
32db0d42 431 parent::set_data($question);
36703ed7 432 }
1d284fbd 433
fe6ce234
DC
434 /**
435 * Any preprocessing needed for the settings form for the question type
436 *
437 * @param array $question - array to fill in with the default values
438 */
439 function data_preprocessing($question) {
7a719748
TH
440 return $question;
441 }
442
443 protected function data_preprocessing_answers($question) {
444 if (empty($question->options->answers)) {
445 return $question;
446 }
447
448 $key = 0;
449 foreach ($question->options->answers as $answer){
450 $question->answer[$key] = $answer->answer;
451 $question->fraction[$key] = 0 + $answer->fraction;
452 $question->feedback[$key] = array();
453
454 // Evil hack alert. Formslib can store defaults in two ways for
455 // repeat elements: ->_defaultValues['fraction[0]'] and
456 // ->_defaultValues['fraction'][0]. The $repeatedoptions['fraction']['default'] = 0;
457 // bit above means that ->_defaultValues['fraction[0]'] has already
458 // been set, but we are using object notation here, so we will be setting
459 // ->_defaultValues['fraction'][0]. That does not work, so we have to unset
460 // ->_defaultValues['fraction[0]']
461 unset($this->_form->_defaultValues["fraction[$key]"]);
462
463 // Prepare the feedback editor to display files in draft area
464 $draftitemid = file_get_submitted_draft_itemid('feedback['.$key.']');
465 $question->feedback[$key]['text'] = file_prepare_draft_area(
466 $draftitemid, // draftid
467 $this->context->id, // context
468 'question', // component
469 'answerfeedback', // filarea
470 !empty($answer->id) ? (int) $answer->id : null, // itemid
471 $this->fileoptions, // options
472 $answer->feedback // text
473 );
474 $question->feedback[$key]['itemid'] = $draftitemid;
475 $question->feedback[$key]['format'] = $answer->feedbackformat;
476 $key++;
477 }
478 return $question;
479 }
480
481 protected function data_preprocessing_hints($question, $withclearwrong = false, $withshownumpartscorrect = false) {
482 if (empty($question->hints)) {
483 return $question;
484 }
485
486 $key = 0;
487 foreach ($question->hints as $hint){
488 $question->hint[$key] = array();
489
490 // prepare feedback editor to display files in draft area
491 $draftitemid = file_get_submitted_draft_itemid('hint['.$key.']');
492 $question->hint[$key]['text'] = file_prepare_draft_area(
493 $draftitemid, // draftid
494 $this->context->id, // context
495 'question', // component
496 'hint', // filarea
497 !empty($hint->id) ? (int) $hint->id : null, // itemid
498 $this->fileoptions, // options
499 $hint->hint // text
500 );
501 $question->hint[$key]['itemid'] = $draftitemid;
502 $question->hint[$key]['format'] = $hint->hintformat;
503 $key++;
504 }
505
506 // TODO $withclearwrong, $withshownumpartscorrect
507
fe6ce234
DC
508 return $question;
509 }
510
2b7da645
TH
511 public function validation($fromform, $files) {
512 $errors = parent::validation($fromform, $files);
513 if (empty($fromform->makecopy) && isset($this->question->id)
514 && ($this->question->formoptions->canedit || $this->question->formoptions->cansaveasnew)
515 && empty($fromform->usecurrentcat) && !$this->question->formoptions->canmove) {
516 $errors['currentgrp'] = get_string('nopermissionmove', 'question');
517 }
518 return $errors;
519 }
520
36703ed7 521 /**
522 * Override this in the subclass to question type name.
523 * @return the question type name, should be the same as the name() method in the question type class.
524 */
2b7da645 525 public abstract function qtype();
36703ed7 526}