\n";
// populate table row/columns
$colcount = count($loadedq['questions'][$_REQUEST['xtab']]['options']) + 1; // count the total number of cols -1 so we can use this in a colspan attribute for header rows
if ($loadedq['questions'][$thisqid]['type'] == "smallbox" || $loadedq['questions'][$thisqid]['type'] == "bigbox") { // an open text question
if (strlen($_REQUEST['xtab'])>0) {
foreach((array)$loadedq['questions'][$_REQUEST['xtab']]['options'] as $xto) {
$xto2 = idWord($xto);
$table .= "Comments ({$xto}): | ".($stats[$xto2][$thisqid])." |
";
}
} else { // no cross tabs, so just show comments in total col
$table .= "Comments: | ".($stats[Total][$thisqid])." |
";
}
$base = count($data2) - $blanks[$thisqid];
} else {
foreach((array)$loadedq['questions'][$thisqid]['options'] as $qo) {
if (eregi("other_specify:",$qo)) { // this row is 'other specify', so show the values entered
$qo_id = idWord($qo);
//$othervalues = "".@implode(", ",$othervals[$thisqid][$qo_id])."";
$othervalues = "Responses include: ".substr(@implode(", ",$othervals[$thisqid]),0,255)."";
} else {
$othervalues = null;
}
$table .= "{$qo}{$othervalues} | ";
if (count($loadedq['questions'][$thisqid]['scale'])>0) { // this is a grid, so split out options as subrows
$table .= " |
\n"; // end the option row and blank out the rest of the row
foreach((array)$loadedq['questions'][$thisqid]['scale'] as $scpt) {
$table .= " {$scpt} | ";
$ido = idWord($qo);
$ids = idWord($scpt);
if ($calcPercentageOnAll == "TRUE") { // use the total number of submitted responses, including blanks
$percent = ($stats[Total][$thisqid][$ido][$ids]>0) ? round($stats[Total][$thisqid][$ido][$ids]/count($data2)*100) . "%": null;
} else { // calc percentages on the number of non-blank responses to this question
$percent = ($stats[Total][$thisqid][$ido][$ids]>0) ? round($stats[Total][$thisqid][$ido][$ids]/(count($data2)-$blanks[$thisqid])*100) . "%": null;
}
$table .= "";
if ($_REQUEST['show'] == "count" || $_REQUEST['show'] == "both" ) { $table .= $stats[Total][$thisqid][$ido][$ids]; }
if ($_REQUEST['show'] == "percentage" || $_REQUEST['show'] == "both" ) { $table .= "" . $percent . ""; }
$table .= " | ";
foreach((array)$loadedq['questions'][$_REQUEST['xtab']]['options'] as $xto) {
$xto = idWord($xto);
$xtopercent = ($stats[$xto][$thisqid][$ido][$ids]>0) ? round($stats[$xto][$thisqid][$ido][$ids]/$respcount[$xto]*100) . "%" : null;
$table .= "";
if ($_REQUEST['show'] == "count" || $_REQUEST['show'] == "both" ) { $table .= $stats[$xto][$thisqid][$ido][$ids]; }
if ($_REQUEST['show'] == "percentage" || $_REQUEST['show'] == "both" ) { $table .= "". $xtopercent . ""; }
$table .= " | ";
}
$table .= "
\n";
}
} else { // just a one-dimensional questions
$ido = idWord($qo);
if ($calcPercentageOnAll == "TRUE") { // use the total number of submitted responses, including blanks
$percent = ($stats[Total][$thisqid][$ido]>0) ? round($stats[Total][$thisqid][$ido]/count($data2)*100) . "%" : null;
} else { // calc percentages on the number of non-blank responses to this question
$percent = ($stats[Total][$thisqid][$ido]>0) ? round($stats[Total][$thisqid][$ido]/(count($data2)-$blanks[$thisqid])*100) . "%" : null;
}
$table .= "";
if ($_REQUEST['show'] == "count" || $_REQUEST['show'] == "both" ) { $table .= $stats[Total][$thisqid][$ido]; }
if ($_REQUEST['show'] == "percentage" || $_REQUEST['show'] == "both" ) { $table .= "" . $percent . ""; }
$table .= " | ";
foreach((array)$loadedq['questions'][$_REQUEST['xtab']]['options'] as $xto) {
$xto = idWord($xto);
$xtopercent = ($stats[$xto][$thisqid][$ido]) ? round($stats[$xto][$thisqid][$ido]/$respcount[$xto]*100)."%" : null;
$table .= "";
if ($_REQUEST['show'] == "count" || $_REQUEST['show'] == "both" ) { $table .= $stats[$xto][$thisqid][$ido]; }
if ($_REQUEST['show'] == "percentage" || $_REQUEST['show'] == "both" ) { $table .= "" . $xtopercent . ""; }
$table .= " | ";
}
$table .= "\n";
}
}
}
$base = count($data2) - $blanks[$thisqid];
$table .= "