Permalink
Browse files

Added likert matrix chart for site results

  • Loading branch information...
1 parent 0d12923 commit 251b6d6770236c2e3d00ff71ee7a066af6bdd11d Ollie Armstrong committed Feb 21, 2012
Showing with 35 additions and 1 deletion.
  1. +35 −1 pages/admin/surveys/result.total.script.site.php
@@ -73,6 +73,31 @@
$googleChartUrl .= '&chds=0,'.(++$maxValue); // Sets scaling to a little bit more than max value
$googleChartUrl .= '&chd=t:'.implode(',', $valueArray); // Chart data
?><img class="wpsqt-chart" 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 class="wpsqt-chart" 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>';
} ?>
@@ -87,12 +112,21 @@
$givenAnswers = $givenAnswers[$sectionKey]['answers'][$questonKey]['given'];
echo '<div class="wpsqt-question-response-you">You entered: ';
if (is_array($givenAnswers)) {
+ $i = 1;
foreach ($givenAnswers as $givenAnswer) {
foreach($_SESSION['wpsqt'][$_SESSION['wpsqt']['current_id']]['sections'][$sectionKey]['questions'] as $question) {
if ($question['id'] == $questonKey) {
- echo $question['answers'][$givenAnswer]['text'].' ';
+ if ($question['type'] == 'Likert Matrix') {
+ $givenAnswerDetails = explode("_", $givenAnswer);
+ echo '<em>'.$givenAnswerDetails[0].'</em>: '.$givenAnswerDetails[1];
+ } else {
+ echo $question['answers'][$givenAnswer]['text'];
+ }
+ if ($i < count($givenAnswers))
+ echo ', ';
}
}
+ $i++;
}
} else {
echo $givenAnswers;

0 comments on commit 251b6d6

Please sign in to comment.