MDL-41640 mod_feedback: info question should default to course

Also hide "response time" from options in case of anonymous feedback
This commit is contained in:
Marina Glancy 2016-05-03 15:31:37 +08:00 committed by Andrew Nicols
parent ac29314ed1
commit c0dd0e3543
2 changed files with 15 additions and 7 deletions

View file

@ -25,6 +25,7 @@ class feedback_info_form extends feedback_item_form {
$common = $this->_customdata['common'];
$positionlist = $this->_customdata['positionlist'];
$position = $this->_customdata['position'];
$presentationoptions = $this->_customdata['presentationoptions'];
$mform =& $this->_form;
@ -41,14 +42,10 @@ class feedback_info_form extends feedback_item_form {
get_string('item_label', 'feedback'),
array('size'=>FEEDBACK_ITEM_LABEL_TEXTBOX_SIZE, 'maxlength'=>255));
$options=array();
$options[1] = get_string('responsetime', 'feedback');
$options[2] = get_string('course');
$options[3] = get_string('coursecategory');
$this->infotype = &$mform->addElement('select',
'presentation',
get_string('infotype', 'feedback'),
$options);
$presentationoptions);
parent::definition();
$this->set_data($item);

View file

@ -48,7 +48,7 @@ class feedback_item_info extends feedback_item_base {
//the elements for position dropdownlist
$positionlist = array_slice(range(0, $i_formselect_last), 1, $i_formselect_last, true);
$item->presentation = empty($item->presentation) ? 1 : $item->presentation;
$item->presentation = empty($item->presentation) ? self::MODE_COURSE : $item->presentation;
$item->required = 0;
//all items for dependitem
@ -59,12 +59,23 @@ class feedback_item_info extends feedback_item_base {
'items'=>$feedbackitems,
'feedback'=>$feedback->id);
// Options for the 'presentation' select element.
$presentationoptions = array();
if ($feedback->anonymous == FEEDBACK_ANONYMOUS_NO || $item->presentation == self::MODE_RESPONSETIME) {
// "Response time" is hidden anyway in case of anonymous feedback, no reason to offer this option.
// However if it was already selected leave it in the dropdown.
$presentationoptions[self::MODE_RESPONSETIME] = get_string('responsetime', 'feedback');
}
$presentationoptions[self::MODE_COURSE] = get_string('course');
$presentationoptions[self::MODE_CATEGORY] = get_string('coursecategory');
//build the form
$this->item_form = new feedback_info_form('edit_item.php',
array('item'=>$item,
'common'=>$commonparams,
'positionlist'=>$positionlist,
'position' => $position));
'position' => $position,
'presentationoptions' => $presentationoptions));
}
public function save_item() {