mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
optimized the code of item_form. put the common calls into the parrent class "feedback_item_form_class.php"
This commit is contained in:
parent
3a787259fe
commit
5e97c34df7
@ -24,67 +24,7 @@ class feedback_captcha_form extends feedback_item_form {
|
||||
get_string('count_of_nums', 'feedback').' ',
|
||||
array_slice(range(0,10),3,10,true));
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//the following is used in all itemforms
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//itemdepending
|
||||
if($common['items']) {
|
||||
$mform->addElement('select',
|
||||
'dependitem',
|
||||
get_string('dependitem', 'feedback').' ',
|
||||
$common['items']
|
||||
);
|
||||
$mform->addHelpButton('dependitem', 'depending', 'feedback');
|
||||
$mform->addElement('text', 'dependvalue', get_string('dependvalue', 'feedback'), array('size="'.FEEDBACK_ITEM_LABEL_TEXTBOX_SIZE.'"','maxlength="255"'));
|
||||
}else {
|
||||
$mform->addElement('hidden', 'dependitem', 0);
|
||||
$mform->setType('dependitem', PARAM_INT);
|
||||
$mform->addElement('hidden', 'dependvalue', '');
|
||||
$mform->setType('dependitem', PARAM_ALPHA);
|
||||
}
|
||||
|
||||
$position_select = $mform->addElement('select',
|
||||
'position',
|
||||
get_string('position', 'feedback').' ',
|
||||
$positionlist);
|
||||
$position_select->setValue($position);
|
||||
|
||||
|
||||
$mform->addElement('hidden', 'cmid', $common['cmid']);
|
||||
$mform->setType('cmid', PARAM_INT);
|
||||
|
||||
$mform->addElement('hidden', 'id', $common['id']);
|
||||
$mform->setType('id', PARAM_INT);
|
||||
|
||||
$mform->addElement('hidden', 'feedback', $common['feedback']);
|
||||
$mform->setType('feedback', PARAM_INT);
|
||||
|
||||
$mform->addElement('hidden', 'template', 0);
|
||||
$mform->setType('template', PARAM_INT);
|
||||
|
||||
$mform->setType('name', PARAM_RAW);
|
||||
$mform->setType('label', PARAM_ALPHANUM);
|
||||
|
||||
$mform->addElement('hidden', 'typ', $this->type);
|
||||
$mform->setType('typ', PARAM_ALPHA);
|
||||
|
||||
$mform->addElement('hidden', 'hasvalue', 0);
|
||||
$mform->setType('hasvalue', PARAM_INT);
|
||||
|
||||
$mform->addElement('hidden', 'options', '');
|
||||
$mform->setType('options', PARAM_ALPHA);
|
||||
|
||||
|
||||
$buttonarray = array();
|
||||
if(!empty($item->id)){
|
||||
$buttonarray[] = &$mform->createElement('submit', 'update_item', get_string('update_item', 'feedback'));
|
||||
}else{
|
||||
$buttonarray[] = &$mform->createElement('submit', 'save_item', get_string('save_item', 'feedback'));
|
||||
}
|
||||
$buttonarray[] = &$mform->createElement('cancel');
|
||||
$mform->addGroup($buttonarray, 'buttonar', ' ', array(' '), false);
|
||||
|
||||
parent::definition();
|
||||
$this->set_data($item);
|
||||
|
||||
}
|
||||
|
@ -5,8 +5,80 @@ require_once $CFG->libdir.'/formslib.php';
|
||||
define('FEEDBACK_ITEM_NAME_TEXTBOX_SIZE', 80);
|
||||
define('FEEDBACK_ITEM_LABEL_TEXTBOX_SIZE', 20);
|
||||
abstract class feedback_item_form extends moodleform {
|
||||
function get_item_form() {
|
||||
return $this->_form;
|
||||
function definition() {
|
||||
$item = $this->_customdata['item']; //the item object
|
||||
|
||||
//common is an array like:
|
||||
// array('cmid'=>$cm->id,
|
||||
// 'id'=>isset($item->id) ? $item->id : NULL,
|
||||
// 'typ'=>$item->typ,
|
||||
// 'items'=>$feedbackitems,
|
||||
// 'feedback'=>$feedback->id);
|
||||
$common = $this->_customdata['common'];
|
||||
|
||||
//positionlist is an array with possible positions for the item location
|
||||
$positionlist = $this->_customdata['positionlist'];
|
||||
|
||||
//the current position of the item
|
||||
$position = $this->_customdata['position'];
|
||||
|
||||
$mform =& $this->_form;
|
||||
|
||||
if($common['items']) {
|
||||
$mform->addElement('select',
|
||||
'dependitem',
|
||||
get_string('dependitem', 'feedback').' ',
|
||||
$common['items']
|
||||
);
|
||||
$mform->addHelpButton('dependitem', 'depending', 'feedback');
|
||||
$mform->addElement('text', 'dependvalue', get_string('dependvalue', 'feedback'), array('size="'.FEEDBACK_ITEM_LABEL_TEXTBOX_SIZE.'"','maxlength="255"'));
|
||||
}else {
|
||||
$mform->addElement('hidden', 'dependitem', 0);
|
||||
$mform->setType('dependitem', PARAM_INT);
|
||||
$mform->addElement('hidden', 'dependvalue', '');
|
||||
$mform->setType('dependitem', PARAM_ALPHA);
|
||||
}
|
||||
|
||||
$position_select = $mform->addElement('select',
|
||||
'position',
|
||||
get_string('position', 'feedback').' ',
|
||||
$positionlist);
|
||||
$position_select->setValue($position);
|
||||
|
||||
|
||||
$mform->addElement('hidden', 'cmid', $common['cmid']);
|
||||
$mform->setType('cmid', PARAM_INT);
|
||||
|
||||
$mform->addElement('hidden', 'id', $common['id']);
|
||||
$mform->setType('id', PARAM_INT);
|
||||
|
||||
$mform->addElement('hidden', 'feedback', $common['feedback']);
|
||||
$mform->setType('feedback', PARAM_INT);
|
||||
|
||||
$mform->addElement('hidden', 'template', 0);
|
||||
$mform->setType('template', PARAM_INT);
|
||||
|
||||
$mform->setType('name', PARAM_RAW);
|
||||
$mform->setType('label', PARAM_ALPHANUM);
|
||||
|
||||
$mform->addElement('hidden', 'typ', $this->type);
|
||||
$mform->setType('typ', PARAM_ALPHA);
|
||||
|
||||
$mform->addElement('hidden', 'hasvalue', 0);
|
||||
$mform->setType('hasvalue', PARAM_INT);
|
||||
|
||||
$mform->addElement('hidden', 'options', '');
|
||||
$mform->setType('options', PARAM_ALPHA);
|
||||
|
||||
$buttonarray = array();
|
||||
if(!empty($item->id)){
|
||||
$buttonarray[] = &$mform->createElement('submit', 'update_item', get_string('update_item', 'feedback'));
|
||||
}else{
|
||||
$buttonarray[] = &$mform->createElement('submit', 'save_item', get_string('save_item', 'feedback'));
|
||||
}
|
||||
$buttonarray[] = &$mform->createElement('cancel');
|
||||
$mform->addGroup($buttonarray, 'buttonar', ' ', array(' '), false);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,65 +27,7 @@ class feedback_info_form extends feedback_item_form {
|
||||
$options[3] = get_string('coursecategory');
|
||||
$this->infotype = &$mform->addElement('select', 'presentation', get_string('infotype', 'feedback'), $options);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//the following is used in all itemforms
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//itemdepending
|
||||
if($common['items']) {
|
||||
$mform->addElement('select',
|
||||
'dependitem',
|
||||
get_string('dependitem', 'feedback').' ',
|
||||
$common['items']
|
||||
);
|
||||
$mform->addHelpButton('dependitem', 'depending', 'feedback');
|
||||
$mform->addElement('text', 'dependvalue', get_string('dependvalue', 'feedback'), array('size="'.FEEDBACK_ITEM_LABEL_TEXTBOX_SIZE.'"','maxlength="255"'));
|
||||
}else {
|
||||
$mform->addElement('hidden', 'dependitem', 0);
|
||||
$mform->setType('dependitem', PARAM_INT);
|
||||
$mform->addElement('hidden', 'dependvalue', '');
|
||||
$mform->setType('dependitem', PARAM_ALPHA);
|
||||
}
|
||||
|
||||
$position_select = $mform->addElement('select',
|
||||
'position',
|
||||
get_string('position', 'feedback').' ',
|
||||
$positionlist);
|
||||
$position_select->setValue($position);
|
||||
|
||||
|
||||
$mform->addElement('hidden', 'cmid', $common['cmid']);
|
||||
$mform->setType('cmid', PARAM_INT);
|
||||
|
||||
$mform->addElement('hidden', 'id', $common['id']);
|
||||
$mform->setType('id', PARAM_INT);
|
||||
|
||||
$mform->addElement('hidden', 'feedback', $common['feedback']);
|
||||
$mform->setType('feedback', PARAM_INT);
|
||||
|
||||
$mform->addElement('hidden', 'template', 0);
|
||||
$mform->setType('template', PARAM_INT);
|
||||
|
||||
$mform->setType('name', PARAM_RAW);
|
||||
$mform->setType('label', PARAM_ALPHANUM);
|
||||
|
||||
$mform->addElement('hidden', 'typ', $this->type);
|
||||
$mform->setType('typ', PARAM_ALPHA);
|
||||
|
||||
$mform->addElement('hidden', 'hasvalue', 0);
|
||||
$mform->setType('hasvalue', PARAM_INT);
|
||||
|
||||
$mform->addElement('hidden', 'options', '');
|
||||
$mform->setType('options', PARAM_ALPHA);
|
||||
|
||||
$buttonarray = array();
|
||||
if(!empty($item->id)){
|
||||
$buttonarray[] = &$mform->createElement('submit', 'update_item', get_string('update_item', 'feedback'));
|
||||
}else{
|
||||
$buttonarray[] = &$mform->createElement('submit', 'save_item', get_string('save_item', 'feedback'));
|
||||
}
|
||||
$buttonarray[] = &$mform->createElement('cancel');
|
||||
$mform->addGroup($buttonarray, 'buttonar', ' ', array(' '), false);
|
||||
|
||||
parent::definition();
|
||||
$this->set_data($item);
|
||||
|
||||
}
|
||||
|
@ -31,63 +31,7 @@ class feedback_label_form extends feedback_item_form {
|
||||
$mform->addElement('editor', 'presentation_editor', '', null, $presentationoptions);
|
||||
$mform->setType('presentation_editor', PARAM_CLEANHTML);
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//the following is used in all itemforms
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//itemdepending
|
||||
if($common['items']) {
|
||||
$mform->addElement('select',
|
||||
'dependitem',
|
||||
get_string('dependitem', 'feedback').' ',
|
||||
$common['items']
|
||||
);
|
||||
$mform->addHelpButton('dependitem', 'depending', 'feedback');
|
||||
$mform->addElement('text', 'dependvalue', get_string('dependvalue', 'feedback'), array('size="'.FEEDBACK_ITEM_LABEL_TEXTBOX_SIZE.'"','maxlength="255"'));
|
||||
}else {
|
||||
$mform->addElement('hidden', 'dependitem', 0);
|
||||
$mform->setType('dependitem', PARAM_INT);
|
||||
$mform->addElement('hidden', 'dependvalue', '');
|
||||
$mform->setType('dependitem', PARAM_ALPHA);
|
||||
}
|
||||
|
||||
$position_select = $mform->addElement('select',
|
||||
'position',
|
||||
get_string('position', 'feedback').' ',
|
||||
$positionlist);
|
||||
$position_select->setValue($position);
|
||||
|
||||
|
||||
$mform->addElement('hidden', 'cmid', $common['cmid']);
|
||||
$mform->setType('cmid', PARAM_INT);
|
||||
|
||||
$mform->addElement('hidden', 'id', $common['id']);
|
||||
$mform->setType('id', PARAM_INT);
|
||||
|
||||
$mform->addElement('hidden', 'feedback', $common['feedback']);
|
||||
$mform->setType('feedback', PARAM_INT);
|
||||
|
||||
$mform->addElement('hidden', 'template', 0);
|
||||
$mform->setType('template', PARAM_INT);
|
||||
|
||||
$mform->addElement('hidden', 'typ', $this->type);
|
||||
$mform->setType('typ', PARAM_ALPHA);
|
||||
|
||||
$mform->addElement('hidden', 'hasvalue', 0);
|
||||
$mform->setType('hasvalue', PARAM_INT);
|
||||
|
||||
$mform->addElement('hidden', 'options', '');
|
||||
$mform->setType('options', PARAM_ALPHA);
|
||||
|
||||
$buttonarray = array();
|
||||
if(!empty($item->id)){
|
||||
$buttonarray[] = &$mform->createElement('submit', 'update_item', get_string('update_item', 'feedback'));
|
||||
}else{
|
||||
$buttonarray[] = &$mform->createElement('submit', 'save_item', get_string('save_item', 'feedback'));
|
||||
}
|
||||
$buttonarray[] = &$mform->createElement('cancel');
|
||||
$mform->addGroup($buttonarray, 'buttonar', ' ', array(' '), false);
|
||||
|
||||
parent::definition();
|
||||
$this->set_data($item);
|
||||
|
||||
}
|
||||
|
@ -40,66 +40,7 @@ class feedback_multichoice_form extends feedback_item_form {
|
||||
|
||||
$mform->addElement('textarea', 'values', '', 'wrap="virtual" rows="10" cols="65"');
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//the following is used in all itemforms
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//itemdepending
|
||||
if($common['items']) {
|
||||
$mform->addElement('select',
|
||||
'dependitem',
|
||||
get_string('dependitem', 'feedback').' ',
|
||||
$common['items']
|
||||
);
|
||||
$mform->addHelpButton('dependitem', 'depending', 'feedback');
|
||||
$mform->addElement('text', 'dependvalue', get_string('dependvalue', 'feedback'), array('size="'.FEEDBACK_ITEM_LABEL_TEXTBOX_SIZE.'"','maxlength="255"'));
|
||||
}else {
|
||||
$mform->addElement('hidden', 'dependitem', 0);
|
||||
$mform->setType('dependitem', PARAM_INT);
|
||||
$mform->addElement('hidden', 'dependvalue', '');
|
||||
$mform->setType('dependitem', PARAM_ALPHA);
|
||||
}
|
||||
|
||||
$position_select = $mform->addElement('select',
|
||||
'position',
|
||||
get_string('position', 'feedback').' ',
|
||||
$positionlist);
|
||||
$position_select->setValue($position);
|
||||
|
||||
|
||||
$mform->addElement('hidden', 'cmid', $common['cmid']);
|
||||
$mform->setType('cmid', PARAM_INT);
|
||||
|
||||
$mform->addElement('hidden', 'id', $common['id']);
|
||||
$mform->setType('id', PARAM_INT);
|
||||
|
||||
$mform->addElement('hidden', 'feedback', $common['feedback']);
|
||||
$mform->setType('feedback', PARAM_INT);
|
||||
|
||||
$mform->addElement('hidden', 'template', 0);
|
||||
$mform->setType('template', PARAM_INT);
|
||||
|
||||
$mform->setType('name', PARAM_RAW);
|
||||
$mform->setType('label', PARAM_ALPHANUM);
|
||||
|
||||
$mform->addElement('hidden', 'typ', $this->type);
|
||||
$mform->setType('typ', PARAM_ALPHA);
|
||||
|
||||
$mform->addElement('hidden', 'hasvalue', 0);
|
||||
$mform->setType('hasvalue', PARAM_INT);
|
||||
|
||||
$mform->addElement('hidden', 'options', '');
|
||||
$mform->setType('options', PARAM_ALPHA);
|
||||
|
||||
$buttonarray = array();
|
||||
if(!empty($item->id)){
|
||||
$buttonarray[] = &$mform->createElement('submit', 'update_item', get_string('update_item', 'feedback'));
|
||||
}else{
|
||||
$buttonarray[] = &$mform->createElement('submit', 'save_item', get_string('save_item', 'feedback'));
|
||||
}
|
||||
$buttonarray[] = &$mform->createElement('cancel');
|
||||
$mform->addGroup($buttonarray, 'buttonar', ' ', array(' '), false);
|
||||
|
||||
parent::definition();
|
||||
$this->set_data($item);
|
||||
|
||||
}
|
||||
|
@ -38,66 +38,7 @@ class feedback_multichoicerated_form extends feedback_item_form {
|
||||
|
||||
$this->values = $mform->addElement('textarea', 'values', '', 'wrap="virtual" rows="10" cols="65"');
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//the following is used in all itemforms
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//itemdepending
|
||||
if($common['items']) {
|
||||
$mform->addElement('select',
|
||||
'dependitem',
|
||||
get_string('dependitem', 'feedback').' ',
|
||||
$common['items']
|
||||
);
|
||||
$mform->addHelpButton('dependitem', 'depending', 'feedback');
|
||||
$mform->addElement('text', 'dependvalue', get_string('dependvalue', 'feedback'), array('size="'.FEEDBACK_ITEM_LABEL_TEXTBOX_SIZE.'"','maxlength="255"'));
|
||||
}else {
|
||||
$mform->addElement('hidden', 'dependitem', 0);
|
||||
$mform->setType('dependitem', PARAM_INT);
|
||||
$mform->addElement('hidden', 'dependvalue', '');
|
||||
$mform->setType('dependitem', PARAM_ALPHA);
|
||||
}
|
||||
|
||||
$position_select = $mform->addElement('select',
|
||||
'position',
|
||||
get_string('position', 'feedback').' ',
|
||||
$positionlist);
|
||||
$position_select->setValue($position);
|
||||
|
||||
|
||||
$mform->addElement('hidden', 'cmid', $common['cmid']);
|
||||
$mform->setType('cmid', PARAM_INT);
|
||||
|
||||
$mform->addElement('hidden', 'id', $common['id']);
|
||||
$mform->setType('id', PARAM_INT);
|
||||
|
||||
$mform->addElement('hidden', 'feedback', $common['feedback']);
|
||||
$mform->setType('feedback', PARAM_INT);
|
||||
|
||||
$mform->addElement('hidden', 'template', 0);
|
||||
$mform->setType('template', PARAM_INT);
|
||||
|
||||
$mform->setType('name', PARAM_RAW);
|
||||
$mform->setType('label', PARAM_ALPHANUM);
|
||||
|
||||
$mform->addElement('hidden', 'typ', $this->type);
|
||||
$mform->setType('typ', PARAM_ALPHA);
|
||||
|
||||
$mform->addElement('hidden', 'hasvalue', 0);
|
||||
$mform->setType('hasvalue', PARAM_INT);
|
||||
|
||||
$mform->addElement('hidden', 'options', '');
|
||||
$mform->setType('options', PARAM_ALPHA);
|
||||
|
||||
$buttonarray = array();
|
||||
if(!empty($item->id)){
|
||||
$buttonarray[] = &$mform->createElement('submit', 'update_item', get_string('update_item', 'feedback'));
|
||||
}else{
|
||||
$buttonarray[] = &$mform->createElement('submit', 'save_item', get_string('save_item', 'feedback'));
|
||||
}
|
||||
$buttonarray[] = &$mform->createElement('cancel');
|
||||
$mform->addGroup($buttonarray, 'buttonar', ' ', array(' '), false);
|
||||
|
||||
parent::definition();
|
||||
$this->set_data($item);
|
||||
|
||||
}
|
||||
|
@ -24,66 +24,7 @@ class feedback_numeric_form extends feedback_item_form {
|
||||
|
||||
$mform->addElement('text', 'rangeto', get_string('numeric_range_to', 'feedback'), array('size="10"','maxlength="10"'));
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//the following is used in all itemforms
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//itemdepending
|
||||
if($common['items']) {
|
||||
$mform->addElement('select',
|
||||
'dependitem',
|
||||
get_string('dependitem', 'feedback').' ',
|
||||
$common['items']
|
||||
);
|
||||
$mform->addHelpButton('dependitem', 'depending', 'feedback');
|
||||
$mform->addElement('text', 'dependvalue', get_string('dependvalue', 'feedback'), array('size="'.FEEDBACK_ITEM_LABEL_TEXTBOX_SIZE.'"','maxlength="255"'));
|
||||
}else {
|
||||
$mform->addElement('hidden', 'dependitem', 0);
|
||||
$mform->setType('dependitem', PARAM_INT);
|
||||
$mform->addElement('hidden', 'dependvalue', '');
|
||||
$mform->setType('dependitem', PARAM_ALPHA);
|
||||
}
|
||||
|
||||
$position_select = $mform->addElement('select',
|
||||
'position',
|
||||
get_string('position', 'feedback').' ',
|
||||
$positionlist);
|
||||
$position_select->setValue($position);
|
||||
|
||||
|
||||
$mform->addElement('hidden', 'cmid', $common['cmid']);
|
||||
$mform->setType('cmid', PARAM_INT);
|
||||
|
||||
$mform->addElement('hidden', 'id', $common['id']);
|
||||
$mform->setType('id', PARAM_INT);
|
||||
|
||||
$mform->addElement('hidden', 'feedback', $common['feedback']);
|
||||
$mform->setType('feedback', PARAM_INT);
|
||||
|
||||
$mform->addElement('hidden', 'template', 0);
|
||||
$mform->setType('template', PARAM_INT);
|
||||
|
||||
$mform->setType('name', PARAM_RAW);
|
||||
$mform->setType('label', PARAM_ALPHANUM);
|
||||
|
||||
$mform->addElement('hidden', 'typ', $this->type);
|
||||
$mform->setType('typ', PARAM_ALPHA);
|
||||
|
||||
$mform->addElement('hidden', 'hasvalue', 0);
|
||||
$mform->setType('hasvalue', PARAM_INT);
|
||||
|
||||
$mform->addElement('hidden', 'options', '');
|
||||
$mform->setType('options', PARAM_ALPHA);
|
||||
|
||||
$buttonarray = array();
|
||||
if(!empty($item->id)){
|
||||
$buttonarray[] = &$mform->createElement('submit', 'update_item', get_string('update_item', 'feedback'));
|
||||
}else{
|
||||
$buttonarray[] = &$mform->createElement('submit', 'save_item', get_string('save_item', 'feedback'));
|
||||
}
|
||||
$buttonarray[] = &$mform->createElement('cancel');
|
||||
$mform->addGroup($buttonarray, 'buttonar', ' ', array(' '), false);
|
||||
|
||||
parent::definition();
|
||||
$this->set_data($item);
|
||||
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ class feedback_item_textarea extends feedback_item_base {
|
||||
$item->presentation = empty($item->presentation) ? '' : $item->presentation;
|
||||
|
||||
$widthAndHeight = explode('|',$item->presentation);
|
||||
$itemwidth = isset($widthAndHeight[0]) ? $widthAndHeight[0] : 30;
|
||||
$itemwidth = (isset($widthAndHeight[0]) AND $widthAndHeight[0] >= 5) ? $widthAndHeight[0] : 30;
|
||||
$itemheight = isset($widthAndHeight[1]) ? $widthAndHeight[1] : 5;
|
||||
$item->itemwidth = $itemwidth;
|
||||
$item->itemheight = $itemheight;
|
||||
|
@ -29,66 +29,7 @@ class feedback_textarea_form extends feedback_item_form {
|
||||
get_string('textarea_height', 'feedback').' ',
|
||||
array_slice(range(0,40),5,40,true));
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//the following is used in all itemforms
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//itemdepending
|
||||
if($common['items']) {
|
||||
$mform->addElement('select',
|
||||
'dependitem',
|
||||
get_string('dependitem', 'feedback').' ',
|
||||
$common['items']
|
||||
);
|
||||
$mform->addHelpButton('dependitem', 'depending', 'feedback');
|
||||
$mform->addElement('text', 'dependvalue', get_string('dependvalue', 'feedback'), array('size="'.FEEDBACK_ITEM_LABEL_TEXTBOX_SIZE.'"','maxlength="255"'));
|
||||
}else {
|
||||
$mform->addElement('hidden', 'dependitem', 0);
|
||||
$mform->setType('dependitem', PARAM_INT);
|
||||
$mform->addElement('hidden', 'dependvalue', '');
|
||||
$mform->setType('dependitem', PARAM_ALPHA);
|
||||
}
|
||||
|
||||
$position_select = $mform->addElement('select',
|
||||
'position',
|
||||
get_string('position', 'feedback').' ',
|
||||
$positionlist);
|
||||
$position_select->setValue($position);
|
||||
|
||||
|
||||
$mform->addElement('hidden', 'cmid', $common['cmid']);
|
||||
$mform->setType('cmid', PARAM_INT);
|
||||
|
||||
$mform->addElement('hidden', 'id', $common['id']);
|
||||
$mform->setType('id', PARAM_INT);
|
||||
|
||||
$mform->addElement('hidden', 'feedback', $common['feedback']);
|
||||
$mform->setType('feedback', PARAM_INT);
|
||||
|
||||
$mform->addElement('hidden', 'template', 0);
|
||||
$mform->setType('template', PARAM_INT);
|
||||
|
||||
$mform->setType('name', PARAM_RAW);
|
||||
$mform->setType('label', PARAM_ALPHANUM);
|
||||
|
||||
$mform->addElement('hidden', 'typ', $this->type);
|
||||
$mform->setType('typ', PARAM_ALPHA);
|
||||
|
||||
$mform->addElement('hidden', 'hasvalue', 0);
|
||||
$mform->setType('hasvalue', PARAM_INT);
|
||||
|
||||
$mform->addElement('hidden', 'options', '');
|
||||
$mform->setType('options', PARAM_ALPHA);
|
||||
|
||||
$buttonarray = array();
|
||||
if(!empty($item->id)){
|
||||
$buttonarray[] = &$mform->createElement('submit', 'update_item', get_string('update_item', 'feedback'));
|
||||
}else{
|
||||
$buttonarray[] = &$mform->createElement('submit', 'save_item', get_string('save_item', 'feedback'));
|
||||
}
|
||||
$buttonarray[] = &$mform->createElement('cancel');
|
||||
$mform->addGroup($buttonarray, 'buttonar', ' ', array(' '), false);
|
||||
|
||||
parent::definition();
|
||||
$this->set_data($item);
|
||||
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ class feedback_item_textfield extends feedback_item_base {
|
||||
$item->presentation = empty($item->presentation) ? '' : $item->presentation;
|
||||
|
||||
$sizeAndLength = explode('|',$item->presentation);
|
||||
$itemsize = isset($sizeAndLength[0]) ? $sizeAndLength[0] : 30;
|
||||
$itemsize = (isset($sizeAndLength[0]) AND $sizeAndLength[0] >= 5) ? $sizeAndLength[0] : 30;
|
||||
$itemlength = isset($sizeAndLength[1]) ? $sizeAndLength[1] : 5;
|
||||
$item->itemsize = $itemsize;
|
||||
$item->itemmaxlength = $itemlength;
|
||||
|
@ -29,66 +29,7 @@ class feedback_textfield_form extends feedback_item_form {
|
||||
get_string('textfield_maxlength', 'feedback').' ',
|
||||
array_slice(range(0,255),5,255,true));
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//the following is used in all itemforms
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//itemdepending
|
||||
if($common['items']) {
|
||||
$mform->addElement('select',
|
||||
'dependitem',
|
||||
get_string('dependitem', 'feedback').' ',
|
||||
$common['items']
|
||||
);
|
||||
$mform->addHelpButton('dependitem', 'depending', 'feedback');
|
||||
$mform->addElement('text', 'dependvalue', get_string('dependvalue', 'feedback'), array('size="'.FEEDBACK_ITEM_LABEL_TEXTBOX_SIZE.'"','maxlength="255"'));
|
||||
}else {
|
||||
$mform->addElement('hidden', 'dependitem', 0);
|
||||
$mform->setType('dependitem', PARAM_INT);
|
||||
$mform->addElement('hidden', 'dependvalue', '');
|
||||
$mform->setType('dependitem', PARAM_ALPHA);
|
||||
}
|
||||
|
||||
$position_select = $mform->addElement('select',
|
||||
'position',
|
||||
get_string('position', 'feedback').' ',
|
||||
$positionlist);
|
||||
$position_select->setValue($position);
|
||||
|
||||
|
||||
$mform->addElement('hidden', 'cmid', $common['cmid']);
|
||||
$mform->setType('cmid', PARAM_INT);
|
||||
|
||||
$mform->addElement('hidden', 'id', $common['id']);
|
||||
$mform->setType('id', PARAM_INT);
|
||||
|
||||
$mform->addElement('hidden', 'feedback', $common['feedback']);
|
||||
$mform->setType('feedback', PARAM_INT);
|
||||
|
||||
$mform->addElement('hidden', 'template', 0);
|
||||
$mform->setType('template', PARAM_INT);
|
||||
|
||||
$mform->setType('name', PARAM_RAW);
|
||||
$mform->setType('label', PARAM_ALPHANUM);
|
||||
|
||||
$mform->addElement('hidden', 'typ', $this->type);
|
||||
$mform->setType('typ', PARAM_ALPHA);
|
||||
|
||||
$mform->addElement('hidden', 'hasvalue', 0);
|
||||
$mform->setType('hasvalue', PARAM_INT);
|
||||
|
||||
$mform->addElement('hidden', 'options', '');
|
||||
$mform->setType('options', PARAM_ALPHA);
|
||||
|
||||
$buttonarray = array();
|
||||
if(!empty($item->id)){
|
||||
$buttonarray[] = &$mform->createElement('submit', 'update_item', get_string('update_item', 'feedback'));
|
||||
}else{
|
||||
$buttonarray[] = &$mform->createElement('submit', 'save_item', get_string('save_item', 'feedback'));
|
||||
}
|
||||
$buttonarray[] = &$mform->createElement('cancel');
|
||||
$mform->addGroup($buttonarray, 'buttonar', ' ', array(' '), false);
|
||||
|
||||
parent::definition();
|
||||
$this->set_data($item);
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user