diff --git a/components/number.inc b/components/number.inc index ca6f2bf..46af359 100644 --- a/components/number.inc +++ b/components/number.inc @@ -432,58 +432,60 @@ function _webform_analysis_number($component, $sids = array(), $single = FALSE) } // Build normal distribution table rows. - $count = array(); - $percent = array(); - $limit = array(); - $index = 0; - - $count[] = 0; - $limit[] = $average - ($stddev * 4); - foreach ($population as $value) { - while ($value >= $limit[$index]) { - $percent[] = number_format($count[$index] / $population_count * 100, 2, '.', ''); - $limit[] = $limit[$index] + $stddev; - $index += 1; - if ($limit[$index] == $average) { - $limit[$index] = $limit[$index] + $stddev; + if (!empty($stddev)) { + $count = array(); + $percent = array(); + $limit = array(); + $index = 0; + + $count[] = 0; + $limit[] = $average - ($stddev * 4); + foreach ($population as $value) { + while ($value >= $limit[$index]) { + $percent[] = number_format($count[$index] / $population_count * 100, 2, '.', ''); + $limit[] = $limit[$index] + $stddev; + $index += 1; + if ($limit[$index] == $average) { + $limit[$index] = $limit[$index] + $stddev; + } + $count[$index] = 0; } - $count[$index] = 0; + $count[$index] += 1; + } + $percent[] = number_format($count[$index] / $population_count * 100, 2, '.', ''); + + // Format normal distribution table output. + $stddev = _webform_number_format($component, $stddev); + $low = _webform_number_format($component, $population[0]); + $high = _webform_number_format($component, end($population)); + foreach($limit as $key => $value) { + $limit[$key] = _webform_number_format($component, $value); } - $count[$index] += 1; - } - $percent[] = number_format($count[$index] / $population_count * 100, 2, '.', ''); - - // Format normal distribution table output. - $stddev = _webform_number_format($component, $stddev); - $low = _webform_number_format($component, $population[0]); - $high = _webform_number_format($component, end($population)); - foreach($limit as $key => $value) { - $limit[$key] = _webform_number_format($component, $value); - } - // Column headings (override potential theme uppercase, e.g. Seven in D7). - $header = array( - t('Normal Distribution'), - array('data' => '-4' . $sigma, 'style' => 'text-transform: lowercase;',), - array('data' => '-3' . $sigma, 'style' => 'text-transform: lowercase;',), - array('data' => '-2' . $sigma, 'style' => 'text-transform: lowercase;',), - array('data' => '-1' . $sigma, 'style' => 'text-transform: lowercase;',), - array('data' => '+1' . $sigma, 'style' => 'text-transform: lowercase;',), - array('data' => '+2' . $sigma, 'style' => 'text-transform: lowercase;',), - array('data' => '+3' . $sigma, 'style' => 'text-transform: lowercase;',), - array('data' => '+4' . $sigma, 'style' => 'text-transform: lowercase;',), - ); - - // Insert row labels. - array_unshift($limit, t('Boundary')); - array_unshift($count, t('Count')); - array_unshift($percent, t('% of !description', array('!description' => $description))); - - $output = theme('table', array('header' => $header, 'rows' => array($limit, $count, $percent))); - - $rows[4] = array(t('Range'), t('!low to !high', array('!low' => $low, '!high' => $high))); - $rows[5] = array(t('Standard deviation (!sigma)', array('!sigma' => $sigma)), $stddev); - $rows[6] = array(array('data' => $output, 'colspan' => 2)); + // Column headings (override potential theme uppercase, e.g. Seven in D7). + $header = array( + t('Normal Distribution'), + array('data' => '-4' . $sigma, 'style' => 'text-transform: lowercase;',), + array('data' => '-3' . $sigma, 'style' => 'text-transform: lowercase;',), + array('data' => '-2' . $sigma, 'style' => 'text-transform: lowercase;',), + array('data' => '-1' . $sigma, 'style' => 'text-transform: lowercase;',), + array('data' => '+1' . $sigma, 'style' => 'text-transform: lowercase;',), + array('data' => '+2' . $sigma, 'style' => 'text-transform: lowercase;',), + array('data' => '+3' . $sigma, 'style' => 'text-transform: lowercase;',), + array('data' => '+4' . $sigma, 'style' => 'text-transform: lowercase;',), + ); + + // Insert row labels. + array_unshift($limit, t('Boundary')); + array_unshift($count, t('Count')); + array_unshift($percent, t('% of !description', array('!description' => $description))); + + $output = theme('table', array('header' => $header, 'rows' => array($limit, $count, $percent))); + + $rows[4] = array(t('Range'), t('!low to !high', array('!low' => $low, '!high' => $high))); + $rows[5] = array(t('Standard deviation (!sigma)', array('!sigma' => $sigma)), $stddev); + $rows[6] = array(array('data' => $output, 'colspan' => 2)); + } } return $rows;