|
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->libdir.'/formslib.php'); 00018 00019 define('FEEDBACK_ITEM_NAME_TEXTBOX_SIZE', 80); 00020 define('FEEDBACK_ITEM_LABEL_TEXTBOX_SIZE', 20); 00021 abstract class feedback_item_form extends moodleform { 00022 public function definition() { 00023 $item = $this->_customdata['item']; //the item object 00024 00025 //common is an array like: 00026 // array('cmid'=>$cm->id, 00027 // 'id'=>isset($item->id) ? $item->id : NULL, 00028 // 'typ'=>$item->typ, 00029 // 'items'=>$feedbackitems, 00030 // 'feedback'=>$feedback->id); 00031 $common = $this->_customdata['common']; 00032 00033 //positionlist is an array with possible positions for the item location 00034 $positionlist = $this->_customdata['positionlist']; 00035 00036 //the current position of the item 00037 $position = $this->_customdata['position']; 00038 00039 $mform =& $this->_form; 00040 00041 if ($common['items']) { 00042 $mform->addElement('select', 00043 'dependitem', 00044 get_string('dependitem', 'feedback').' ', 00045 $common['items'] 00046 ); 00047 $mform->addHelpButton('dependitem', 'depending', 'feedback'); 00048 $mform->addElement('text', 00049 'dependvalue', 00050 get_string('dependvalue', 'feedback'), 00051 array('size'=>FEEDBACK_ITEM_LABEL_TEXTBOX_SIZE, 'maxlength'=>255)); 00052 } else { 00053 $mform->addElement('hidden', 'dependitem', 0); 00054 $mform->setType('dependitem', PARAM_INT); 00055 $mform->addElement('hidden', 'dependvalue', ''); 00056 $mform->setType('dependitem', PARAM_ALPHA); 00057 } 00058 00059 $position_select = $mform->addElement('select', 00060 'position', 00061 get_string('position', 'feedback').' ', 00062 $positionlist); 00063 $position_select->setValue($position); 00064 00065 $mform->addElement('hidden', 'cmid', $common['cmid']); 00066 $mform->setType('cmid', PARAM_INT); 00067 00068 $mform->addElement('hidden', 'id', $common['id']); 00069 $mform->setType('id', PARAM_INT); 00070 00071 $mform->addElement('hidden', 'feedback', $common['feedback']); 00072 $mform->setType('feedback', PARAM_INT); 00073 00074 $mform->addElement('hidden', 'template', 0); 00075 $mform->setType('template', PARAM_INT); 00076 00077 $mform->setType('name', PARAM_RAW); 00078 $mform->setType('label', PARAM_ALPHANUM); 00079 00080 $mform->addElement('hidden', 'typ', $this->type); 00081 $mform->setType('typ', PARAM_ALPHA); 00082 00083 $mform->addElement('hidden', 'hasvalue', 0); 00084 $mform->setType('hasvalue', PARAM_INT); 00085 00086 $mform->addElement('hidden', 'options', ''); 00087 $mform->setType('options', PARAM_ALPHA); 00088 00089 $buttonarray = array(); 00090 if (!empty($item->id)) { 00091 $buttonarray[] = &$mform->createElement('submit', 00092 'update_item', 00093 get_string('update_item', 'feedback')); 00094 00095 $buttonarray[] = &$mform->createElement('submit', 00096 'clone_item', 00097 get_string('save_as_new_item', 'feedback')); 00098 } else { 00099 $mform->addElement('hidden', 'clone_item', 0); 00100 $mform->setType('clone_item', PARAM_INT); 00101 $buttonarray[] = &$mform->createElement('submit', 00102 'save_item', 00103 get_string('save_item', 'feedback')); 00104 } 00105 $buttonarray[] = &$mform->createElement('cancel'); 00106 $mform->addGroup($buttonarray, 'buttonar', ' ', array(' '), false); 00107 00108 } 00109 } 00110