diff --git a/mod/feedback/item/captcha/captcha_form.php b/mod/feedback/item/captcha/captcha_form.php index 6110586d9e6..1bd7ab6b531 100644 --- a/mod/feedback/item/captcha/captcha_form.php +++ b/mod/feedback/item/captcha/captcha_form.php @@ -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); } diff --git a/mod/feedback/item/feedback_item_form_class.php b/mod/feedback/item/feedback_item_form_class.php index b803489b3ae..036d271bde4 100644 --- a/mod/feedback/item/feedback_item_form_class.php +++ b/mod/feedback/item/feedback_item_form_class.php @@ -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); + } } diff --git a/mod/feedback/item/info/info_form.php b/mod/feedback/item/info/info_form.php index 18de76cf360..47e7ad99fa0 100644 --- a/mod/feedback/item/info/info_form.php +++ b/mod/feedback/item/info/info_form.php @@ -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); } diff --git a/mod/feedback/item/label/label_form.php b/mod/feedback/item/label/label_form.php index ea5618fd1c4..43adeaa7dff 100644 --- a/mod/feedback/item/label/label_form.php +++ b/mod/feedback/item/label/label_form.php @@ -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); } diff --git a/mod/feedback/item/multichoice/multichoice_form.php b/mod/feedback/item/multichoice/multichoice_form.php index 5ff689c8248..7a7731eea8a 100644 --- a/mod/feedback/item/multichoice/multichoice_form.php +++ b/mod/feedback/item/multichoice/multichoice_form.php @@ -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); } diff --git a/mod/feedback/item/multichoicerated/multichoicerated_form.php b/mod/feedback/item/multichoicerated/multichoicerated_form.php index 3eb45e35a31..abee30147da 100644 --- a/mod/feedback/item/multichoicerated/multichoicerated_form.php +++ b/mod/feedback/item/multichoicerated/multichoicerated_form.php @@ -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); } diff --git a/mod/feedback/item/numeric/numeric_form.php b/mod/feedback/item/numeric/numeric_form.php index 8b44ddb8258..d3776d0a4b5 100644 --- a/mod/feedback/item/numeric/numeric_form.php +++ b/mod/feedback/item/numeric/numeric_form.php @@ -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); } diff --git a/mod/feedback/item/textarea/lib.php b/mod/feedback/item/textarea/lib.php index 51ed15e1a42..7a45e45e0f4 100644 --- a/mod/feedback/item/textarea/lib.php +++ b/mod/feedback/item/textarea/lib.php @@ -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; diff --git a/mod/feedback/item/textarea/textarea_form.php b/mod/feedback/item/textarea/textarea_form.php index 5df08894c7a..677c1709bea 100644 --- a/mod/feedback/item/textarea/textarea_form.php +++ b/mod/feedback/item/textarea/textarea_form.php @@ -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); } diff --git a/mod/feedback/item/textfield/lib.php b/mod/feedback/item/textfield/lib.php index 4cd087c8e67..669c2a89a4a 100644 --- a/mod/feedback/item/textfield/lib.php +++ b/mod/feedback/item/textfield/lib.php @@ -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; diff --git a/mod/feedback/item/textfield/textfield_form.php b/mod/feedback/item/textfield/textfield_form.php index bbaf8ed79d1..4f9fbc492ed 100644 --- a/mod/feedback/item/textfield/textfield_form.php +++ b/mod/feedback/item/textfield/textfield_form.php @@ -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); }