Differences Between: [Versions 310 and 403] [Versions 311 and 403] [Versions 39 and 403] [Versions 400 and 403] [Versions 401 and 403]
1 <?php 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 17 require_once($CFG->dirroot.'/mod/feedback/item/feedback_item_form_class.php'); 18 19 class feedback_multichoicerated_form extends feedback_item_form { 20 protected $type = "multichoicerated"; 21 22 /** @var object Form element */ 23 protected $values; 24 25 public function definition() { 26 $item = $this->_customdata['item']; 27 $common = $this->_customdata['common']; 28 $positionlist = $this->_customdata['positionlist']; 29 $position = $this->_customdata['position']; 30 31 $mform =& $this->_form; 32 33 $mform->addElement('header', 'general', get_string($this->type, 'feedback')); 34 35 $mform->addElement('advcheckbox', 'required', get_string('required', 'feedback'), '' , null , array(0, 1)); 36 37 $mform->addElement('text', 38 'name', 39 get_string('item_name', 'feedback'), 40 array('size'=>FEEDBACK_ITEM_NAME_TEXTBOX_SIZE, 41 'maxlength'=>255)); 42 43 $mform->addElement('text', 44 'label', 45 get_string('item_label', 'feedback'), 46 array('size'=>FEEDBACK_ITEM_LABEL_TEXTBOX_SIZE, 47 'maxlength'=>255)); 48 49 $mform->addElement('select', 50 'subtype', 51 get_string('multichoicetype', 'feedback').' ', 52 array('r'=>get_string('radio', 'feedback'), 53 'd'=>get_string('dropdown', 'feedback'))); 54 55 $mform->addElement('select', 56 'horizontal', 57 get_string('adjustment', 'feedback').' ', 58 array(0 => get_string('vertical', 'feedback'), 59 1 => get_string('horizontal', 'feedback'))); 60 $mform->hideIf('horizontal', 'subtype', 'eq', 'd'); 61 62 $mform->addElement('selectyesno', 63 'hidenoselect', 64 get_string('hide_no_select_option', 'feedback')); 65 $mform->hideIf('hidenoselect', 'subtype', 'eq', 'd'); 66 67 $mform->addElement('selectyesno', 68 'ignoreempty', 69 get_string('do_not_analyse_empty_submits', 'feedback')); 70 $mform->disabledIf('ignoreempty', 'required', 'eq', '1'); 71 72 $this->values = $mform->addElement('textarea', 73 'values', 74 get_string('multichoice_values', 'feedback'), 75 'wrap="virtual" rows="10" cols="65"'); 76 77 $mform->addElement('static', 78 'hint', 79 '', 80 get_string('use_one_line_for_each_value', 'feedback')); 81 82 parent::definition(); 83 $this->set_data($item); 84 85 } 86 87 public function set_data($item) { 88 $info = $this->_customdata['info']; 89 90 $item->horizontal = $info->horizontal; 91 92 $item->subtype = $info->subtype; 93 94 $item->values = $info->values; 95 96 return parent::set_data($item); 97 } 98 99 public function get_data() { 100 if (!$item = parent::get_data()) { 101 return false; 102 } 103 104 $itemobj = new feedback_item_multichoicerated(); 105 106 $presentation = $itemobj->prepare_presentation_values_save(trim($item->values), 107 FEEDBACK_MULTICHOICERATED_VALUE_SEP2, 108 FEEDBACK_MULTICHOICERATED_VALUE_SEP); 109 if (!isset($item->subtype)) { 110 $subtype = 'r'; 111 } else { 112 $subtype = substr($item->subtype, 0, 1); 113 } 114 if (isset($item->horizontal) AND $item->horizontal == 1 AND $subtype != 'd') { 115 $presentation .= FEEDBACK_MULTICHOICERATED_ADJUST_SEP.'1'; 116 } 117 $item->presentation = $subtype.FEEDBACK_MULTICHOICERATED_TYPE_SEP.$presentation; 118 if (!isset($item->hidenoselect)) { 119 $item->hidenoselect = 1; 120 } 121 if (!isset($item->ignoreempty)) { 122 $item->ignoreempty = 0; 123 } 124 return $item; 125 } 126 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body