You are here

function webform_results_analysis in Webform 6.2

Same name and namespace in other branches
  1. 5.2 webform_report.inc \webform_results_analysis()
  2. 6.3 includes/webform.report.inc \webform_results_analysis()
  3. 7.4 includes/webform.report.inc \webform_results_analysis()
  4. 7.3 includes/webform.report.inc \webform_results_analysis()

Provides a simple analysis of all submissions to a webform.

1 string reference to 'webform_results_analysis'
webform_menu in ./webform.module
Implementation of hook_menu().

File

./webform_report.inc, line 464
This file includes helper functions for creating reports for webform.module

Code

function webform_results_analysis($node, $sids = array()) {
  $rows = array();
  $question_number = 0;
  $headers = array(
    t('Q'),
    array(
      'data' => t('responses'),
      'colspan' => '10',
    ),
  );
  webform_load_components();

  // Load all component types.
  foreach ($node->webform['components'] as $component) {

    // Do component specific call.
    $analysis_function = '_webform_analysis_rows_' . $component['type'];
    if (function_exists($analysis_function)) {
      $question_number++;
      $crows = $analysis_function($component, $sids);
      if (is_array($crows)) {
        $row[0] = array(
          'data' => '<strong>' . $question_number . '</strong>',
          'rowspan' => count($crows) + 1,
          'valign' => 'top',
        );
        $row[1] = array(
          'data' => '<strong>' . $component['name'] . '</strong>',
          'colspan' => '10',
        );
        $rows = array_merge($rows, array_merge(array(
          $row,
        ), $crows));
      }
    }
  }
  if (count($rows) == 0) {
    $rows[] = array(
      array(
        'data' => t('There are no submissions for this form. <a href="!url">View this form</a>.', array(
          '!url' => url('node/' . $node->nid),
        )),
        'colspan' => 20,
      ),
    );
  }
  return theme('table', $headers, $rows);
}