curl now mandatory
[moodle.git] / question / type / truefalse / edit_truefalse_form.php
CommitLineData
aeb15530 1<?php
bfebaf64
MD
2if (!defined('MOODLE_INTERNAL')) {
3 die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
4}
5
01ae934f 6require_once($CFG->dirroot.'/question/type/edit_question_form.php');
36703ed7 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
830e47a8 13 * @package questionbank
14 * @subpackage questiontypes
36703ed7 15 *//** */
16
17/**
18 * truefalse editing form definition.
19 */
01ae934f 20class question_edit_truefalse_form extends question_edit_form {
36703ed7 21 /**
22 * Add question-type specific form fields.
01ae934f 23 *
24 * @param object $mform the form being built.
36703ed7 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')));
01ae934f 29
271e6dec 30 $mform->addElement('htmleditor', 'feedbacktrue', get_string('feedbacktrue', 'qtype_truefalse'),
31 array('course' => $this->coursefilesid));;
36703ed7 32 $mform->setType('feedbacktrue', PARAM_RAW);
33
271e6dec 34 $mform->addElement('htmleditor', 'feedbackfalse', get_string('feedbackfalse', 'qtype_truefalse'),
35 array('course' => $this->coursefilesid));
36703ed7 36 $mform->setType('feedbackfalse', PARAM_RAW);
fe76ab50 37
38 // Fix penalty factor at 1.
39 $mform->setDefault('penalty', 1);
40 $mform->freeze('penalty');
36703ed7 41 }
01ae934f 42
32db0d42 43 function set_data($question) {
36703ed7 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 }
32db0d42 50 parent::set_data($question);
36703ed7 51 }
01ae934f 52
36703ed7 53 function qtype() {
54 return 'truefalse';
55 }
56}