poll_view_results

function poll_view_results

poll_view_results($node, $view_mode, $block = FALSE)

Generates a graphical representation of the results of a poll.

File

modules/poll/poll.module, line 809
Enables your site to capture votes on different topics in the form of multiple choice questions.

Code

function poll_view_results($node, $view_mode, $block = FALSE) {
  // Make sure that choices are ordered by their weight.
  uasort($node->choice, 'drupal_sort_weight');

  // Count the votes and find the maximum.
  $total_votes = 0;
  $max_votes = 0;
  foreach ($node->choice as $choice) {
    if (isset($choice['chvotes'])) {
      $total_votes += $choice['chvotes'];
      $max_votes = max($max_votes, $choice['chvotes']);
    }
  }

  $poll_results = '';
  foreach ($node->choice as $i