You are here

function _webform_analysis_matrix in Webform Matrix Component 7

Same name and namespace in other branches
  1. 6 components/matrix.inc \_webform_analysis_matrix()
  2. 7.4 components/matrix.inc \_webform_analysis_matrix()
  3. 7.2 components/matrix.inc \_webform_analysis_matrix()
  4. 7.3 components/matrix.inc \_webform_analysis_matrix()

Implements _webform_analysis_component().

File

components/matrix.inc, line 607
Webform module matrix component.

Code

function _webform_analysis_matrix($component, $sids = array()) {
  $query = db_select('webform_submitted_data', 'wsd', array(
    'fetch' => PDO::FETCH_ASSOC,
  ))
    ->fields('wsd', array(
    'no',
    'data',
  ))
    ->condition('nid', $component['nid'])
    ->condition('cid', $component['cid'])
    ->orderBy('sid');
  if (count($sids)) {
    $query
      ->condition('sid', $sids, 'IN');
  }
  $result = $query
    ->execute();
  $matrixs = array();
  $submissions = 0;
  foreach ($result as $row) {
    $submissions++;
    if ($row['data']) {
      $matrixs[] = webform_matrix_array($row['data']);
    }
  }

  // Display stats.
  $nonblanks = count($matrixs);
  $rows[0] = array(
    t('Left Blank'),
    $submissions - $nonblanks,
  );
  $rows[1] = array(
    t('User entered value'),
    $nonblanks,
  );
  return $rows;
}