';
echo get_string('average', 'feedback').': '.$avg.'';
echo ' |
';
}
}
public function excelprint_item(&$worksheet, $row_offset,
$xls_formats, $item,
$groupid, $courseid = false) {
$analysed_item = $this->get_analysed($item, $groupid, $courseid);
$data = $analysed_item[2];
//write the item
$worksheet->write_string($row_offset, 0, $item->label, $xls_formats->head2);
$worksheet->write_string($row_offset, 1, $analysed_item[1], $xls_formats->head2);
if (is_array($data)) {
$avg = 0.0;
$sizeofdata = count($data);
for ($i = 0; $i < $sizeofdata; $i++) {
$analysed_data = $data[$i];
$worksheet->write_string($row_offset,
$i + 2,
trim($analysed_data->answertext).' ('.$analysed_data->value.')',
$xls_formats->value_bold);
$worksheet->write_number($row_offset + 1,
$i + 2,
$analysed_data->answercount,
$xls_formats->default);
$avg += $analysed_data->avg;
}
//mittelwert anzeigen
$worksheet->write_string($row_offset,
count($data) + 2,
get_string('average', 'feedback'),
$xls_formats->value_bold);
$worksheet->write_number($row_offset + 1,
count($data) + 2,
$avg,
$xls_formats->value_bold);
}
$row_offset +=2;
return $row_offset;
}
/**
* Options for the multichoice element
* @param stdClass $item
* @return array
*/
protected function get_options($item) {
$info = $this->get_info($item);
$lines = explode(FEEDBACK_MULTICHOICERATED_LINE_SEP, $info->presentation);
$options = array();
foreach ($lines as $idx => $line) {
list($weight, $optiontext) = explode(FEEDBACK_MULTICHOICERATED_VALUE_SEP, $line);
$a = new stdclass();
$a->weight = $weight;
$a->name = format_text($optiontext, FORMAT_HTML, array('noclean' => true, 'para' => false));
$options[$idx + 1] = get_string('multichoiceoption', 'feedback', $a);
}
if ($info->subtype === 'r' && !$this->hidenoselect($item)) {
$options = array(0 => get_string('not_selected', 'feedback')) + $options;
}
return $options;
}
/**
* Adds an input element to the complete form
*
* @param stdClass $item
* @param mod_feedback_complete_form $form
*/
public function complete_form_element($item, $form) {
$info = $this->get_info($item);
$name = $this->get_display_name($item);
$class = 'multichoicerated-' . $info->subtype;
$inputname = $item->typ . '_' . $item->id;
$options = $this->get_options($item);
if ($info->subtype === 'd' || $form->is_frozen()) {
$el = $form->add_form_element($item,
['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];
}
// Span to hold the element id. The id is used for drag and drop reordering.
$objs[] = ['static', '', '', html_writer::span('', '', ['id' => 'feedback_item_' . $item->id])];
$separator = $info->horizontal ? ' ' : '