MDL-8003 - part - Use formslib for question editing forms
[moodle.git] / question / type / truefalse / edit_truefalse_question_form.php
CommitLineData
36703ed7 1<?php
2/**
3 * Defines the editing form for the thruefalse question type.
4 *
5 * @copyright &copy; 2006 The Open University
6 * @author T.J.Hunt@open.ac.uk
7 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
8 * @package questions
9 *//** */
10
11/**
12 * truefalse editing form definition.
13 */
14class edit_truefalse_question_form extends edit_question_form {
15 /**
16 * Add question-type specific form fields.
17 *
18 * @param object $mform the form being built.
19 */
20 function definition_inner(&$mform) {
21 $mform->addElement('select', 'correctanswer', get_string('correctanswer', 'qtype_truefalse'),
22 array(0 => get_string('false', 'qtype_truefalse'), 1 => get_string('true', 'qtype_truefalse')));
23
24 $mform->addElement('htmleditor', 'feedbacktrue', get_string('feedbacktrue', 'qtype_truefalse'));
25 $mform->setType('feedbacktrue', PARAM_RAW);
26
27 $mform->addElement('htmleditor', 'feedbackfalse', get_string('feedbackfalse', 'qtype_truefalse'));
28 $mform->setType('feedbackfalse', PARAM_RAW);
29 }
30
31 function set_defaults($question) {
32 if (!empty($question->options->trueanswer)) {
33 $trueanswer = $question->options->answers[$question->options->trueanswer];
34 $question->correctanswer = ($trueanswer->fraction != 0);
35 $question->feedbacktrue = $trueanswer->feedback;
36 $question->feedbackfalse = $question->options->answers[$question->options->falseanswer]->feedback;
37 }
38 parent::set_defaults($question);
39 }
40
41 function qtype() {
42 return 'truefalse';
43 }
44}
45?>