Skip to content

Commit

Permalink
Fixed issue #06615 - Browsing text answer results with the browse but…
Browse files Browse the repository at this point in the history
…ton does nothing. Fixed filtering for text browsing
  • Loading branch information
jcleeland committed Nov 17, 2012
1 parent 45bc1ca commit eb25bb2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 4 additions & 1 deletion application/controllers/admin/statistics.php
Expand Up @@ -495,7 +495,10 @@ public function run($surveyid = 0, $subaction = null)
function listcolumn($surveyid, $column, $sortby="", $sortmethod="", $sorttype="")
{
$search['condition']=$column." != ''";
//if($sql != "") {$search['condition'].= " AND ($sql)";}
//Look for any selects/filters set in the original statistics query, and apply them to the column listing
foreach(Yii::app()->session['statistics_selects_'.$surveyid] as $sql) {
$search['condition'] .= " AND $sql";
}
if($sorttype=='N') {$sortby = "($sortby * 1)";} //Converts text sorting into numerical sorting
if($sortby != "") $search['order']=$sortby.' '.$sortmethod;
$results=Survey_dynamic::model($surveyid)->findAll($search);
Expand Down
7 changes: 5 additions & 2 deletions application/helpers/admin/statistics_helper.php
Expand Up @@ -662,7 +662,7 @@ protected function buildOutputList($rt, $language, $surveyid, $outputType, $sql,
//more substrings
$count = substr($qqid, strlen($qqid)-1);

//get answers
//get answers / subquestion text
$nresult = Questions::model()->find(array('order'=>'question_order',
'condition'=>'language=:language AND parent_qid=:parent_qid AND title=:title',
'params'=>array(':language'=>$language, ':parent_qid'=>substr($qqid, 0, $iQuestionIDlength), ':title'=>$qaid)
Expand Down Expand Up @@ -1638,11 +1638,12 @@ protected function displayResults($outputs, $results, $rt, $outputType, $surveyi
{
// It is better for single choice question types to filter on the number of '-oth-' entries, than to
// just count the number of 'other' values - that way with failing Javascript the statistics don't get messed up
/* This query selects a count of responses where "other" has been selected */
$query = "SELECT count(*) FROM {{survey_$surveyid}} WHERE ".Yii::app()->db->quoteColumnName(substr($al[2],0,strlen($al[2])-5))."='-oth-'";
}
else
{
//get data
//get data - select a count of responses where no answer is provided
$query = "SELECT count(*) FROM {{survey_$surveyid}} WHERE ";
$query .= ($sDatabaseType == "mysql")? Yii::app()->db->quoteColumnName($al[2])." != ''" : "NOT (".Yii::app()->db->quoteColumnName($al[2])." LIKE '')";
}
Expand Down Expand Up @@ -3187,6 +3188,8 @@ public function generate_statistics($surveyid, $allfields, $q2show='all', $usegr
//are there any filters that have to be taken care of?
if (isset($selects) && $selects)
{
//Save the filters to session for use in browsing text & other features (statistics.php function listcolumn())
Yii::app()->session['statistics_selects_'.$surveyid] = $selects;
//filter incomplete answers?
if (incompleteAnsFilterState() == "complete" || incompleteAnsFilterState() == "incomplete") {$query .= " AND ";}

Expand Down

0 comments on commit eb25bb2

Please sign in to comment.