View Issue Details

This bug affects 1 person(s).
 8
IDProjectCategoryView StatusLast Update
05323Bug reportsSurvey takingpublic2012-03-14 21:08
Reporteruser14785Assigned Toc_schmitz  
PrioritynormalSeverityminor 
Status closedResolutionfixed 
Product Version1.91+ 
Fixed in Version1.91+ 
Summary05323: .missing class added in answered filtered array question "Show question index / allow jumping" modality
Description

In "Show index/allow jumping" modality .missing class is added at filtered array question even if all subquestions are answered

Steps To Reproduce
  • Create survey with "Show question index / allow jumping" and "View one group per page" set to yes

  • Create 2 groups

  • in the 1st group

    • Create a multiple choice question
    • Create an array question with the multiple choice as filter
  • in the 2nd group create one question

  • Start the survey

  • Check some option in the multiple choice (not all)

  • Answer all the options shown in the array question

  • Go to next page

In the index the first group will be marked as if there are missing answer.

Going to the previous page will show that the array question has been marked as missing (class=".missing")

an example can be seen at http://www.officair-survey.eu/index.php?sid=19883&lang=en

TagsNo tags attached.
Attached Files
floccs.patch (2,846 bytes)   
Index: common_functions.php
===================================================================
--- common_functions.php	(revisione 11141)
+++ common_functions.php	(copia locale)
@@ -7668,12 +7668,14 @@
  */
 function bCheckQuestionForAnswer($q, $aFieldnamesInfoInv)
 {
-	if (@$_SESSION['fieldmap'][$aFieldnamesInfoInv[$q][0]]['type'] == 'X')
+    $qtype = $_SESSION['fieldmap'][$aFieldnamesInfoInv[$q][0]]['type'];
+
+    if ($qtype == 'X')
     {
         // boilerplate have no answers
         return true;
     }
-    else if (@$_SESSION['fieldmap'][$aFieldnamesInfoInv[$q][0]]['type'] == 'M' || @$_SESSION['fieldmap'][$aFieldnamesInfoInv[$q][0]]['type'] == 'P' || @$_SESSION['fieldmap'][$aFieldnamesInfoInv[$q][0]]['type'] == 'O')
+    else if ($qtype == 'M' || $qtype == 'P' || $qtype == 'O')
     {
         // multiple choice and list with comments question types - just one answer is required and comments are not required
         $bAnsw = false;
@@ -7686,8 +7688,56 @@
             }
         }
     }
+    else if ($qtype == 'F' || $qtype == ':' || $qtype == ';' || $qtype == '1' || $qtype == 'C' || $qtype == 'B' || $qtype == 'A' || $qtype == 'E')
+    {
+        // array question types - if filtered only displayed answer are required
+        $bAnsw = true;
+
+        $qid=$_SESSION['fieldmap'][$aFieldnamesInfoInv[$q][0]]['qid'];
+
+        $gquery = "SELECT * FROM ".db_table_name('question_attributes')." WHERE qid={$qid} AND attribute ='array_filter'";
+        $qresult = db_execute_assoc($gquery); //checked
+        $qrows = $qresult->GetRows();
+
+        $filter=$qrows[0]['value'];
+
+        //if there is no filter checkall answers
+        if (trim($filter) == '')
+            goto checkall;
+
+
+        foreach($_SESSION['fieldarray'] as $field)
+        {
+            //look for the multiple choice filter
+            if ($field[2] == $filter && $field[4] == 'M')
+            {
+                //filter SQG
+                $array_filter = $field[1];
+                break;
+            }
+        }
+        
+        //if filter not found checkall answers
+        if ($array_filter == '')
+            goto checkall;
+
+        foreach($aFieldnamesInfoInv[$q] as $sField)
+        {
+        //keep only first SQ for multiple scale answer
+        $aid = explode('_',$_SESSION['fieldmap'][$sField]['aid']);
+        $aid = explode('#',$aid[0]);
+
+        if ($_SESSION[$array_filter.$aid[0]]=='Y' && $_SESSION[$sField]=='')
+	        {
+                $bAnsw = false;
+		        break;
+	        }
+        }
+
+    }
     else
     {
+        checkall:
         // all answers required for all other question types
         $bAnsw = true;
         foreach($aFieldnamesInfoInv[$q] as $sField)
@@ -7698,7 +7748,9 @@
                 break;
             }
         }
+
     }
+
     return $bAnsw;
 }
 
floccs.patch (2,846 bytes)   
floccs_01.patch (5,314 bytes)   
Index: common_functions.php
===================================================================
--- common_functions.php	(revisione 11199)
+++ common_functions.php	(copia locale)
@@ -7668,90 +7668,71 @@
  */
 function bCheckQuestionForAnswer($q, $aFieldnamesInfoInv)
 {
-    $qtype = $_SESSION['fieldmap'][$aFieldnamesInfoInv[$q][0]]['type'];
+    $qtype = @$_SESSION['fieldmap'][$aFieldnamesInfoInv[$q][0]]['type'];
 
-    if ($qtype == 'X')
-    {
-        // boilerplate have no answers
-        return true;
-    }
-    else if ($qtype == 'M' || $qtype == 'P' || $qtype == 'O')
-    {
-        // multiple choice and list with comments question types - just one answer is required and comments are not required
-        $bAnsw = false;
-        foreach($aFieldnamesInfoInv[$q] as $sField)
-        {
-            if(!strstr($sField, 'comment') && isset($_SESSION[$sField]) && trim($_SESSION[$sField])!='')
-            {
-                $bAnsw = true;
-                break;
-            }
-        }
-    }
-    else if ($qtype == 'F' || $qtype == ':' || $qtype == ';' || $qtype == '1' || $qtype == 'C' || $qtype == 'B' || $qtype == 'A' || $qtype == 'E')
-    {
-        // array question types - if filtered only displayed answer are required
-        $bAnsw = true;
+    switch ($qtype) {
+        case 'X':
+            return true;
+        case 'M':
+        case 'P':
+        case 'O':
+            // multiple choice and list with comments question types - just one answer is required and comments are not required
+            foreach($aFieldnamesInfoInv[$q] as $sField)
+                if(!strstr($sField, 'comment') && isset($_SESSION[$sField]) && trim($_SESSION[$sField])!='')
+                    return true;
+            return false;
+        case 'F':
+        case ':':
+        case ';':
+        case '1':
+        case 'C':
+        case 'B':
+        case 'A':
+        case 'E':
+            // array question types - if filtered only displayed answer are required
+            $qattr = getQuestionAttributes(@$_SESSION['fieldmap'][$aFieldnamesInfoInv[$q][0]]['qid'], $qtype);
 
-        $qid=$_SESSION['fieldmap'][$aFieldnamesInfoInv[$q][0]]['qid'];
+            $qcodefilter = @$qattr['array_filter'];
 
-        $gquery = "SELECT * FROM ".db_table_name('question_attributes')." WHERE qid={$qid} AND attribute ='array_filter'";
-        $qresult = db_execute_assoc($gquery); //checked
-        $qrows = $qresult->GetRows();
+            $sgqfilter = '';
 
-        $filter=$qrows[0]['value'];
+            foreach($_SESSION['fieldarray'] as $field)
+                //look for the multiple choice filter
+                if ($field[2] == $qcodefilter && $field[4] == 'M')
+                {
+                    //filter SQG
+                    $sgqfilter = $field[1];
+                    break;
+                }
 
-        //if there is no filter checkall answers
-        if (trim($filter) == '')
-            goto checkall;
-
-
-        foreach($_SESSION['fieldarray'] as $field)
-        {
-            //look for the multiple choice filter
-            if ($field[2] == $filter && $field[4] == 'M')
+            //if filter not found checkall answers
+            if ($sgqfilter == '')
             {
-                //filter SQG
-                $array_filter = $field[1];
-                break;
+                // all answers required
+                foreach($aFieldnamesInfoInv[$q] as $sField)
+                    if(!isset($_SESSION[$sField]) || trim($_SESSION[$sField])=='')
+                        return false;
+                return true;
             }
-        }
-        
-        //if filter not found checkall answers
-        if ($array_filter == '')
-            goto checkall;
 
-        foreach($aFieldnamesInfoInv[$q] as $sField)
-        {
-        //keep only first SQ for multiple scale answer
-        $aid = explode('_',$_SESSION['fieldmap'][$sField]['aid']);
-        $aid = explode('#',$aid[0]);
-
-        if ($_SESSION[$array_filter.$aid[0]]=='Y' && $_SESSION[$sField]=='')
-	        {
-                $bAnsw = false;
-		        break;
-	        }
-        }
-
-    }
-    else
-    {
-        checkall:
-        // all answers required for all other question types
-        $bAnsw = true;
-        foreach($aFieldnamesInfoInv[$q] as $sField)
-        {
-            if(!isset($_SESSION[$sField]) || trim($_SESSION[$sField])=='')
+            foreach($aFieldnamesInfoInv[$q] as $sField)
             {
-                $bAnsw = false;
-                break;
+                //keep only first subquestion code for multiple scale answer
+                $aid = explode('_',$_SESSION['fieldmap'][$sField]['aid']);
+                $aid = explode('#',$aid[0]);
+                //if a checked answer in the multiple choice is not present
+                if ($_SESSION[$sgqfilter.$aid[0]] == 'Y' && $_SESSION[$sField] == '')
+                    return false;    
             }
-        }
-
+            return true;
+        default:
+            // all answers required for all other question types
+            foreach($aFieldnamesInfoInv[$q] as $sField)
+                if(!isset($_SESSION[$sField]) || trim($_SESSION[$sField])=='')
+                    return false;
+            return true;
     }
 
-    return $bAnsw;
 }
 
 /**
floccs_01.patch (5,314 bytes)   
Bug heat8
Complete LimeSurvey version number (& build)10377
I will donate to the project if issue is resolvedYes
BrowserChrome, Firefox
Database type & versionMysql 5.1.52
Server OS (if known)Linux
Webserver software & version (if known)LiteSpeed V5.5
PHP Version5.2

Users monitoring this issue

There are no users monitoring this issue.

Activities

user14785

2011-10-11 20:12

  ~16391

I've made a patch for this issue, can you review it?

This should fix the problem.
Tell me if there is something wrong.

Mazi

Mazi

2011-10-12 14:03

updater   ~16400

Thanks for providing a patch. Can you also attach a sample survey for testing?

user14785

2011-10-12 14:14

  ~16402

sample survey attached

DenisChenu

DenisChenu

2011-10-14 14:42

developer   ~16420

For me in the link example , it work like a charm:

checked 1 and 2, selext column 1 to each line,
Next : no .missing
Previuos : no .missing
Next : no .missing
Previous: uncheck 1 , check 4
Next : .missing
Previous .missing for 4 in table

I see no problem :)

user14785

2011-10-14 15:17

  ~16422

i'm sorry but the link provided in the description is now working with the patch i've written.

try loading the survey attached on a non patched version of limesurvey to reproduce the bug.

c_schmitz

c_schmitz

2011-10-18 18:56

administrator   ~16455

Patch looks okay - thank you!

user14785

2011-10-18 20:15

  ~16458

I've attached a patch with more readable code. Don't know if I have to reopen the issue to have it applied

c_schmitz

c_schmitz

2011-10-19 15:26

administrator   ~16472

Thank you! Yes, that looks much better since i just found out that goto mark is only supported in 5.3 and up.

c_schmitz

c_schmitz

2011-10-26 18:28

administrator   ~16532

New version released

Related Changesets

LimeSurvey: Yii d987a83b

2011-10-18 09:58:44

c_schmitz

Details Diff
Fixed issue 05323: .missing class added in answered filtered array question "Show question index / allow jumping" modality - patch by flocs

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_ci@11199 b72ed6b6-b9f8-46b5-92b4-906544132732
Affected Issues
05323
mod - application/helpers/common_helper.php Diff File

LimeSurvey: Yii 4ec26f3b

2011-10-19 07:00:30

c_schmitz

Details Diff
Fixed issue 05323: .missing class added in answered filtered array question "Show question index / allow jumping" modality - patch by flocs
Fixed issue 05508: $printanswershonorsconditions settings doesn't work - all questions are shown in Print Answers page -
Dev printanswershonorsconditions config variable is now completely removed and Print answers always honors conditions

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_ci@11207 b72ed6b6-b9f8-46b5-92b4-906544132732
Affected Issues
05323, 05508
mod - application/config/lsconfig.php Diff File
mod - application/controllers/printanswers.php Diff File
mod - application/helpers/common_helper.php Diff File

Issue History

Date Modified Username Field Change
2011-07-06 20:25 user14785 New Issue
2011-07-07 12:11 user14785 Issue Monitored: user14785
2011-07-07 12:11 user14785 Issue End Monitor: user14785
2011-07-08 17:02 c_schmitz Assigned To => user9586
2011-07-08 17:02 c_schmitz Status new => assigned
2011-09-05 14:56 c_schmitz Assigned To user9586 => c_schmitz
2011-10-11 20:12 user14785 File Added: floccs.patch
2011-10-11 20:12 user14785 Note Added: 16391
2011-10-12 14:03 Mazi Note Added: 16400
2011-10-12 14:14 user14785 File Added: limesurvey_survey_19883.lss
2011-10-12 14:14 user14785 Note Added: 16402
2011-10-14 14:42 DenisChenu Note Added: 16420
2011-10-14 15:17 user14785 Note Added: 16422
2011-10-18 18:56 c_schmitz Note Added: 16455
2011-10-18 18:56 c_schmitz Status assigned => resolved
2011-10-18 18:56 c_schmitz Fixed in Version => 1.91+
2011-10-18 18:56 c_schmitz Resolution open => fixed
2011-10-18 20:15 user14785 File Added: floccs_01.patch
2011-10-18 20:15 user14785 Note Added: 16458
2011-10-19 15:26 c_schmitz Note Added: 16472
2011-10-26 18:28 c_schmitz Note Added: 16532
2011-10-26 18:28 c_schmitz Status resolved => closed
2012-03-14 21:08 c_schmitz Changeset attached => Import 2012-03-09 13:30:34 Yii 4ec26f3b
2012-03-14 21:08 c_schmitz Changeset attached => Import 2012-03-09 13:30:34 Yii d987a83b