Skip to content

Commit

Permalink
Fixed issue #6346: Statistic page filter not remembering statistics l…
Browse files Browse the repository at this point in the history
…anguage
  • Loading branch information
c-schmitz committed Jul 20, 2012
1 parent 5ef6d12 commit 73545ac
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 27 deletions.
41 changes: 21 additions & 20 deletions application/controllers/admin/statistics.php
Expand Up @@ -209,7 +209,7 @@ public function run($surveyid, $subaction = null)
*/

//store all the data in $rows
$rows = Questions::getQuestionList($surveyid, $language);
$rows = Questions::model()->getQuestionList($surveyid, $language);

//SORT IN NATURAL ORDER!
usort($rows, 'groupOrderThenQuestionOrder');
Expand Down Expand Up @@ -243,7 +243,7 @@ public function run($surveyid, $subaction = null)
$error.='<br />'.$clang->gT('You do not have the Freetype Library installed. Showing charts requires the Freetype library to function properly.');
$error.='<br />'.$clang->gT('visit http://us2.php.net/manual/en/ref.image.php for more information').'<br />';
}

if ($grapherror)
{
unset($_POST['usegraph']);
Expand Down Expand Up @@ -357,7 +357,7 @@ public function run($surveyid, $subaction = null)
{
case "K": // Multiple Numerical
//get answers
$result = Questions::getQuestionsForStatistics('title as code, question as answer', "parent_qid=$flt[0] AND language = '{$language}'", 'question_order');
$result = Questions::model()->getQuestionsForStatistics('title as code, question as answer', "parent_qid=$flt[0] AND language = '{$language}'", 'question_order');
$aData['result'][$key1]['key1'] = $result;
break;

Expand All @@ -366,7 +366,7 @@ public function run($surveyid, $subaction = null)
case "Q": // Multiple Short Text

//get subqestions
$result = Questions::getQuestionsForStatistics('title as code, question as answer', "parent_qid=$flt[0] AND language = '{$language}'", 'question_order');
$result = Questions::model()->getQuestionsForStatistics('title as code, question as answer', "parent_qid=$flt[0] AND language = '{$language}'", 'question_order');
$aData['result'][$key1] = $result;
break;

Expand All @@ -375,50 +375,50 @@ public function run($surveyid, $subaction = null)
case "A": // ARRAY OF 5 POINT CHOICE QUESTIONS

//get answers
$result = Questions::getQuestionsForStatistics('title, question', "parent_qid=$flt[0] AND language = '{$language}'", 'question_order');
$result = Questions::model()->getQuestionsForStatistics('title, question', "parent_qid=$flt[0] AND language = '{$language}'", 'question_order');
$aData['result'][$key1] = $result;
break;



//just like above only a different loop
case "B": // ARRAY OF 10 POINT CHOICE QUESTIONS
$result = Questions::getQuestionsForStatistics('title, question', "parent_qid=$flt[0] AND language = '{$language}'", 'question_order');
$result = Questions::model()->getQuestionsForStatistics('title, question', "parent_qid=$flt[0] AND language = '{$language}'", 'question_order');
$aData['result'][$key1] = $result;
break;



case "C": // ARRAY OF YES\No\$clang->gT("Uncertain") QUESTIONS
//get answers
$result = Questions::getQuestionsForStatistics('title, question', "parent_qid=$flt[0] AND language = '{$language}'", 'question_order');
$result = Questions::model()->getQuestionsForStatistics('title, question', "parent_qid=$flt[0] AND language = '{$language}'", 'question_order');
$aData['result'][$key1] = $result;
break;



//similiar to the above one
case "E": // ARRAY OF Increase/Same/Decrease QUESTIONS
$result = Questions::getQuestionsForStatistics('title, question', "parent_qid=$flt[0] AND language = '{$language}'", 'question_order');
$result = Questions::model()->getQuestionsForStatistics('title, question', "parent_qid=$flt[0] AND language = '{$language}'", 'question_order');
$aData['result'][$key1] = $result;
break;

case ";": //ARRAY (Multi Flex) (Text)
$result = Questions::getQuestionsForStatistics('title, question', "parent_qid=$flt[0] AND language = '{$language}' AND scale_id = 0", 'question_order');
$result = Questions::model()->getQuestionsForStatistics('title, question', "parent_qid=$flt[0] AND language = '{$language}' AND scale_id = 0", 'question_order');
$aData['result'][$key1] = $result;
foreach($result as $key => $row)
{
$fresult = Questions::getQuestionsForStatistics('title, question', "parent_qid=$flt[0] AND language = '{$language}' AND scale_id = 1", 'question_order');
$fresult = Questions::model()->getQuestionsForStatistics('title, question', "parent_qid=$flt[0] AND language = '{$language}' AND scale_id = 1", 'question_order');
$aData['fresults'][$key1][$key] = $fresult;
}
break;

case ":": //ARRAY (Multi Flex) (Numbers)
$result = Questions::getQuestionsForStatistics('title, question', "parent_qid=$flt[0] AND language = '{$language}' AND scale_id = 0", 'question_order');
$result = Questions::model()->getQuestionsForStatistics('title, question', "parent_qid=$flt[0] AND language = '{$language}' AND scale_id = 0", 'question_order');
$aData['result'][$key1] = $result;
foreach($result as $row)
{
$fresult = Questions::getQuestionsForStatistics('*', "parent_qid=$flt[0] AND language = '{$language}' AND scale_id = 1", 'question_order, title');
$fresult = Questions::model()->getQuestionsForStatistics('*', "parent_qid=$flt[0] AND language = '{$language}' AND scale_id = 1", 'question_order, title');
$aData['fresults'][$key1] = $fresult;
}
break;
Expand All @@ -430,13 +430,13 @@ public function run($surveyid, $subaction = null)
case "F": // FlEXIBLE ARRAY
case "H": // ARRAY (By Column)
//Get answers. We always use the answer code because the label might be too long elsewise
$result = Questions::getQuestionsForStatistics('title, question', "parent_qid=$flt[0] AND language = '{$language}'", 'question_order');
$result = Questions::model()->getQuestionsForStatistics('title, question', "parent_qid=$flt[0] AND language = '{$language}'", 'question_order');
$aData['result'][$key1] = $result;

//check all the answers
foreach($result as $row)
{
$fresult = Answers::getQuestionsForStatistics('*', "qid=$flt[0] AND language = '{$language}'", 'sortorder, code');
$fresult = Answers::model()->getQuestionsForStatistics('*', "qid=$flt[0] AND language = '{$language}'", 'sortorder, code');
$aData['fresults'][$key1] = $fresult;
}

Expand All @@ -448,14 +448,14 @@ public function run($surveyid, $subaction = null)

case "R": //RANKING
//get some answers
$result = Answers::getQuestionsForStatistics('code, answer', "qid=$flt[0] AND language = '{$language}'", 'sortorder, answer');
$result = Answers::model()->getQuestionsForStatistics('code, answer', "qid=$flt[0] AND language = '{$language}'", 'sortorder, answer');
$aData['result'][$key1] = $result;
break;

case "1": // MULTI SCALE

//get answers
$result = Questions::getQuestionsForStatistics('title, question', "parent_qid=$flt[0] AND language = '{$language}'", 'question_order');
$result = Questions::model()->getQuestionsForStatistics('title, question', "parent_qid=$flt[0] AND language = '{$language}'", 'question_order');
$aData['result'][$key1] = $result;
//loop through answers
foreach($result as $key => $row)
Expand All @@ -466,7 +466,7 @@ public function run($surveyid, $subaction = null)
$aData['dshresults'][$key1][$key] = $dshresult;


$fresult = Answers::getQuestionsForStatistics('*', "qid=$flt[0] AND language = '{$language}' AND scale_id = 0", 'sortorder, code');
$fresult = Answers::model()->getQuestionsForStatistics('*', "qid=$flt[0] AND language = '{$language}' AND scale_id = 0", 'sortorder, code');

$aData['fresults'][$key1][$key] = $fresult;

Expand All @@ -480,7 +480,7 @@ public function run($surveyid, $subaction = null)
case "M": //M - Multiple choice

//get answers
$result = Questions::getQuestionsForStatistics('title, question', "parent_qid = $flt[0] AND language = '$language'", 'question_order');
$result = Questions::model()->getQuestionsForStatistics('title, question', "parent_qid = $flt[0] AND language = '$language'", 'question_order');
$aData['result'][$key1] = $result;
break;

Expand All @@ -495,7 +495,7 @@ public function run($surveyid, $subaction = null)
default:

//get answers
$result = Answers::getQuestionsForStatistics('code, answer', "qid=$flt[0] AND language = '$language'", 'sortorder, answer');
$result = Answers::model()->getQuestionsForStatistics('code, answer', "qid=$flt[0] AND language = '$language'", 'sortorder, answer');
$aData['result'][$key1] = $result;
break;

Expand Down Expand Up @@ -549,7 +549,8 @@ public function run($surveyid, $subaction = null)
}

} //end if -> show summary results


$aData['sStatisticsLanguage']=$statlang;
$aData['output'] = $statisticsoutput;

$this->_renderWrappedTemplate('export', 'statistics_view', $aData);
Expand Down
16 changes: 9 additions & 7 deletions application/views/admin/export/statistics_view.php
Expand Up @@ -46,7 +46,7 @@
foreach ($survlangs as $survlang)
{
$language_options .= "\t<option value=\"{$survlang}\"";
if (Yii::app()->session['adminlang'] == $survlang)
if ($sStatisticsLanguage == $survlang)
{
$language_options .= " selected=\"selected\" " ;
}
Expand Down Expand Up @@ -181,7 +181,7 @@
<?php $myfield = "{$surveyid}X{$flt[1]}X{$flt[0]}"; $niceqtext=flattenText($flt[5]); ?>
<?php
if ($flt[2]=='M' || $flt[2]=='P' || $flt[2]=='N' || $flt[2]=='L' || $flt[2]=='5'
|| $flt[2]=='G' || $flt[2]=='I' || $flt[2]=='O' || $flt[2]=='Y' || $flt[2]=='!'): ?>
|| $flt[2]=='G' || $flt[2]=='I' || $flt[2]=='O' || $flt[2]=='Y' || $flt[2]=='!'){ ?>
<td>
<?php
//Multiple choice:
Expand All @@ -199,9 +199,11 @@
|| array_search("P{$surveyid}X{$flt[1]}X{$flt[0]}", $summary) !== FALSE
|| array_search("N{$surveyid}X{$flt[1]}X{$flt[0]}", $summary) !== FALSE)) { echo " checked='checked'"; } ?> />
<label for='filter<?php echo $myfield; ?>'><?php echo _showSpeaker(flattenText($flt[5],true)); ?></label><br />
<?php if ($flt[2] != "N" && $flt[2] != "|"): ?>
<select name='<?php endif; if ($flt[2] == "M" ) { echo "M";}; if ($flt[2] == "P" ) { echo "P";}; echo "{$surveyid}X{$flt[1]}X{$flt[0]}[]'";?> multiple='multiple'>
<?php endif; ?>
<?php
if ($flt[2] != "N" && $flt[2] != "|"): ?>
<select name='<?php if ($flt[2] == "M" ) { echo "M";}; if ($flt[2] == "P" ) { echo "P";}; echo "{$surveyid}X{$flt[1]}X{$flt[0]}[]'";?> multiple='multiple'>
<?php endif;
};?>
<!-- QUESTION TYPE = <?php echo $flt[2]; ?> -->
<?php

Expand Down Expand Up @@ -273,7 +275,7 @@
echo "\t</tr>\n\t<tr>\n";

//get subqestions
$result[$key1] = Questions::getQuestionsForStatistics('title as code, question as answer', "parent_qid='$flt[0]' AND language = '{$language}'", 'question_order');
$result[$key1] = Questions::model()->getQuestionsForStatistics('title as code, question as answer', "parent_qid='$flt[0]' AND language = '{$language}'", 'question_order');
$counter2=0;

//loop through all answers
Expand Down Expand Up @@ -858,7 +860,7 @@
$counter2=0;

//check all the answers
foreach($result[$key1] as $row)
foreach($result[$key1] as $key=>$row)
{
$row=array_values($row);
$myfield2 = $myfield . "$row[0]";
Expand Down

0 comments on commit 73545ac

Please sign in to comment.