require_once($CFG->dirroot.'/mod/feedback/item/'.$typ.'/lib.php');
-//new formdefinition
$itemclass = 'feedback_item_'.$typ;
$itemobj = new $itemclass();
-$item_form = &$itemobj->show_edit($item);
-
-$i_form = &$item_form->get_item_form();
-// $i_form->addElement('header', 'general', 'Titel');
-$i_form->addElement('hidden', 'cmid', $cmid);
-$i_form->setType('cmid', PARAM_INT);
-$i_form->addElement('hidden', 'id', isset($item->id)?$item->id:'');
-$i_form->setType('id', PARAM_INT);
-$i_form->addElement('hidden', 'typ', $typ);
-$i_form->setType('typ', PARAM_ALPHA);
-$i_form->addElement('hidden', 'feedbackid', $feedback->id);
-$i_form->setType('feedbackid', PARAM_INT);
-
$lastposition = $DB->count_records('feedback_item', array('feedback'=>$feedback->id));
if($position == -1){
$i_formselect_last = $lastposition;
$i_formselect_value = $item->position;
}
-$i_formselect = $i_form->addElement('select',
- 'position',
- get_string('position', 'feedback').' ',
- array_slice(range(0,$i_formselect_last),1,$i_formselect_last,true));
-$i_formselect->setValue($i_formselect_value);
-
-$buttonarray = array();
-if(!empty($item->id)){
- $i_form->addElement('hidden', 'updateitem', '1');
- $i_form->setType('updateitem', PARAM_INT);
- // $i_form->addElement('submit', 'update_item', get_string('update_item', 'feedback'));
- $buttonarray[] = &$i_form->createElement('submit', 'update_item', get_string('update_item', 'feedback'));
-}else{
- $i_form->addElement('hidden', 'saveitem', '1');
- $i_form->setType('saveitem', PARAM_INT);
- // $i_form->addElement('submit', 'save_item', get_string('save_item', 'feedback'));
- $buttonarray[] = &$i_form->createElement('submit', 'save_item', get_string('save_item', 'feedback'));
-}
-// $i_form->addElement('cancel');
-$buttonarray[] = &$i_form->createElement('cancel');
-$i_form->addGroup($buttonarray, 'buttonar', '', array(' '), false);
+$positionlist = array_slice(range(0,$i_formselect_last),1,$i_formselect_last,true);
+
+$commonarams = array('cmid'=>$cmid,
+ 'id'=>isset($item->id) ? $item->id : NULL,
+ 'typ'=>$typ,
+ 'feedbackid'=>$feedback->id);
+
+$item_form = &$itemobj->show_edit($item, $commonarams, $positionlist, $i_formselect_value);
////////////////////////////////////////////////////////////////////////////////////
$item_form->set_data($item);
get_string('count_of_nums', 'feedback').' ',
array_slice(range(0,10),3,10,true));
+
+ ////////////////////////////////////////////////////////////////////////
+ //the following is used in all itemforms
+ ////////////////////////////////////////////////////////////////////////
+ $item = $this->_customdata['item'];
+ $common = $this->_customdata['common'];
+
+ $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', 'typ', $common['typ']);
+ $mform->setType('typ', PARAM_ALPHA);
+ $mform->addElement('hidden', 'feedbackid', $common['feedbackid']);
+ $mform->setType('feedbackid', PARAM_INT);
+
+ $position_select = $mform->addElement('select',
+ 'position',
+ get_string('position', 'feedback').' ',
+ $this->_customdata['positionlist']);
+ $position_select->setValue($this->_customdata['position']);
+
+
+ $buttonarray = array();
+ if(!empty($item->id)){
+ $mform->addElement('hidden', 'updateitem', '1');
+ $mform->setType('updateitem', PARAM_INT);
+ // $i_form->addElement('submit', 'update_item', get_string('update_item', 'feedback'));
+ $buttonarray[] = &$mform->createElement('submit', 'update_item', get_string('update_item', 'feedback'));
+ }else{
+ $mform->addElement('hidden', 'saveitem', '1');
+ $mform->setType('saveitem', PARAM_INT);
+ // $i_form->addElement('submit', 'save_item', get_string('save_item', 'feedback'));
+ $buttonarray[] = &$mform->createElement('submit', 'save_item', get_string('save_item', 'feedback'));
+ }
+ // $i_form->addElement('cancel');
+ $buttonarray[] = &$mform->createElement('cancel');
+ $mform->addGroup($buttonarray, 'buttonar', ' ', array(' '), false);
+
}
}
}
- function show_edit($item) {
+/**
+ * Build the editform for the item
+ *
+ * @global object
+ * @param object $item the instance of the recordset feedback_item
+ * @param array $commonparams all hidden values needed in the form
+ * @param array $positionlist this array build the selection list for itemposition
+ * @param int $position the current itemposition
+ * @return object instance of the built form
+ */
+ function show_edit($item, $commonparams, $positionlist, $position) {
global $CFG;
require_once('captcha_form.php');
- $item_form = new feedback_captcha_form();
+ $item_form = new feedback_captcha_form('edit_item.php', array('item'=>$item, 'common'=>$commonparams, 'positionlist'=>$positionlist, 'position'=>$position));
$item->presentation = empty($item->presentation) ? 3 : $item->presentation;
$item->name = empty($item->name) ? '' : $item->name;
$options[3] = get_string('coursecategory', 'feedback');
$this->infotype = &$mform->addElement('select', 'infotype', get_string('infotype', 'feedback'), $options);
+
+ ////////////////////////////////////////////////////////////////////////
+ //the following is used in all itemforms
+ ////////////////////////////////////////////////////////////////////////
+ $item = $this->_customdata['item'];
+ $common = $this->_customdata['common'];
+
+ $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', 'typ', $common['typ']);
+ $mform->setType('typ', PARAM_ALPHA);
+ $mform->addElement('hidden', 'feedbackid', $common['feedbackid']);
+ $mform->setType('feedbackid', PARAM_INT);
+
+ $position_select = $mform->addElement('select',
+ 'position',
+ get_string('position', 'feedback').' ',
+ $this->_customdata['positionlist']);
+ $position_select->setValue($this->_customdata['position']);
+
+
+ $buttonarray = array();
+ if(!empty($item->id)){
+ $mform->addElement('hidden', 'updateitem', '1');
+ $mform->setType('updateitem', PARAM_INT);
+ // $i_form->addElement('submit', 'update_item', get_string('update_item', 'feedback'));
+ $buttonarray[] = &$mform->createElement('submit', 'update_item', get_string('update_item', 'feedback'));
+ }else{
+ $mform->addElement('hidden', 'saveitem', '1');
+ $mform->setType('saveitem', PARAM_INT);
+ // $i_form->addElement('submit', 'save_item', get_string('save_item', 'feedback'));
+ $buttonarray[] = &$mform->createElement('submit', 'save_item', get_string('save_item', 'feedback'));
+ }
+ // $i_form->addElement('cancel');
+ $buttonarray[] = &$mform->createElement('cancel');
+ $mform->addGroup($buttonarray, 'buttonar', ' ', array(' '), false);
+
}
}
}
- function &show_edit($item) {
+ function show_edit($item, $commonparams, $positionlist, $position) {
global $CFG;
require_once('info_form.php');
- $item_form = new feedback_info_form();
+ $item_form = new feedback_info_form('edit_item.php', array('item'=>$item, 'common'=>$commonparams, 'positionlist'=>$positionlist, 'position'=>$position));
$item->presentation = empty($item->presentation) ? '' : $item->presentation;
$item->name = empty($item->name) ? '' : htmlspecialchars($item->name);
$mform->setType('itemname', PARAM_INT);
$mform->addElement('editor', 'presentation', '', null, null);
$mform->setType('presentation', PARAM_CLEANHTML);
+
+
+ ////////////////////////////////////////////////////////////////////////
+ //the following is used in all itemforms
+ ////////////////////////////////////////////////////////////////////////
+ $item = $this->_customdata['item'];
+ $common = $this->_customdata['common'];
+
+ $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', 'typ', $common['typ']);
+ $mform->setType('typ', PARAM_ALPHA);
+ $mform->addElement('hidden', 'feedbackid', $common['feedbackid']);
+ $mform->setType('feedbackid', PARAM_INT);
+
+ $position_select = $mform->addElement('select',
+ 'position',
+ get_string('position', 'feedback').' ',
+ $this->_customdata['positionlist']);
+ $position_select->setValue($this->_customdata['position']);
+
+
+ $buttonarray = array();
+ if(!empty($item->id)){
+ $mform->addElement('hidden', 'updateitem', '1');
+ $mform->setType('updateitem', PARAM_INT);
+ // $i_form->addElement('submit', 'update_item', get_string('update_item', 'feedback'));
+ $buttonarray[] = &$mform->createElement('submit', 'update_item', get_string('update_item', 'feedback'));
+ }else{
+ $mform->addElement('hidden', 'saveitem', '1');
+ $mform->setType('saveitem', PARAM_INT);
+ // $i_form->addElement('submit', 'save_item', get_string('save_item', 'feedback'));
+ $buttonarray[] = &$mform->createElement('submit', 'save_item', get_string('save_item', 'feedback'));
+ }
+ // $i_form->addElement('cancel');
+ $buttonarray[] = &$mform->createElement('cancel');
+ $mform->addGroup($buttonarray, 'buttonar', ' ', array(' '), false);
+
}
function get_data() {
}
function set_data($data) {
- $data->presentation = array('text'=>$data->presentation, 'format'=>FORMAT_HTML, 'itemid'=>0);
+ if(isset($data->presentation)) {
+ $data->presentation = array('text'=>$data->presentation, 'format'=>FORMAT_HTML, 'itemid'=>0);
+ }
return parent::set_data($data);
}
}
}
- function show_edit($item) {
+ function show_edit($item, $commonparams, $positionlist, $position) {
global $CFG;
require_once('label_form.php');
- $item_form = new feedback_label_form();
+ $item_form = new feedback_label_form('edit_item.php', array('item'=>$item, 'common'=>$commonparams, 'positionlist'=>$positionlist, 'position'=>$position));
return $item_form;
}
}
- function show_edit($item) {
+ function show_edit($item, $commonparams, $positionlist, $position) {
global $CFG;
require_once('multichoice_form.php');
- $item_form = new feedback_multichoice_form();
+ $item_form = new feedback_multichoice_form('edit_item.php', array('item'=>$item, 'common'=>$commonparams, 'positionlist'=>$positionlist, 'position'=>$position));
$item->presentation = empty($item->presentation) ? '' : $item->presentation;
$item->name = empty($item->name) ? '' : $item->name;
$this->values = $mform->addElement('textarea', 'itemvalues', '', 'wrap="virtual" rows="10" cols="65"');
+
+ ////////////////////////////////////////////////////////////////////////
+ //the following is used in all itemforms
+ ////////////////////////////////////////////////////////////////////////
+ $item = $this->_customdata['item'];
+ $common = $this->_customdata['common'];
+
+ $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', 'typ', $common['typ']);
+ $mform->setType('typ', PARAM_ALPHA);
+ $mform->addElement('hidden', 'feedbackid', $common['feedbackid']);
+ $mform->setType('feedbackid', PARAM_INT);
+
+ $position_select = $mform->addElement('select',
+ 'position',
+ get_string('position', 'feedback').' ',
+ $this->_customdata['positionlist']);
+ $position_select->setValue($this->_customdata['position']);
+
+
+ $buttonarray = array();
+ if(!empty($item->id)){
+ $mform->addElement('hidden', 'updateitem', '1');
+ $mform->setType('updateitem', PARAM_INT);
+ // $i_form->addElement('submit', 'update_item', get_string('update_item', 'feedback'));
+ $buttonarray[] = &$mform->createElement('submit', 'update_item', get_string('update_item', 'feedback'));
+ }else{
+ $mform->addElement('hidden', 'saveitem', '1');
+ $mform->setType('saveitem', PARAM_INT);
+ // $i_form->addElement('submit', 'save_item', get_string('save_item', 'feedback'));
+ $buttonarray[] = &$mform->createElement('submit', 'save_item', get_string('save_item', 'feedback'));
+ }
+ // $i_form->addElement('cancel');
+ $buttonarray[] = &$mform->createElement('cancel');
+ $mform->addGroup($buttonarray, 'buttonar', ' ', array(' '), false);
+
}
}
}
- function show_edit($item) {
+ function show_edit($item, $commonparams, $positionlist, $position) {
global $CFG;
require_once('multichoicerated_form.php');
- $item_form = new feedback_multichoicerated_form();
+ $item_form = new feedback_multichoicerated_form('edit_item.php', array('item'=>$item, 'common'=>$commonparams, 'positionlist'=>$positionlist, 'position'=>$position));
$item->presentation = empty($item->presentation) ? '' : $item->presentation;
$item->name = empty($item->name) ? '' : $item->name;
$this->values = $mform->addElement('textarea', 'itemvalues', '', 'wrap="virtual" rows="10" cols="65"');
+
+ ////////////////////////////////////////////////////////////////////////
+ //the following is used in all itemforms
+ ////////////////////////////////////////////////////////////////////////
+ $item = $this->_customdata['item'];
+ $common = $this->_customdata['common'];
+
+ $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', 'typ', $common['typ']);
+ $mform->setType('typ', PARAM_ALPHA);
+ $mform->addElement('hidden', 'feedbackid', $common['feedbackid']);
+ $mform->setType('feedbackid', PARAM_INT);
+
+ $position_select = $mform->addElement('select',
+ 'position',
+ get_string('position', 'feedback').' ',
+ $this->_customdata['positionlist']);
+ $position_select->setValue($this->_customdata['position']);
+
+
+ $buttonarray = array();
+ if(!empty($item->id)){
+ $mform->addElement('hidden', 'updateitem', '1');
+ $mform->setType('updateitem', PARAM_INT);
+ // $i_form->addElement('submit', 'update_item', get_string('update_item', 'feedback'));
+ $buttonarray[] = &$mform->createElement('submit', 'update_item', get_string('update_item', 'feedback'));
+ }else{
+ $mform->addElement('hidden', 'saveitem', '1');
+ $mform->setType('saveitem', PARAM_INT);
+ // $i_form->addElement('submit', 'save_item', get_string('save_item', 'feedback'));
+ $buttonarray[] = &$mform->createElement('submit', 'save_item', get_string('save_item', 'feedback'));
+ }
+ // $i_form->addElement('cancel');
+ $buttonarray[] = &$mform->createElement('cancel');
+ $mform->addGroup($buttonarray, 'buttonar', ' ', array(' '), false);
+
}
}
}
}
- function show_edit($item) {
+ function show_edit($item, $commonparams, $positionlist, $position) {
global $CFG;
require_once('numeric_form.php');
- $item_form = new feedback_numeric_form();
+ $item_form = new feedback_numeric_form('edit_item.php', array('item'=>$item, 'common'=>$commonparams, 'positionlist'=>$positionlist, 'position'=>$position));
$item->presentation = empty($item->presentation) ? '' : $item->presentation;
$item->name = empty($item->name) ? '' : $item->name;
$this->selectto = $mform->addElement('text', 'numericrangeto', get_string('numeric_range_to', 'feedback'), array('size="10"','maxlength="10"'));
+
+ ////////////////////////////////////////////////////////////////////////
+ //the following is used in all itemforms
+ ////////////////////////////////////////////////////////////////////////
+ $item = $this->_customdata['item'];
+ $common = $this->_customdata['common'];
+
+ $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', 'typ', $common['typ']);
+ $mform->setType('typ', PARAM_ALPHA);
+ $mform->addElement('hidden', 'feedbackid', $common['feedbackid']);
+ $mform->setType('feedbackid', PARAM_INT);
+
+ $position_select = $mform->addElement('select',
+ 'position',
+ get_string('position', 'feedback').' ',
+ $this->_customdata['positionlist']);
+ $position_select->setValue($this->_customdata['position']);
+
+
+ $buttonarray = array();
+ if(!empty($item->id)){
+ $mform->addElement('hidden', 'updateitem', '1');
+ $mform->setType('updateitem', PARAM_INT);
+ // $i_form->addElement('submit', 'update_item', get_string('update_item', 'feedback'));
+ $buttonarray[] = &$mform->createElement('submit', 'update_item', get_string('update_item', 'feedback'));
+ }else{
+ $mform->addElement('hidden', 'saveitem', '1');
+ $mform->setType('saveitem', PARAM_INT);
+ // $i_form->addElement('submit', 'save_item', get_string('save_item', 'feedback'));
+ $buttonarray[] = &$mform->createElement('submit', 'save_item', get_string('save_item', 'feedback'));
+ }
+ // $i_form->addElement('cancel');
+ $buttonarray[] = &$mform->createElement('cancel');
+ $mform->addGroup($buttonarray, 'buttonar', ' ', array(' '), false);
+
}
}
}
- function show_edit($item) {
+ function show_edit($item, $commonparams, $positionlist, $position) {
global $CFG;
require_once('textarea_form.php');
- $item_form = new feedback_textarea_form();
+ $item_form = new feedback_textarea_form('edit_item.php', array('item'=>$item, 'common'=>$commonparams, 'positionlist'=>$positionlist, 'position'=>$position));
$item->presentation = empty($item->presentation) ? '' : $item->presentation;
$item->name = empty($item->name) ? '' : $item->name;
get_string('textarea_height', 'feedback').' ',
array_slice(range(0,40),5,40,true));
+
+ ////////////////////////////////////////////////////////////////////////
+ //the following is used in all itemforms
+ ////////////////////////////////////////////////////////////////////////
+ $item = $this->_customdata['item'];
+ $common = $this->_customdata['common'];
+
+ $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', 'typ', $common['typ']);
+ $mform->setType('typ', PARAM_ALPHA);
+ $mform->addElement('hidden', 'feedbackid', $common['feedbackid']);
+ $mform->setType('feedbackid', PARAM_INT);
+
+ $position_select = $mform->addElement('select',
+ 'position',
+ get_string('position', 'feedback').' ',
+ $this->_customdata['positionlist']);
+ $position_select->setValue($this->_customdata['position']);
+
+
+ $buttonarray = array();
+ if(!empty($item->id)){
+ $mform->addElement('hidden', 'updateitem', '1');
+ $mform->setType('updateitem', PARAM_INT);
+ // $i_form->addElement('submit', 'update_item', get_string('update_item', 'feedback'));
+ $buttonarray[] = &$mform->createElement('submit', 'update_item', get_string('update_item', 'feedback'));
+ }else{
+ $mform->addElement('hidden', 'saveitem', '1');
+ $mform->setType('saveitem', PARAM_INT);
+ // $i_form->addElement('submit', 'save_item', get_string('save_item', 'feedback'));
+ $buttonarray[] = &$mform->createElement('submit', 'save_item', get_string('save_item', 'feedback'));
+ }
+ // $i_form->addElement('cancel');
+ $buttonarray[] = &$mform->createElement('cancel');
+ $mform->addGroup($buttonarray, 'buttonar', ' ', array(' '), false);
+
}
}
}
- function show_edit($item) {
+ function show_edit($item, $commonparams, $positionlist, $position) {
global $CFG;
require_once('textfield_form.php');
- $item_form = new feedback_textfield_form();
+ $item_form = new feedback_textfield_form('edit_item.php', array('item'=>$item, 'common'=>$commonparams, 'positionlist'=>$positionlist, 'position'=>$position));
$item->presentation = empty($item->presentation) ? '' : $item->presentation;
$item->name = empty($item->name) ? '' : $item->name;
get_string('textfield_maxlength', 'feedback').' ',
array_slice(range(0,255),5,255,true));
+
+ ////////////////////////////////////////////////////////////////////////
+ //the following is used in all itemforms
+ ////////////////////////////////////////////////////////////////////////
+ $item = $this->_customdata['item'];
+ $common = $this->_customdata['common'];
+
+ $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', 'typ', $common['typ']);
+ $mform->setType('typ', PARAM_ALPHA);
+ $mform->addElement('hidden', 'feedbackid', $common['feedbackid']);
+ $mform->setType('feedbackid', PARAM_INT);
+
+ $position_select = $mform->addElement('select',
+ 'position',
+ get_string('position', 'feedback').' ',
+ $this->_customdata['positionlist']);
+ $position_select->setValue($this->_customdata['position']);
+
+
+ $buttonarray = array();
+ if(!empty($item->id)){
+ $mform->addElement('hidden', 'updateitem', '1');
+ $mform->setType('updateitem', PARAM_INT);
+ // $i_form->addElement('submit', 'update_item', get_string('update_item', 'feedback'));
+ $buttonarray[] = &$mform->createElement('submit', 'update_item', get_string('update_item', 'feedback'));
+ }else{
+ $mform->addElement('hidden', 'saveitem', '1');
+ $mform->setType('saveitem', PARAM_INT);
+ // $i_form->addElement('submit', 'save_item', get_string('save_item', 'feedback'));
+ $buttonarray[] = &$mform->createElement('submit', 'save_item', get_string('save_item', 'feedback'));
+ }
+ // $i_form->addElement('cancel');
+ $buttonarray[] = &$mform->createElement('cancel');
+ $mform->addGroup($buttonarray, 'buttonar', ' ', array(' '), false);
+
}
}