Skip to content

Commit

Permalink
Add likert matrix total results view for admin panel
Browse files Browse the repository at this point in the history
  • Loading branch information
Ollie Armstrong committed Feb 21, 2012
1 parent fea2789 commit 0d12923
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion pages/admin/surveys/result.total.script.php
Expand Up @@ -72,8 +72,33 @@
$googleChartUrl .= '&chds=0,'.(++$maxValue); // Sets scaling to a little bit more than max value
$googleChartUrl .= '&chd=t:'.implode(',', $valueArray); // Chart data
?><img src="<?php echo $googleChartUrl; ?>" alt="<?php echo $question['name']; ?>" /><?php
} else if ($question['type'] == "Likert Matrix") {
foreach($question['answers'] as $optionkey => $matrixOption) {
$googleChartUrl = 'http://chart.apis.google.com/chart?&cht=bvs';
$valueArray = array();
$nameArray = array();
$maxValue = 0;
$numAnswers = count($question['answers']);

foreach ($matrixOption as $key => $answer) {
$nameArray[] = $key;
$valueArray[] = $answer['count'];
// Gets the maximum value
if ($answer['count'] > $maxValue)
$maxValue = $answer['count'];
}

$googleChartUrl .= '&chs=350x250';
$googleChartUrl .= '&chxt=x&chxl=0:|'.implode('|', $nameArray); // Sets labelling to x-axis only
$googleChartUrl .= '&chm=N,000000,0,,10|N,000000,1,,10|N,000000,2,,10'; // Adds the count above bars
$googleChartUrl .= '&chds=0,'.(++$maxValue); // Sets scaling to a little bit more than max value
$googleChartUrl .= '&chd=t:'.implode(',', $valueArray); // Chart data

echo '<h4>'.$optionkey.'</h4>';
?><img src="<?php echo $googleChartUrl; ?>" alt="<?php echo $question['name']; ?>" /><?php
}
} else {
echo 'Something went really wrong, please report this bug to the forum. Here\'s a var dump which might make you feel better.<pre>'; var_dump($question); echo '</pre>';
echo 'Something went really wrong, please report this bug to the GitHub Issues page. Here\'s a var dump which might make you feel better.<pre>'; var_dump($question); echo '</pre>';
} ?>

<?php }
Expand Down

0 comments on commit 0d12923

Please sign in to comment.