Skip to content

Commit

Permalink
Fixed issue #4294: Bug in using multiple statictics filters when more…
Browse files Browse the repository at this point in the history
… than one type=M/P question used as filters

Fixed issue: You can't filter a certain question in statistics unless it is marked to be displayed

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey@9249 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
c-schmitz committed Oct 15, 2010
1 parent 599cd7b commit 26c21d7
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 36 deletions.
11 changes: 6 additions & 5 deletions admin/statistics.php
Expand Up @@ -460,10 +460,8 @@
Y - Yes/No
! - List (Dropdown) )
*/
if ($flt[2] != "A" && $flt[2] != "B" && $flt[2] != "C" && $flt[2] != "E" &&
$flt[2] != "F" && $flt[2] != "H" && $flt[2] != "T" && $flt[2] != "U" &&
$flt[2] != "S" && $flt[2] != "D" && $flt[2] != "R" && $flt[2] != "Q" && $flt[2] != "1" &&
$flt[2] != "X" && $flt[2] != "K" && $flt[2] != ":" && $flt[2] != ";") //Have to make an exception for these types!
if ($flt[2]=='M' || $flt[2]=='P' || $flt[2]=='N' || $flt[2]=='L'
|| $flt[2]=='G' || $flt[2]=='I' || $flt[2]=='O' || $flt[2]=='Y' || $flt[2]=='!') //Have to make an exception for these types!
{

$statisticsoutput .= "\t\t\t\t<td align='center'>";
Expand All @@ -487,7 +485,10 @@
*
* Auto-check the question types mentioned above
*/
if (isset($summary) && (array_search("{$surveyid}X{$flt[1]}X{$flt[0]}", $summary) !== FALSE || array_search("M{$surveyid}X{$flt[1]}X{$flt[0]}", $summary) !== FALSE || array_search("N{$surveyid}X{$flt[1]}X{$flt[0]}", $summary) !== FALSE))
if (isset($summary) && (array_search("{$surveyid}X{$flt[1]}X{$flt[0]}", $summary) !== FALSE
|| array_search("M{$surveyid}X{$flt[1]}X{$flt[0]}", $summary) !== FALSE
|| array_search("P{$surveyid}X{$flt[1]}X{$flt[0]}", $summary) !== FALSE
|| array_search("N{$surveyid}X{$flt[1]}X{$flt[0]}", $summary) !== FALSE))
{$statisticsoutput .= " checked='checked'";}

//show speaker symbol which contains full question text
Expand Down
58 changes: 27 additions & 31 deletions admin/statistics_function.php
Expand Up @@ -59,37 +59,29 @@
//don't call this script directly!
if (isset($_REQUEST['homedir'])) {die('You cannot start this script directly');}

//some includes, the progressbar is used to show a progressbar while generating the graphs
//if($casEnabled)
//{
// include_once("login_check_cas.php");
//}
//else
//{

//}

//require_once('classes/core/class.progressbar.php');




// // LimeSurvey translation Object
// require_once($rootdir.'/classes/core/language.php');
// $clang = new limesurvey_lang($defaultlang);




//generate_statistics('999','all',0,'pdf','F');

/**
* Generates statistics
*
* @param int $surveyid The survey id
* @param mixed $allfields
* @param mixed $q2show
* @param mixed $usegraph
* @param string $outputType Optional - Can be xls, html or pdf - Defaults to pdf
* @param string $pdfOutput Sets the target for the PDF output: DD=File download , F=Save file to local disk
* @param string $statlangcode Lamguage for statistics
* @param mixed $browse Show browse buttons
* @return buffer
*/
function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, $outputType='pdf', $pdfOutput='DD',$statlangcode=null, $browse = true)
{
//$allfields ="";
global $connect, $dbprefix, $clang,
$rooturl, $rootdir, $homedir, $homeurl, $tempdir, $tempurl, $scriptname,
$chartfontfile, $chartfontsize, $admintheme, $pdfdefaultfont, $pdffontsize;

$fieldmap=createFieldMap($surveyid, "full");

if (is_null($statlangcode))
{
$statlang=$clang;
Expand Down Expand Up @@ -286,6 +278,13 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0,
// creates array of post variable names
for (reset($_POST); $key=key($_POST); next($_POST)) { $postvars[]=$key;}

$aQuestionMap=array();
foreach ($fieldmap as $field)
{
if(isset($field['qid']) && $field['qid']!='')
$aQuestionMap[]=$field['sid'].'X'.$field['gid'].'X'.$field['qid'];
}

/*
* Iterate through postvars to create "nice" data for SQL later.
*
Expand All @@ -296,7 +295,7 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0,
foreach ($postvars as $pv)
{
//Only do this if there is actually a value for the $pv
if (in_array($pv, $allfields) || in_array(substr($pv,0,-1), $allfields))
if (in_array($pv, $allfields) || in_array(substr($pv,1),$aQuestionMap) || in_array($pv,$aQuestionMap))
{
$firstletter=substr($pv,0,1);
/*
Expand Down Expand Up @@ -331,10 +330,11 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0,
//P - Multiple Options with comments
elseif ($firstletter == "M" || $firstletter == "P")
{
$mselects=array();
//create a list out of the $pv array
list($lsid, $lgid, $lqid) = explode("X", $pv);

$aquery="SELECT question FROM ".db_table_name("questions")." WHERE parent_qid=$lqid AND language='{$language}' ORDER BY question_order";
$aquery="SELECT title FROM ".db_table_name("questions")." WHERE parent_qid=$lqid AND language='{$language}' and scale_id=0 ORDER BY question_order";
$aresult=db_execute_num($aquery) or safe_die ("Couldn't get subquestions<br />$aquery<br />".$connect->ErrorMsg());

// go through every possible answer
Expand Down Expand Up @@ -647,7 +647,7 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0,
}

//1. Get list of answers
$query="SELECT title, question FROM ".db_table_name("questions")." WHERE parent_qid='$qqid' AND language='{$language}' ORDER BY question_order";
$query="SELECT title, question FROM ".db_table_name("questions")." WHERE parent_qid='$qqid' AND language='{$language}' and scale_id=0 ORDER BY question_order";
$result=db_execute_num($query) or safe_die("Couldn't get list of subquestions for multitype<br />$query<br />".$connect->ErrorMsg());

//loop through multiple answers
Expand All @@ -674,8 +674,7 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0,
//T - Long Free Text
elseif ($firstletter == "T" || $firstletter == "S") //Short and long text
{
$fieldmap=createFieldMap($surveyid, "full");


//search for key
$fld = substr($rt, 1, strlen($rt));
$fielddata=$fieldmap[$fld];
Expand Down Expand Up @@ -1327,9 +1326,6 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0,
// NICE SIMPLE SINGLE OPTION ANSWERS
else
{
//get database fields for this survey
$fieldmap=createFieldMap($surveyid, "full");
//print_r($fieldmap);
//search for key
$fld =
$fielddata=$fieldmap[$rt];
Expand Down

0 comments on commit 26c21d7

Please sign in to comment.