View Issue Details

IDProjectCategoryView StatusLast Update
06406User patchesStatisticspublic2013-03-05 13:53
ReporterDWS 
Assigned To 
PrioritynormalSeverityminor 
Status confirmedResolutionopen 
Product Version1.92RC2 
Target VersionFixed in Version 
Summary06406: Assign tokens to a user and filter stats
DescriptionEnable a user with access to the results of a survey, but only to the responses of a particular group of tokens, not all the answers. The tokens need to be grouped and identified in order to assign this id to the user. Then, filter the sql sentences to this filter.
Steps To ReproduceAdd field to users table, related to filter option.
Add the filter on any sql sentence of browse and/or statistics.
Additionally, I delete the prev-next button on single view.
Additional Informationhttp://www.limesurvey.org/es/forum/can-i-do-this-with-limesurvey/83588-assign-tokens-to-a-user
TagsNo tags attached.
Complete LimeSurvey version number (& build)120704

Relationships

Activities

DWS

2012-07-30 14:37

reporter  

statistics_function.php (172,280 bytes)

DWS

2012-07-30 14:38

reporter  

browse.php (55,857 bytes)

DWS

2012-07-30 14:39

reporter   ~20072

As you see, it's done on dirty and raw way, but it works. Will be pretty add this possibility to new versions.

DWS

2012-07-30 14:40

reporter   ~20074

Unfortunately, the survey contents privacy data and can't give you a user to test it.

DenisChenu

2012-07-30 17:47

developer   ~20076

Hello,

Thnak's a lot, it can be great if you can put a diff file.

You can use diffutils or winmerge to do the diff files.
http://gnuwin32.sourceforge.net/packages/diffutils.htm
http://sourceforge.net/projects/winmerge/

Denis

DWS

2012-07-31 16:15

reporter  

comp_browse (13,157 bytes)
--- /var/www/shop/ls/admin/browse.php
+++ /var/www/browse.php
@@ -12,11 +12,6 @@
  *
 */
 
-$sql0 = mysql_query("SELECT * FROM `lime_users` WHERE `users_name` ='$_SESSION[user]'");
-while ($mostrar = mysql_fetch_array($sql0)){ $centro=$mostrar['centro']; $idadmin=$mostrar['uid']; } mysql_free_result($sql0); 
-
-if($idadmin == 2) {$busqueda="29138X16X270 >= 0";} else {$busqueda="29138X16X270='$centro'";}
-
 include_once("login_check.php");  //Login Check dies also if the script is started directly
 
 if (!isset($limit)) {$limit=(int)returnglobal('limit');}
@@ -196,11 +191,11 @@
     if ($surveyinfo['anonymized'] == "N" && db_tables_exist($tokentable))
         $idquery .= " LEFT JOIN {$tokentable} t ON s.token = t.token ";
     if (incompleteAnsFilterstate() == "inc")
-        $idquery .= " WHERE (submitdate = ".$connect->DBDate('1980-01-01'). " OR submitdate IS NULL) AND $busqueda AND ";
+        $idquery .= " WHERE (submitdate = ".$connect->DBDate('1980-01-01'). " OR submitdate IS NULL) AND ";
     elseif (incompleteAnsFilterstate() == "filter")
-        $idquery .= " WHERE submitdate >= ".$connect->DBDate('1980-01-01'). " AND $busqueda AND ";
+        $idquery .= " WHERE submitdate >= ".$connect->DBDate('1980-01-01'). " AND ";
     else
-        $idquery .= " WHERE $busqueda AND";
+        $idquery .= " WHERE ";
     if ($id < 1) { $id = 1; }
     $idquery .= " s.id = $id";
     $idresult = db_execute_assoc($idquery) or safe_die ("Couldn't get entry<br />\n$idquery<br />\n".$connect->ErrorMsg());
@@ -245,7 +240,12 @@
             "<img name='ExportAnswer' src='$imageurl/export.png' alt='". $clang->gT("Export this Response")."' align='left' /></a>\n"
             ."<img src='$imageurl/seperator.gif' border='0' hspace='0' align='left' alt='' />\n"
             ."<img src='$imageurl/blank.gif' width='20' height='20' border='0' hspace='0' align='left' alt='' />\n"
-            
+            ."<a href='$scriptname?action=browse&amp;subaction=id&amp;id=$last&amp;sid=$surveyid' "
+            ."title='".$clang->gTview("Show previous...")."' >"
+            ."<img name='DataBack' align='left' src='$imageurl/databack.png' alt='".$clang->gT("Show previous...")."' /></a>\n"
+            ."<img src='$imageurl/blank.gif' width='13' height='20' border='0' hspace='0' align='left' alt='' />\n"
+            ."<a href='$scriptname?action=browse&amp;subaction=id&amp;id=$next&amp;sid=$surveyid' title='".$clang->gTview("Show next...")."'>"
+            ."<img name='DataForward' align='left' src='$imageurl/dataforward.png' alt='".$clang->gT("Show next...")."' /></a>\n"
             ."</div>\n"
             ."\t</div>\n";
 
@@ -351,7 +351,7 @@
         if (!empty($fuqtquestions))
         {
             // find all responses (filenames) to the fuqt questions
-            $query="SELECT " . implode(", ", $fuqtquestions) . " FROM $surveytable where id={$_POST['deleteanswer']} AND $busqueda";
+            $query="SELECT " . implode(", ", $fuqtquestions) . " FROM $surveytable where id={$_POST['deleteanswer']}";
             $responses = db_execute_assoc($query) or safe_die("Could not fetch responses<br />$query<br />".$connect->ErrorMsg());
 
             while($json = $responses->FetchRow())
@@ -394,7 +394,7 @@
                 if (!empty($fuqtquestions))
                 {
                     // find all responses (filenames) to the fuqt questions
-                    $query="SELECT " . implode(", ", $fuqtquestions) . " FROM $surveytable where id={$iResponseID} AND $busqueda";
+                    $query="SELECT " . implode(", ", $fuqtquestions) . " FROM $surveytable where id={$iResponseID}";
                     $responses = db_execute_assoc($query) or safe_die("Could not fetch responses<br />$query<br />".$connect->ErrorMsg());
 
                     while($json = $responses->FetchRow())
@@ -436,7 +436,7 @@
         $downloadindividualfile = $_POST['downloadindividualfile'];
         $fieldname = $_POST['fieldname'];
 
-        $query = "SELECT ".db_quote_id($fieldname)." FROM {$surveytable} WHERE id={$id} AND $busqueda";
+        $query = "SELECT ".db_quote_id($fieldname)." FROM {$surveytable} WHERE id={$id}";
         $result=db_execute_num($query);
         $row=$result->FetchRow();
         $phparray = json_decode($row[0]);
@@ -580,12 +580,12 @@
     $sql_where = "";
     if (incompleteAnsFilterstate() == "inc")
     {
-        $sql_where .= "submitdate IS NULL AND $busqueda";
+        $sql_where .= "submitdate IS NULL";
 
     }
     elseif (incompleteAnsFilterstate() == "filter")
     {
-        $sql_where .= "submitdate IS NOT NULL AND $busqueda";
+        $sql_where .= "submitdate IS NOT NULL";
 
     }
 
@@ -594,7 +594,7 @@
     $dtquery = "SELECT count(*) FROM $sql_from";
     if ($sql_where!="")
     {
-        $dtquery .=" WHERE $sql_where AND $busqueda";
+        $dtquery .=" WHERE $sql_where";
     }
     $dtresult=db_execute_num($dtquery) or safe_die("Couldn't get response data<br />$dtquery<br />".$connect->ErrorMsg());
     while ($dtrow=$dtresult->FetchRow()) {$dtcount=$dtrow[0];}
@@ -607,18 +607,18 @@
         if ($_SESSION['sql'] == "NULL" )
         {
             if ($surveyinfo['anonymized'] == "N" && db_tables_exist($tokentable))
-                $dtquery = "SELECT * FROM $surveytable LEFT JOIN $tokentable ON $surveytable.token = $tokentable.token WHERE $busqueda";
+                $dtquery = "SELECT * FROM $surveytable LEFT JOIN $tokentable ON $surveytable.token = $tokentable.token ";
             else
-                $dtquery = "SELECT * FROM $surveytable WHERE $busqueda";
+                $dtquery = "SELECT * FROM $surveytable ";
             // group token id
             $selectedgroup = returnglobal('selectgroup');
             if (incompleteAnsFilterstate() == "inc")
             {
-                $dtquery .= "AND submitdate IS NULL";
+                $dtquery .= "WHERE submitdate IS NULL ";
             }
             elseif (incompleteAnsFilterstate() == "filter")
             {
-                $dtquery .= " AND submitdate IS NOT NULL";
+                $dtquery .= " WHERE submitdate IS NOT NULL ";
             }
 
             $dtquery .= " ORDER BY {$surveytable}.id";
@@ -627,22 +627,22 @@
         {
 
             if ($surveytable['anonymized'] == "N" && db_tables_exist($tokentable))
-                $dtquery = "SELECT * FROM $surveytable LEFT JOIN $tokentable ON $surveytable.token = $tokentable.token WHERE 1=1 AND $busqueda";
+                $dtquery = "SELECT * FROM $surveytable LEFT JOIN $tokentable ON $surveytable.token = $tokentable.token WHERE 1=1 ";
             else
-                $dtquery = "SELECT * FROM $surveytable WHERE 1=1 AND $busqueda";
+                $dtquery = "SELECT * FROM $surveytable WHERE 1=1 ";
             $selectedgroup = returnglobal('selectgroup');
             if (incompleteAnsFilterstate() == "inc")
             {
-                $dtquery .= " AND submitdate IS NULL AND $busqueda";
+                $dtquery .= " AND submitdate IS NULL ";
 
             }
             elseif (incompleteAnsFilterstate() == "filter")
             {
-                $dtquery .= " AND submitdate IS NOT NULL AND $busqueda";
+                $dtquery .= " AND submitdate IS NOT NULL ";
             }
             if ($_SESSION['sql'] !== "")
             {
-                $dtquery .= ' AND '.$_SESSION['sql']." AND $busqueda";
+                $dtquery .= ' AND '.$_SESSION['sql']." ";
             }
             $dtquery .= " ORDER BY {$surveytable}.id";
         }
@@ -650,17 +650,17 @@
     else
     {
         if ($surveyinfo['anonymized'] == "N" && db_tables_exist($tokentable))
-            $dtquery = "SELECT * FROM $surveytable LEFT JOIN $tokentable ON $surveytable.token = $tokentable.token WHERE $busqueda";
+            $dtquery = "SELECT * FROM $surveytable LEFT JOIN $tokentable ON $surveytable.token = $tokentable.token ";
         else
-            $dtquery = "SELECT * FROM $surveytable WHERE $busqueda";
+            $dtquery = "SELECT * FROM $surveytable ";
         if (incompleteAnsFilterstate() == "inc")
         {
-            $dtquery .= " AND submitdate IS NULL";
+            $dtquery .= " WHERE submitdate IS NULL ";
 
         }
         elseif (incompleteAnsFilterstate() == "filter")
         {
-            $dtquery .= " AND submitdate IS NOT NULL";
+            $dtquery .= " WHERE submitdate IS NOT NULL ";
         }
 
         $dtquery .= " ORDER BY {$surveytable}.id";
@@ -701,7 +701,7 @@
                 ."<a href='$scriptname?action=browse&amp;subaction=all&amp;sid=$surveyid&amp;start=$last&amp;limit=$limit' "
                 ."title='".$clang->gTview("Show previous..")."' >"
                 ."<img name='DataBack' align='left'  src='$imageurl/databack.png' alt='".$clang->gT("Show previous..")."' /></a>\n"
-                ."<img src='$imageurl/blank.gif' width=$centro height='20' border='0' hspace='0' align='left' alt='' />\n"
+                ."<img src='$imageurl/blank.gif' width='13' height='20' border='0' hspace='0' align='left' alt='' />\n"
 
                 ."<a href='$scriptname?action=browse&amp;subaction=all&amp;sid=$surveyid&amp;start=$next&amp;limit=$limit' " .
                 "title='".$clang->gT("Show next...")."' >".
@@ -904,7 +904,7 @@
     if (!isset($start) || $start =='') {$start = 0;}
 
     //LETS COUNT THE DATA
-    $dtquery = "SELECT count(t.id) FROM {$surveytimingstable} t INNER JOIN {$surveytable} ON t.id={$surveytable}.id WHERE submitdate IS NOT NULL AND $busqueda";
+    $dtquery = "SELECT count(t.id) FROM {$surveytimingstable} t INNER JOIN {$surveytable} ON t.id={$surveytable}.id WHERE submitdate IS NOT NULL ";
 
     $dtresult=db_execute_num($dtquery) or safe_die("Couldn't get response data<br />$dtquery<br />".$connect->ErrorMsg());
     while ($dtrow=$dtresult->FetchRow()) {$dtcount=$dtrow[0];}
@@ -912,7 +912,7 @@
     if ($limit > $dtcount) {$limit=$dtcount;}
 
     //NOW LETS SHOW THE DATA
-    $dtquery = "SELECT t.* FROM {$surveytimingstable} t INNER JOIN {$surveytable} ON t.id={$surveytable}.id WHERE submitdate IS NOT NULL AND $busqueda ORDER BY {$surveytable}.id";
+    $dtquery = "SELECT t.* FROM {$surveytimingstable} t INNER JOIN {$surveytable} ON t.id={$surveytable}.id WHERE submitdate IS NOT NULL ORDER BY {$surveytable}.id";
 
     if ($order == "desc") {$dtquery .= " DESC";}
 
@@ -949,7 +949,7 @@
                 ."<a href='$scriptname?action=browse&amp;subaction=time&amp;sid=$surveyid&amp;start=$last&amp;limit=$limit' "
                 ."title='".$clang->gTview("Show previous..")."' >"
                 ."<img name='DataBack' align='left'  src='$imageurl/databack.png' alt='".$clang->gT("Show previous..")."' /></a>\n"
-                ."<img src='$imageurl/blank.gif' width=$centro height='20' border='0' hspace='0' align='left' alt='' />\n"
+                ."<img src='$imageurl/blank.gif' width='13' height='20' border='0' hspace='0' align='left' alt='' />\n"
 
                 ."<a href='$scriptname?action=browse&amp;subaction=time&amp;sid=$surveyid&amp;start=$next&amp;limit=$limit' " .
                 "title='".$clang->gT("Show next...")."' >".
@@ -1031,8 +1031,8 @@
 	//interview Time statistics
 	$count=false;
 	//$survstats=substr($surveytableNq);
-	$queryAvg="SELECT AVG(timings.interviewtime) AS avg, COUNT(timings.id) AS count FROM {$surveytableNq}_timings AS timings JOIN {$surveytable} AS surv ON timings.id=surv.id WHERE surv.submitdate IS NOT NULL AND $busqueda";
-	$queryAll="SELECT timings.interviewtime FROM {$surveytableNq}_timings AS timings JOIN {$surveytable} AS surv ON timings.id=surv.id WHERE surv.submitdate IS NOT NULL AND $busqueda ORDER BY timings.interviewtime";
+	$queryAvg="SELECT AVG(timings.interviewtime) AS avg, COUNT(timings.id) AS count FROM {$surveytableNq}_timings AS timings JOIN {$surveytable} AS surv ON timings.id=surv.id WHERE surv.submitdate IS NOT NULL";
+	$queryAll="SELECT timings.interviewtime FROM {$surveytableNq}_timings AS timings JOIN {$surveytable} AS surv ON timings.id=surv.id WHERE surv.submitdate IS NOT NULL ORDER BY timings.interviewtime";
 	$browseoutput .= '<table class="statisticssummary">';
 	if($result=db_execute_assoc($queryAvg)){
 
@@ -1083,8 +1083,8 @@
     $browseoutput .= $surveyoptions;
     $num_total_answers=0;
     $num_completed_answers=0;
-    $gnquery = "SELECT count(id) FROM $surveytable WHERE $busqueda";
-    $gnquery2 = "SELECT count(id) FROM $surveytable WHERE submitdate IS NOT NULL AND $busqueda";
+    $gnquery = "SELECT count(id) FROM $surveytable";
+    $gnquery2 = "SELECT count(id) FROM $surveytable WHERE submitdate IS NOT NULL";
     $gnresult = db_execute_num($gnquery);
     $gnresult2 = db_execute_num($gnquery2);
 
@@ -1130,7 +1130,7 @@
     {
         $responseId=(int)$responseId; // sanitize the value
 
-        $query = $initquery . " FROM $surveytable WHERE id=$responseId AND $busqueda";
+        $query = $initquery . " FROM $surveytable WHERE id=$responseId";
         $filearray = db_execute_assoc($query) or safe_die("Could not download response<br />$query<br />".$connect->ErrorMsg());
         $metadata = array();
         $filecount = 0;
comp_browse (13,157 bytes)

DWS

2012-07-31 16:15

reporter  

comp_stats (14,398 bytes)
--- /var/www/shop/ls/admin/statistics_function.php
+++ /var/www/shop/ls/admin/statistics_function (copy).php
@@ -54,6 +54,9 @@
     //$showcombinedresults = 0;
 
 
+
+
+
     //don't call this script directly!
     if (isset($_REQUEST['homedir'])) {die('You cannot start this script directly');}
 
@@ -500,17 +503,12 @@
 
         }	//end foreach -> loop through filter options to create SQL
 
-$sql0 = mysql_query("SELECT * FROM `lime_users` WHERE `users_name` ='$_SESSION[user]'");
-while ($mostrar = mysql_fetch_array($sql0)){ $centro=$mostrar['centro']; $idadmin=$mostrar['uid']; } mysql_free_result($sql0); 
-
-if($idadmin == 2) {$busqueda="29138X16X270 >= 0";} else {$busqueda="29138X16X270='$centro'";}
-
         //count number of answers
-        $query = "SELECT count(*) FROM ".db_table_name("survey_$surveyid")."WHERE ".$busqueda;
+        $query = "SELECT count(*) FROM ".db_table_name("survey_$surveyid");
 
         //if incompleted answers should be filtert submitdate has to be not null
-        if (incompleteAnsFilterstate() == "inc") {$query .= " AND submitdate is null ";}
-        elseif (incompleteAnsFilterstate() == "filter") {$query .= "AND submitdate is not null ";}
+        if (incompleteAnsFilterstate() == "inc") {$query .= " WHERE submitdate is null";}
+        elseif (incompleteAnsFilterstate() == "filter") {$query .= " WHERE submitdate is not null";}
         $result = db_execute_num($query) or safe_die ("Couldn't get total<br />$query<br />".$connect->ErrorMsg());
 
         //$total = total number of answers
@@ -520,12 +518,12 @@
         if (isset($selects) && $selects)
         {
             //filter incomplete answers?
-            if (incompleteAnsFilterstate() == "filter" || incompleteAnsFilterstate() == "inc") {$query .= " AND $busqueda ";}
-
-            else {$query .= " WHERE $busqueda ";}
+            if (incompleteAnsFilterstate() == "filter" || incompleteAnsFilterstate() == "inc") {$query .= " AND ";}
+
+            else {$query .= " WHERE ";}
 
             //add filter criteria to SQL
-            $query .= implode(" AND $busqueda ", $selects);
+            $query .= implode(" AND ", $selects);
         }
 
 
@@ -604,7 +602,7 @@
         }
 
         //put everything from $selects array into a string connected by AND
-        if (isset ($selects) && $selects) {$sql=implode(" AND $busqueda ", $selects);}
+        if (isset ($selects) && $selects) {$sql=implode(" AND ", $selects);}
 
         elseif (!empty($newsql)) {$sql = $newsql;}
 
@@ -1134,7 +1132,7 @@
                         if ($connect->databaseType == 'odbc_mssql' || $connect->databaseType == 'odbtp' || $connect->databaseType == 'mssql_n' || $connect->databaseType == 'mssqlnative')
                         {
                             //no NULL/empty values please
-                            $query .= " FROM ".db_table_name("survey_$surveyid")." WHERE ".db_quote_id($fieldname)." IS NOT NULL AND $busqueda";
+                            $query .= " FROM ".db_table_name("survey_$surveyid")." WHERE ".db_quote_id($fieldname)." IS NOT NULL";
                             if(!$excludezeros)
                             {
                                 //NO ZERO VALUES
@@ -1146,7 +1144,7 @@
                         else
                         {
                             //no NULL/empty values please
-                            $query .= " FROM ".db_table_name("survey_$surveyid")." WHERE ".db_quote_id($fieldname)." IS NOT NULL AND $busqueda ";
+                            $query .= " FROM ".db_table_name("survey_$surveyid")." WHERE ".db_quote_id($fieldname)." IS NOT NULL";
                             if(!$excludezeros)
                             {
                                 //NO ZERO VALUES
@@ -1155,11 +1153,11 @@
                         }
 
                         //filter incomplete answers if set
-                        if (incompleteAnsFilterstate() == "inc") {$query .= " AND submitdate is null AND $busqueda ";}
-                        elseif (incompleteAnsFilterstate() == "filter") {$query .= " AND submitdate is not null AND $busqueda ";}
+                        if (incompleteAnsFilterstate() == "inc") {$query .= " AND submitdate is null";}
+                        elseif (incompleteAnsFilterstate() == "filter") {$query .= " AND submitdate is not null";}
 
                         //$sql was set somewhere before
-                        if ($sql != "NULL") {$query .= " AND $sql $busqueda ";}
+                        if ($sql != "NULL") {$query .= " AND $sql";}
 
                         //execute query
                         $result=db_execute_assoc($query) or safe_die("Couldn't do maths testing<br />$query<br />".$connect->ErrorMsg());
@@ -1183,7 +1181,7 @@
                         //CALCULATE QUARTILES
 
                         //get data
-                        $query ="SELECT ".db_quote_id($fieldname)." FROM ".db_table_name("survey_$surveyid")." WHERE $busqueda AND ".db_quote_id($fieldname)." IS NOT null";
+                        $query ="SELECT ".db_quote_id($fieldname)." FROM ".db_table_name("survey_$surveyid")." WHERE ".db_quote_id($fieldname)." IS NOT null";
                         //NO ZEROES
                         if(!$excludezeros)
                         {
@@ -1191,8 +1189,8 @@
                         }
 
                         //filtering enabled?
-                        if (incompleteAnsFilterstate() == "inc") {$query .= "  AND submitdate is null ";}
-                        elseif (incompleteAnsFilterstate() == "filter") {$query .= " AND submitdate is not null ";}
+                        if (incompleteAnsFilterstate() == "inc") {$query .= " AND submitdate is null";}
+                        elseif (incompleteAnsFilterstate() == "filter") {$query .= " AND submitdate is not null";}
 
                         //if $sql values have been passed to the statistics script from another script, incorporate them
                         if ($sql != "NULL") {$query .= " AND $sql";}
@@ -1204,14 +1202,14 @@
                         //No Zeroes
                         if(!$excludezeros)
                         {
-                            $querystart .= " AND $busqueda AND ".db_quote_id($fieldname)." != 0";
+                            $querystart .= " AND ".db_quote_id($fieldname)." != 0";
                         }
                         //filtering enabled?
-                        if (incompleteAnsFilterstate() == "inc") {$querystarter .= " AND submitdate is null AND $busqueda ";}
-                        elseif (incompleteAnsFilterstate() == "filter") {$querystarter .= " AND submitdate is not null AND $busqueda ";}
+                        if (incompleteAnsFilterstate() == "inc") {$querystarter .= " AND submitdate is null";}
+                        elseif (incompleteAnsFilterstate() == "filter") {$querystarter .= " AND submitdate is not null";}
 
                         //if $sql values have been passed to the statistics script from another script, incorporate them
-                        if ($sql != "NULL") {$querystarter .= " AND $busqueda AND $sql";}
+                        if ($sql != "NULL") {$querystarter .= " AND $sql";}
 
                         //we just count the number of records returned
                         $medcount=$result->RecordCount();
@@ -1922,12 +1920,12 @@
                                 {
                                     // 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
-                                    $query = "SELECT count(*) FROM ".db_table_name("survey_$surveyid")." WHERE $busqueda ".db_quote_id(substr($al[2],0,strlen($al[2])-5))."='-oth-'";
+                                    $query = "SELECT count(*) FROM ".db_table_name("survey_$surveyid")." WHERE ".db_quote_id(substr($al[2],0,strlen($al[2])-5))."='-oth-'";
                                 }
                                 else
                                 {
                                     //get data
-                                    $query = "SELECT count(*) FROM ".db_table_name("survey_$surveyid")." WHERE $busqueda ";
+                                    $query = "SELECT count(*) FROM ".db_table_name("survey_$surveyid")." WHERE ";
                                     $query .= ($connect->databaseType == "mysql")?  db_quote_id($al[2])." != ''" : "NOT (".db_quote_id($al[2])." LIKE '')";
                                 }
                             }
@@ -1946,25 +1944,25 @@
                                 //free text answers
                                 if($al[0]=="Answers")
                                 {
-                                    $query = "SELECT count(*) FROM ".db_table_name("survey_$surveyid")." WHERE $busqueda AND ";
+                                    $query = "SELECT count(*) FROM ".db_table_name("survey_$surveyid")." WHERE ";
                                     $query .= ($connect->databaseType == "mysql")?  db_quote_id($al[2])." != ''" : "NOT (".db_quote_id($al[2])." LIKE '')";
                                 }
                                 //"no answer" handling
                                 elseif($al[0]=="NoAnswer")
                                 {
-                                    $query = "SELECT count(*) FROM ".db_table_name("survey_$surveyid")." WHERE $busqueda AND ( ";
+                                    $query = "SELECT count(*) FROM ".db_table_name("survey_$surveyid")." WHERE ( ";
                                     $query .= ($connect->databaseType == "mysql")?  db_quote_id($al[2])." = '')" : " (".db_quote_id($al[2])." LIKE ''))";
                                 }
                             }
                             elseif ($qtype == "O")
                             {
-                                $query = "SELECT count(*) FROM ".db_table_name("survey_$surveyid")." WHERE $busqueda AND ( ";
+                                $query = "SELECT count(*) FROM ".db_table_name("survey_$surveyid")." WHERE ( ";
                                 $query .= ($connect->databaseType == "mysql")?  db_quote_id($al[2])." <> '')" : " (".db_quote_id($al[2])." NOT LIKE ''))";
                                 // all other question types
                             }
                             else
                             {
-                                $query = "SELECT count(*) FROM ".db_table_name("survey_$surveyid")." WHERE $busqueda AND ".db_quote_id($al[2])." =";
+                                $query = "SELECT count(*) FROM ".db_table_name("survey_$surveyid")." WHERE ".db_quote_id($al[2])." =";
 
                                 //ranking question?
                                 if (substr($rt, 0, 1) == "R")
@@ -1988,10 +1986,10 @@
                                 if ($connect->databaseType == 'odbc_mssql' || $connect->databaseType == 'odbtp' || $connect->databaseType == 'mssql_n' || $connect->databaseType == 'mssqlnative')
                                 {
                                     // mssql cannot compare text blobs so we have to cast here
-                                    $query = "SELECT count(*) FROM ".db_table_name("survey_$surveyid")." WHERE  $busqueda AND cast(".db_quote_id($rt)." as varchar)= '$al[0]'";
+                                    $query = "SELECT count(*) FROM ".db_table_name("survey_$surveyid")." WHERE cast(".db_quote_id($rt)." as varchar)= '$al[0]'";
                                 }
                                 else
-                                    $query = "SELECT count(*) FROM ".db_table_name("survey_$surveyid")." WHERE $busqueda AND ".db_quote_id($rt)." = '$al[0]'";
+                                    $query = "SELECT count(*) FROM ".db_table_name("survey_$surveyid")." WHERE ".db_quote_id($rt)." = '$al[0]'";
                             }
                             else
                             { // This is for the 'NoAnswer' case
@@ -2006,14 +2004,14 @@
                                 {
                                     // mssql cannot compare text blobs so we have to cast here
                                     //$query = "SELECT count(*) FROM ".db_table_name("survey_$surveyid")." WHERE (".db_quote_id($rt)." IS NULL "
-                                    $query = "SELECT count(*) FROM ".db_table_name("survey_$surveyid")." WHERE $busqueda AND ( "
+                                    $query = "SELECT count(*) FROM ".db_table_name("survey_$surveyid")." WHERE ( "
                                     //                                    . "OR cast(".db_quote_id($rt)." as varchar) = '' "
                                     . "cast(".db_quote_id($rt)." as varchar) = '' "
                                     . "OR cast(".db_quote_id($rt)." as varchar) = ' ' )";
                                 }
                                 else
                                     //			    $query = "SELECT count(*) FROM ".db_table_name("survey_$surveyid")." WHERE (".db_quote_id($rt)." IS NULL "
-                                    $query = "SELECT count(*) FROM ".db_table_name("survey_$surveyid")." WHERE $busqueda AND ( "
+                                    $query = "SELECT count(*) FROM ".db_table_name("survey_$surveyid")." WHERE ( "
                                     //								    . "OR ".db_quote_id($rt)." = '' "
                                     . " ".db_quote_id($rt)." = '' "
                                     . "OR ".db_quote_id($rt)." = ' ') ";
@@ -2022,8 +2020,8 @@
                         }
 
                         //check filter option
-                        if (incompleteAnsFilterstate() == "inc") {$query .= " AND submitdate is null AND $busqueda ";}
-                        elseif (incompleteAnsFilterstate() == "filter") {$query .= " AND submitdate is not null AND $busqueda";}
+                        if (incompleteAnsFilterstate() == "inc") {$query .= " AND submitdate is null";}
+                        elseif (incompleteAnsFilterstate() == "filter") {$query .= " AND submitdate is not null";}
 
                         //check for any "sql" that has been passed from another script
                         if ($sql != "NULL") {$query .= " AND $sql";}
comp_stats (14,398 bytes)

DWS

2012-07-31 16:16

reporter   ~20092

done, I upload diff files (made with diff meld) from each file

DWS

2013-03-05 12:55

reporter   ~24549

Nice to see that this Issue is assigned!

Now I have done a lot of modifications on limesurvey 1.92 to have this issue working on. I can share this work with you in order to evaluate the solution.

DenisChenu

2013-03-05 13:53

developer   ~24553

Plugon/2.05 ?

https://www.limesurvey.org/component/content/article/1/347-your-feedback-plugins-for-limesurvey-205

Issue History

Date Modified Username Field Change
2012-07-30 14:37 DWS New Issue
2012-07-30 14:37 DWS File Added: statistics_function.php
2012-07-30 14:38 DWS File Added: browse.php
2012-07-30 14:39 DWS Note Added: 20072
2012-07-30 14:40 DWS Note Added: 20074
2012-07-30 17:47 DenisChenu Note Added: 20076
2012-07-31 16:15 DWS File Added: comp_browse
2012-07-31 16:15 DWS File Added: comp_stats
2012-07-31 16:16 DWS Note Added: 20092
2013-03-05 12:38 c_schmitz Assigned To => c_schmitz
2013-03-05 12:38 c_schmitz Status new => acknowledged
2013-03-05 12:38 c_schmitz Assigned To c_schmitz =>
2013-03-05 12:38 c_schmitz Status acknowledged => confirmed
2013-03-05 12:55 DWS Note Added: 24549
2013-03-05 13:53 DenisChenu Note Added: 24553