function poll_get_results(&$results, $sort = true) { foreach ($this->options as $option) { $responses = get_records('block_poll_response', 'optionid', $option->id); $results[$option->optiontext] = !$responses ? '0' : count($responses); } if ($sort) { poll_sort_results($results); } }
public function poll_get_results(&$results, $sort = true) { global $DB; foreach ($this->options as $option) { $responses = $DB->get_records('block_poll_response', array('optionid' => $option->id)); $results[$option->optiontext] = !$responses ? '0' : count($responses); } if ($sort) { poll_sort_results($results); } }
return $arr; } $polls = get_records('block_poll', 'courseid', $COURSE->id); foreach ($polls as $poll) { $menu[$poll->id] = $poll->name; } print_simple_box_start(); echo get_string('editpollname', 'block_poll') . ': '; choose_from_menu($menu, 'pid', $pid, 'choose', 'show_poll_results(this.options[this.selectedIndex].value);'); print_simple_box_end(); if (($poll = get_record('block_poll', 'id', $pid)) && ($options = get_records('block_poll_option', 'pollid', $poll->id))) { foreach ($options as $option) { $option->responses = get_records('block_poll_response', 'optionid', $option->id); $option->responsecount = !$option->responses ? 0 : count($option->responses); } poll_sort_results($options, 'poll_custom_callback'); print_simple_box_start(); echo "<strong>{$poll->questiontext}</strong><ol>"; foreach ($options as $option) { echo "<li>{$option->optiontext} ({$option->responsecount})</li>"; } echo '</ol>'; print_simple_box_end(); if ($responses = get_records('block_poll_response', 'pollid', $poll->id, 'submitted ASC')) { $responsecount = count($responses); $optioncount = count($options); $table = new Object(); $table->head = array(' ', get_string('user'), get_string('date')); for ($i = 1; $i <= $optioncount; $i++) { $table->head[] = $i; }