|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 // This file is part of Moodle - http://moodle.org/ 00003 // 00004 // Moodle is free software: you can redistribute it and/or modify 00005 // it under the terms of the GNU General Public License as published by 00006 // the Free Software Foundation, either version 3 of the License, or 00007 // (at your option) any later version. 00008 // 00009 // Moodle is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00016 00017 require_once($CFG->dirroot.'/mod/feedback/item/feedback_item_form_class.php'); 00018 00019 class feedback_multichoicerated_form extends feedback_item_form { 00020 protected $type = "multichoicerated"; 00021 00022 public function definition() { 00023 $item = $this->_customdata['item']; 00024 $common = $this->_customdata['common']; 00025 $positionlist = $this->_customdata['positionlist']; 00026 $position = $this->_customdata['position']; 00027 00028 $mform =& $this->_form; 00029 00030 $mform->addElement('header', 'general', get_string($this->type, 'feedback')); 00031 00032 $mform->addElement('checkbox', 'required', get_string('required', 'feedback')); 00033 00034 $mform->addElement('text', 00035 'name', 00036 get_string('item_name', 'feedback'), 00037 array('size'=>FEEDBACK_ITEM_NAME_TEXTBOX_SIZE, 00038 'maxlength'=>255)); 00039 00040 $mform->addElement('text', 00041 'label', 00042 get_string('item_label', 'feedback'), 00043 array('size'=>FEEDBACK_ITEM_LABEL_TEXTBOX_SIZE, 00044 'maxlength'=>255)); 00045 00046 $mform->addElement('select', 00047 'horizontal', 00048 get_string('adjustment', 'feedback').' ', 00049 array(0 => get_string('vertical', 'feedback'), 00050 1 => get_string('horizontal', 'feedback'))); 00051 00052 $mform->addElement('select', 00053 'subtype', 00054 get_string('multichoicetype', 'feedback').' ', 00055 array('r'=>get_string('radio', 'feedback'), 00056 'd'=>get_string('dropdown', 'feedback'))); 00057 00058 $mform->addElement('selectyesno', 00059 'ignoreempty', 00060 get_string('do_not_analyse_empty_submits', 'feedback')); 00061 00062 $mform->addElement('selectyesno', 00063 'hidenoselect', 00064 get_string('hide_no_select_option', 'feedback')); 00065 00066 $mform->addElement('static', 00067 'hint', 00068 get_string('multichoice_values', 'feedback'), 00069 get_string('use_one_line_for_each_value', 'feedback')); 00070 00071 $this->values = $mform->addElement('textarea', 00072 'values', 00073 '', 00074 'wrap="virtual" rows="10" cols="65"'); 00075 00076 parent::definition(); 00077 $this->set_data($item); 00078 00079 } 00080 00081 public function set_data($item) { 00082 $info = $this->_customdata['info']; 00083 00084 $item->horizontal = $info->horizontal; 00085 00086 $item->subtype = $info->subtype; 00087 00088 $item->values = $info->values; 00089 00090 return parent::set_data($item); 00091 } 00092 00093 public function get_data() { 00094 if (!$item = parent::get_data()) { 00095 return false; 00096 } 00097 00098 $itemobj = new feedback_item_multichoicerated(); 00099 00100 $presentation = $itemobj->prepare_presentation_values_save(trim($item->values), 00101 FEEDBACK_MULTICHOICERATED_VALUE_SEP2, 00102 FEEDBACK_MULTICHOICERATED_VALUE_SEP); 00103 if (!isset($item->subtype)) { 00104 $subtype = 'r'; 00105 } else { 00106 $subtype = substr($item->subtype, 0, 1); 00107 } 00108 if (isset($item->horizontal) AND $item->horizontal == 1 AND $subtype != 'd') { 00109 $presentation .= FEEDBACK_MULTICHOICERATED_ADJUST_SEP.'1'; 00110 } 00111 $item->presentation = $subtype.FEEDBACK_MULTICHOICERATED_TYPE_SEP.$presentation; 00112 return $item; 00113 } 00114 }