View Issue Details

IDProjectCategoryView StatusLast Update
04588User patchesOtherpublic2010-12-14 13:02
Reporteruser9586Assigned Toc_schmitz 
PrioritynormalSeverityminor 
Status closedResolutionfixed 
Product Version 
Target VersionFixed in Version1.91 
Summary04588: Allow to reverse iteration order in Array (Numbers).
Description

This patch allows to reverse the iteration order of the generated numbers when setting "Minimum value" "Maximum value" and "Step" in "Array (Numbers)" question type.

Reverse ordering can be achieved by putting a _max value lower than _min. The loop will iterate in reverse (you don't need to put a negative step value).

Requested by our Q/A group, for questions where ordering could introduce bias.

Additional Information

I've tuned the sort order of the "min/step/max" parameters so that they are consecutive.

This patch also fixes the infinite loop generated by inserting a negative step value.

TagsNo tags attached.
Complete LimeSurvey version number (& build)9114

Relationships

related to 04589 closedc_schmitz Allow to reverse year order in dropdown dates. 

Activities

c_schmitz

c_schmitz

2010-10-11 21:31

administrator   ~13084

Last edited: 2010-10-11 21:38

View 2 revisions

Thank you very much!
But same here: Could you rather make this a question attribute?

c_schmitz

c_schmitz

2010-10-11 23:55

administrator   ~13087

Can you please provide the patch as a subversion patch (svn diff) against our 1.91 development version at the subversion branch at :
https://limesurvey.svn.sourceforge.net/svnroot/limesurvey/source/limesurvey_dev

Thank you!

user9586

2010-10-21 12:44

  ~13299

I was able to update this patch and 04589 to use a common 'reverse answer order' attribute, but I cannot reliably diff using subversion until the earlier patches are either accepted or discarded.

c_schmitz

c_schmitz

2010-11-01 17:27

administrator   ~13387

Wavexx, there is no problem if two issue are overlaying that you submit one patch for it - if it is a real subversion patch :-)

user9586

2010-11-04 15:56

 

patch-svn.diff (3,113 bytes)
Index: common_functions.php
===================================================================
--- common_functions.php	(revision 9413)
+++ common_functions.php	(working copy)
@@ -3661,7 +3661,7 @@
     $qattributes["multiflexible_max"]=array(
     "types"=>":",
     'category'=>$clang->gT('Display'),
-     'sortorder'=>100,
+     'sortorder'=>112,
    'inputtype'=>'text',
     "help"=>$clang->gT('Maximum value for array(mult-flexible) question type'),
     "caption"=>$clang->gT('Maximum value'));
@@ -3669,7 +3669,7 @@
     $qattributes["multiflexible_min"]=array(
     "types"=>":",
     'category'=>$clang->gT('Display'),
-    'sortorder'=>100,
+    'sortorder'=>110,
     'inputtype'=>'text',
     "help"=>$clang->gT('Minimum value for array(multi-flexible) question type'),
     "caption"=>$clang->gT('Minimum value'));
@@ -3677,7 +3677,7 @@
     $qattributes["multiflexible_step"]=array(
     "types"=>":",
     'category'=>$clang->gT('Display'),
-    'sortorder'=>100,
+    'sortorder'=>111,
     'inputtype'=>'text',
     "help"=>$clang->gT('Step value'),
     "caption"=>$clang->gT('Step value'));
@@ -3693,6 +3693,17 @@
     "help"=>$clang->gT('Use checkbox layout'),
     "caption"=>$clang->gT('Checkbox layout'));
 
+    $qattributes["reverse"]=array(
+    "types"=>":",
+    'category'=>$clang->gT('Display'),
+    'sortorder'=>100,
+    'inputtype'=>'singleselect',
+    'options'=>array(0=>$clang->gT('No'),
+    1=>$clang->gT('Yes')),
+    'default'=>0,
+    "help"=>$clang->gT('Present answers in reverse order'),
+    "caption"=>$clang->gT('Reverse answer order'));
+
     $qattributes["num_value_equals_sgqa"]=array(
     "types"=>"K",
     'category'=>$clang->gT('Logic'),
Index: qanda.php
===================================================================
--- qanda.php	(revision 9413)
+++ qanda.php	(working copy)
@@ -6408,7 +6408,7 @@
         }
     }
 
-    if (trim($qidattributes['multiflexible_step'])!='')
+    if (trim($qidattributes['multiflexible_step'])!='' && $qidattributes['multiflexible_step'] > 0)
     {
         $stepvalue=$qidattributes['multiflexible_step'];
     }
@@ -6417,6 +6417,19 @@
         $stepvalue=1;
     }
 
+    if($qidattributes['reverse']==1)
+    {
+        $tmp = $minvalue;
+        $minvalue = $maxvalue;
+        $maxvalue = $tmp;
+        $reverse=true;
+        $stepvalue=-$stepvalue;
+    }
+    else
+    {
+        $reverse=false;
+    }
+
     $checkboxlayout=false;
     if ($qidattributes['multiflexible_checkbox']!=0)
     {
@@ -6583,7 +6596,7 @@
                         . " onchange=\"$checkconditionFunction(this.value, this.name, this.type)\">\n"
                         . "<option value=\"\">".$clang->gT('...')."</option>\n";
 
-                        for($ii=$minvalue; $ii<=$maxvalue; $ii+=$stepvalue) {
+                        for($ii=$minvalue; ($reverse? $ii>=$maxvalue:$ii<=$maxvalue); $ii+=$stepvalue) {
                             $answer .= "<option value=\"$ii\"";
                             if(isset($_SESSION[$myfname2]) && $_SESSION[$myfname2] == $ii) {
                                 $answer .= SELECTED;
patch-svn.diff (3,113 bytes)

user9586

2010-11-04 15:56

  ~13422

Next patch. Introduced the 'reverse' attribute.

c_schmitz

c_schmitz

2010-11-04 16:05

administrator   ~13423

Last edited: 2010-11-04 16:06

View 1 revisions

Thank you! These patches are of great value & quality!
Next one?

Issue History

Date Modified Username Field Change
2010-09-09 11:57 user9586 New Issue
2010-09-09 11:57 user9586 File Added: patch.diff
2010-10-11 18:19 c_schmitz Assigned To => c_schmitz
2010-10-11 18:19 c_schmitz Status new => assigned
2010-10-11 21:31 c_schmitz Note Added: 13084
2010-10-11 21:31 c_schmitz Status assigned => resolved
2010-10-11 21:31 c_schmitz Fixed in Version => 1.91
2010-10-11 21:31 c_schmitz Resolution open => fixed
2010-10-11 21:38 c_schmitz Status resolved => feedback
2010-10-11 21:38 c_schmitz Resolution fixed => reopened
2010-10-11 21:38 c_schmitz Relationship added related to 04589
2010-10-11 21:38 c_schmitz Note Edited: 13084 View Revisions
2010-10-11 23:55 c_schmitz Note Added: 13087
2010-10-21 12:44 user9586 Note Added: 13299
2010-10-21 12:44 user9586 Status feedback => assigned
2010-11-01 17:27 c_schmitz Note Added: 13387
2010-11-04 15:56 user9586 File Added: patch-svn.diff
2010-11-04 15:56 user9586 Note Added: 13422
2010-11-04 16:00 c_schmitz File Deleted: patch.diff
2010-11-04 16:05 c_schmitz Note Added: 13423
2010-11-04 16:05 c_schmitz Status assigned => resolved
2010-11-04 16:05 c_schmitz Resolution reopened => fixed
2010-11-04 16:06 c_schmitz Note Edited: 13423 View Revisions
2010-11-04 16:06 c_schmitz Note Revision Dropped: 13423: 00388
2010-12-14 13:02 c_schmitz Status resolved => closed