View Issue Details

This bug affects 1 person(s).
 8
IDProjectCategoryView StatusLast Update
05042Bug reportsSurvey editingpublic2011-04-11 11:30
ReporterJoyLaneResearch Assigned Tojcleeland  
PrioritylowSeveritytweak 
Status closedResolutionfixed 
Product Version1.90+ 
Fixed in Version1.91RC6 
Summary05042: GSOC: Too many on-screen headings in an array using array filter
Description

I have a survey that asks which of 120 stores respondents have shopped (multiple options). A follow-up question asks ratings of stores shopped (array, using an array filter). My system is set to repeat headings in a table every eight rows. The follow-up question still has all the heading rows, even though it doesn't have all the stores. Is there a workaround? Thanks!

Steps To Reproduce
  • In global settings, change number of answers to show before repeating the headings in array questions to 8.
  • Set Create long multiple options question (about 50 items) as Q1.
  • Create an array with the same subquestions and call it Q2.
  • Set a Q2 array filter based on Q1.
  • Test the survey with 2-5 options chosen in Q1.
  • Extra headings will likely appear where they seem awkward.
TagsNo tags attached.
Attached Files
bug 05042.patch (3,618 bytes)   
Index: qanda.php
===================================================================
--- qanda.php	(revision 9945)
+++ qanda.php	(working copy)
@@ -1360,6 +1360,60 @@
     return $output;
 }
 
+function return_array_filter_selected($ia, $qidattributes, $thissurvey, $ansrow, $rowname, $trbc='', $valuename, $method="tbody", $class=null)
+// function which returns TRUE if the given $ansrow contains a row which is selected, ie, not filtered out in previous answer
+{
+	$filter_select = TRUE;
+	if
+    (
+    (trim($qidattributes['array_filter'])!='' && 		// The array filter attribute is set
+    $thissurvey['format'] == 'S'						// and the survey is being presented in question-by-question mode
+    ) || 												// OR
+    (trim($qidattributes['array_filter'])!='' && 		// The array filter attribute is set
+    $thissurvey['format'] == 'G' && 					// and the survey is being presented in group-by-group mode
+    getArrayFiltersOutGroup($ia[0]) == true			// and the source question for the array filter is in a different group than this question
+    )
+    )
+    {
+        $selected = getArrayFiltersForQuestion($ia[0]);
+        if (isset($ansrow['code'])) $ansrow['title'] = $ansrow['code'];
+        if (!empty($selected) && !in_array($ansrow['title'],$selected))
+        {
+			$filter_select = FALSE;
+		}
+		else
+		{
+			$filter_select = TRUE;
+		}
+	}
+	
+	if
+    (isset($qidattributes['array_filter_exclude']) &&
+	(
+    (trim($qidattributes['array_filter_exclude'])!='' &&
+    $thissurvey['format'] == 'S'
+    ) ||
+    (trim($qidattributes['array_filter_exclude'])!='' &&
+    $thissurvey['format'] == 'G' &&
+    getArrayFiltersExcludesOutGroup($ia[0]) == true
+    )
+	)
+    )
+    {
+        $selected = getArrayFilterExcludesForQuestion($ia[0]);
+        if (isset($ansrow['code'])) $ansrow['title'] = $ansrow['code'];  
+        if (!empty($selected) && !in_array($ansrow['title'],$selected))
+        {
+			$filter_select = TRUE;
+		}
+		else
+		{
+			$filter_select = FALSE;
+		}
+	}
+	return $filter_select; 
+}
+
 function return_array_filter_strings($ia, $qidattributes, $thissurvey, $ansrow, $rowname, $trbc='', $valuename, $method="tbody", $class=null) {
     /* We're just going to work out whether to do the include or exclude version of the function at this point */
     if(isset($qidattributes['array_filter_exclude']) && trim($qidattributes['array_filter_exclude']) != '') {
@@ -5987,7 +6041,6 @@
                 }
             }
             $myfname = $ia[1].$ansrow['title'];
-            $trbc = alternation($trbc , 'row');
             $answertext=dTexts::run($ansrow['question']);
             $answertextsave=$answertext;
             if (strpos($answertext,'|'))
@@ -6005,7 +6058,13 @@
             }
             // Get array_filter stuff
             list($htmltbody2, $hiddenfield)=return_array_filter_strings($ia, $qidattributes, $thissurvey, $ansrow, $myfname, $trbc, $myfname);
-            $answer .= $htmltbody2;
+            $row_selected = return_array_filter_selected($ia, $qidattributes, $thissurvey, $ansrow, $myfname, $trbc, $myfname);
+			if($row_selected)
+			{
+				$trbc = alternation($trbc , 'row');
+				$fn++;
+			}
+			$answer .= $htmltbody2;
              
             $answer .= "<tr class=\"$trbc\">\n"
             . "\t<th class=\"answertext\">\n$answertext"
@@ -6062,7 +6121,6 @@
             $answer .= "</tr>\n";
             $inputnames[]=$myfname;
             //IF a MULTIPLE of flexi-redisplay figure, repeat the headings
-            $fn++;
         }
 
         $answer_cols = "\t<colgroup class=\"col-responses\">\n"
bug 05042.patch (3,618 bytes)   
qanda.php (315,207 bytes)
Bug heat8
Complete LimeSurvey version number (& build)9642
I will donate to the project if issue is resolvedNo
BrowserIE8 and FF3.6
Database type & versionMySQL 5-something
Server OS (if known)LS is on RedHat Linux, browser is on Windows 7
Webserver software & version (if known)Rackspace
PHP Version5.2

Relationships

related to 05087 closedjcleeland GSoc: Background color at matrix questions gets messed up when using array_filter 

Users monitoring this issue

There are no users monitoring this issue.

Activities

Mazi

Mazi

2011-03-21 00:36

updater   ~14483

There is also a similar array filter problem when highlighting lines at a following array question. Depending on the number of remaining answers at the following question the color alternation doesn't work properly.

user12700

2011-04-03 21:26

  ~14639

Hi,
I have uploaded a patch file, please try it out, and confirm if it fixes the bug.

I have also attached a test survey structure(limesurvey_survey_62432.lss), which exhibits the bug in question.

Mazi

Mazi

2011-04-04 20:02

updater   ~14664

Jason, can you please have a look at the patch!?

jcleeland

jcleeland

2011-04-05 03:36

reporter   ~14668

Hi anurag89, could you post your whole qanda.php file, I'm having all sorts of problems using the patch file (probably not your fault), but it'll be easier for me to just do a merge between two file versions to check this out.

Thanks,

Jason

user12700

2011-04-05 07:31

  ~14669

Hi Jason,
I have uploaded the qanda.php.

Thanks,
Anurag

jcleeland

jcleeland

2011-04-06 11:47

reporter   ~14685

Thanks Anurag, I've tested the fix and committed it to SVN. Nice work :-)

jcleeland

jcleeland

2011-04-06 11:48

reporter   ~14686

Thanks to Anurag/Anurag89 for this fix

jcleeland

jcleeland

2011-04-06 11:49

reporter   ~14687

Oh, Mazi - could you create the bug relating to the alternating colours and label it GSOC? Thanks!

Mazi

Mazi

2011-04-06 12:14

updater   ~14689

New ticket opened: http://bugs.limesurvey.org/view.php?id=5087

user12700

2011-04-06 18:10

  ~14702

Thanks for the appreciation... :-)

but i had also fixed the alternating color problem in this patch, since i had already seen mazi's comment...

You can check it out...

Thanks,
Anurag

c_schmitz

c_schmitz

2011-04-11 11:30

administrator   ~14748

1.91RC6 released.

Issue History

Date Modified Username Field Change
2011-03-19 00:48 JoyLaneResearch New Issue
2011-03-21 00:36 Mazi Assigned To => jcleeland
2011-03-21 00:36 Mazi Status new => assigned
2011-03-21 00:36 Mazi Note Added: 14483
2011-03-24 19:01 user12741 Issue Monitored: user12741
2011-03-26 17:47 Mazi Summary Too many on-screen headings in an array using array filter => GSOC: Too many on-screen headings in an array using array filter
2011-04-03 21:22 user12700 File Added: limesurvey_survey_62432.lss
2011-04-03 21:22 user12700 File Added: bug 05042.patch
2011-04-03 21:26 user12700 Note Added: 14639
2011-04-04 20:02 Mazi Note Added: 14664
2011-04-05 03:36 jcleeland Note Added: 14668
2011-04-05 07:29 user12700 File Added: qanda.php
2011-04-05 07:31 user12700 Note Added: 14669
2011-04-06 11:47 jcleeland Note Added: 14685
2011-04-06 11:48 jcleeland Note Added: 14686
2011-04-06 11:48 jcleeland Status assigned => resolved
2011-04-06 11:48 jcleeland Fixed in Version => 1.91RC6
2011-04-06 11:48 jcleeland Resolution open => fixed
2011-04-06 11:49 jcleeland Note Added: 14687
2011-04-06 12:14 Mazi Relationship added related to 05087
2011-04-06 12:14 Mazi Note Added: 14689
2011-04-06 18:10 user12700 Note Added: 14702
2011-04-11 11:30 c_schmitz Note Added: 14748
2011-04-11 11:30 c_schmitz Status resolved => closed
2019-11-01 17:25 c_schmitz Category Survey design => Survey editing