Skip to content

Commit

Permalink
Merge branch 'wip-MDL-56912-32' of git://github.com/marinaglancy/mood…
Browse files Browse the repository at this point in the history
…le into MOODLE_32_STABLE
  • Loading branch information
danpoltawski committed Dec 19, 2016
2 parents 4942dfc + f7b3774 commit 1a1eef4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions mod/feedback/item/feedback_item_class.php
Expand Up @@ -181,6 +181,7 @@ public function get_display_name_postfix($item) {
* If it is important which mode the form is in, use $form->get_mode()
*
* Each item type must add a single form element with the name $item->typ.'_'.$item->id
* This element must always be present in form data even if nothing is selected (i.e. use advcheckbox and not checkbox).
* To add an element use either:
* $form->add_form_element() - adds a single element to the form
* $form->add_form_group_element() - adds a group element to the form
Expand Down
5 changes: 5 additions & 0 deletions mod/feedback/item/multichoice/lib.php
Expand Up @@ -350,11 +350,16 @@ public function complete_form_element($item, $form) {
}
} else {
// Radio.
if (!array_key_exists(0, $options)) {
// Always add '0' as hidden element, otherwise form submit data may not have this element.
$objs[] = ['hidden', $inputname.'[0]'];
}
foreach ($options as $idx => $label) {
$objs[] = ['radio', $inputname.'[0]', '', $label, $idx];
}
$element = $form->add_form_group_element($item, 'group_'.$inputname, $name, $objs, $separator, $class);
$form->set_element_default($inputname.'[0]', $tmpvalue);
$form->set_element_type($inputname.'[0]', PARAM_INT);
}
}

Expand Down
5 changes: 5 additions & 0 deletions mod/feedback/item/multichoicerated/lib.php
Expand Up @@ -305,12 +305,17 @@ public function complete_form_element($item, $form) {
['select', $inputname, $name, array('' => '') + $options, array('class' => $class)]);
} else {
$objs = array();
if (!array_key_exists(0, $options)) {
// Always add '0' as hidden element, otherwise form submit data may not have this element.
$objs[] = ['hidden', $inputname];
}
foreach ($options as $idx => $label) {
$objs[] = ['radio', $inputname, '', $label, $idx];
}
$separator = $info->horizontal ? ' ' : '<br>';
$class .= ' multichoicerated-' . ($info->horizontal ? 'horizontal' : 'vertical');
$el = $form->add_form_group_element($item, 'group_'.$inputname, $name, $objs, $separator, $class);
$form->set_element_type($inputname, PARAM_INT);

// Set previously input values.
$form->set_element_default($inputname, $form->get_item_value($item));
Expand Down

0 comments on commit 1a1eef4

Please sign in to comment.