MDL-22388 Added some checks to kill these scripts dead with an unequivocal notice...
[moodle.git] / question / type / truefalse / edit_truefalse_form.php
1 <?php
2 if (!defined('MOODLE_INTERNAL')) {
3     die('Direct access to this script is forbidden.');    ///  It must be included from a Moodle page
4 }
6 require_once($CFG->dirroot.'/question/type/edit_question_form.php');
7 /**
8  * Defines the editing form for the thruefalse question type.
9  *
10  * @copyright &copy; 2006 The Open University
11  * @author T.J.Hunt@open.ac.uk
12  * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
13  * @package questionbank
14  * @subpackage questiontypes
15  *//** */
17 /**
18  * truefalse editing form definition.
19  */
20 class question_edit_truefalse_form extends question_edit_form {
21     /**
22      * Add question-type specific form fields.
23      *
24      * @param object $mform the form being built.
25      */
26     function definition_inner(&$mform) {
27         $mform->addElement('select', 'correctanswer', get_string('correctanswer', 'qtype_truefalse'),
28                 array(0 => get_string('false', 'qtype_truefalse'), 1 => get_string('true', 'qtype_truefalse')));
30         $mform->addElement('htmleditor', 'feedbacktrue', get_string('feedbacktrue', 'qtype_truefalse'),
31                                 array('course' => $this->coursefilesid));;
32         $mform->setType('feedbacktrue', PARAM_RAW);
34         $mform->addElement('htmleditor', 'feedbackfalse', get_string('feedbackfalse', 'qtype_truefalse'),
35                                 array('course' => $this->coursefilesid));
36         $mform->setType('feedbackfalse', PARAM_RAW);
38         // Fix penalty factor at 1.
39         $mform->setDefault('penalty', 1);
40         $mform->freeze('penalty');
41     }
43     function set_data($question) {
44         if (!empty($question->options->trueanswer)) {
45             $trueanswer = $question->options->answers[$question->options->trueanswer];
46             $question->correctanswer = ($trueanswer->fraction != 0);
47             $question->feedbacktrue = $trueanswer->feedback;
48             $question->feedbackfalse = $question->options->answers[$question->options->falseanswer]->feedback;
49         }
50         parent::set_data($question);
51     }
53     function qtype() {
54         return 'truefalse';
55     }
56 }