View Issue Details

This bug affects 1 person(s).
 6
IDProjectCategoryView StatusLast Update
12456Bug reportsConditionspublic2018-02-15 12:03
Reportersickpig Assigned Toc_schmitz  
PrioritynoneSeveritypartial_block 
Status closedResolutionreopened 
Product Version2.64.x 
Fixed in Version3.0.x 
Summary12456: Conditional routing doesn't work on scale and array questions
Description

Values of scale and array question is treated like string rather than array while evaluating routing conditions.

This means that for a 1 to 10 scale, 4 < 10 evaluate to false.

Steps To Reproduce

Q1 scale 1 to 20
Q2 short text entry

Q2 has to be filled only if Q1 < 10

for every value of Q1 belonging to [2,9] the routing will not work as intented

Additional Information

Use the attached lss file to reproduce the problem

TagsNo tags attached.
Attached Files
Bug heat6
Complete LimeSurvey version number (& build)2.65.1+170522
I will donate to the project if issue is resolvedNo
Browserchrome, firefox
Database type & versionmyysql 5.7, postresql 9.6
Server OS (if known)Ubuntu Linux 16.04
Webserver software & version (if known)Apache 2.4.7
PHP Version5.5.9 and 7

Relationships

duplicate of 12452 closedc_schmitz Conditional routing doesn't work, all vars are treated as string during comparison 

Users monitoring this issue

There are no users monitoring this issue.

Activities

DenisChenu

DenisChenu

2017-06-06 16:36

developer   ~43826

Exactly same issue than https://bugs.limesurvey.org/view.php?id=12452

sickpig

sickpig

2017-06-07 10:32

reporter   ~43843

Sorry to say that but this is not the case. I have updated the instance to the latest release build 170606 and the problem is still there.

sickpig

sickpig

2017-06-07 11:11

reporter   ~43845

you need to use the same fix applied to fix 12452 also for the scale question
something like this should do the trick

diff --git a/scripts/expressions/em_javascript.js b/scripts/expressions/em_javascript.js
index 25ad200..f4b2474 100644
--- a/scripts/expressions/em_javascript.js
+++ b/scripts/expressions/em_javascript.js
@@ -786,7 +786,7 @@ function LEMval(alias)
// If it's not a decimal number, just return value
try {
var decimal_safe = new Decimal(value);

  • return pad(decimal_safe,value.length);
  • return parseFloat(decimal_safe.valueOf());
    }
    catch (ex) {
    return value;
c_schmitz

c_schmitz

2017-06-07 11:17

administrator   ~43849

parseFloat will also allow invalid numbers to become numbers. Just number() is better, I think.

DenisChenu

DenisChenu

2017-06-07 11:47

developer   ~43851

@c_schmitz: OK to test and fix it ?

sickpig

sickpig

2017-06-07 11:57

reporter   ~43853

@c_schmitz number() is ok for me

sickpig

sickpig

2017-07-19 12:07

reporter   ~44109

@c_schmitz bug is still there as of today (Version 2.67.2+170719).

the patch above fix the problem (using number).

Do you want me to submit a PR to the GH repo?

c_schmitz

c_schmitz

2017-07-19 14:00

administrator   ~44111

Sure, please do.

sickpig

sickpig

2017-07-19 14:23

reporter   ~44112

ok great, will do it today

sickpig

sickpig

2017-07-19 17:43

reporter   ~44118

done.

see https://github.com/LimeSurvey/LimeSurvey/pull/783

Issue History

Date Modified Username Field Change
2017-06-05 18:03 sickpig New Issue
2017-06-05 18:03 sickpig File Added: limesurvey_survey_123919.lss
2017-06-06 15:28 DenisChenu Relationship added related to 12452
2017-06-06 16:35 DenisChenu Relationship replaced duplicate of 12452
2017-06-06 16:36 DenisChenu Assigned To => DenisChenu
2017-06-06 16:36 DenisChenu Status new => closed
2017-06-06 16:36 DenisChenu Resolution open => duplicate
2017-06-06 16:36 DenisChenu Note Added: 43826
2017-06-07 10:32 sickpig Status closed => feedback
2017-06-07 10:32 sickpig Resolution duplicate => reopened
2017-06-07 10:32 sickpig Note Added: 43843
2017-06-07 11:11 sickpig Note Added: 43845
2017-06-07 11:11 sickpig Status feedback => assigned
2017-06-07 11:17 c_schmitz Note Added: 43849
2017-06-07 11:47 DenisChenu Assigned To DenisChenu => c_schmitz
2017-06-07 11:47 DenisChenu Note Added: 43851
2017-06-07 11:57 sickpig Note Added: 43853
2017-07-19 12:07 sickpig Note Added: 44109
2017-07-19 14:00 c_schmitz Note Added: 44111
2017-07-19 14:23 sickpig Note Added: 44112
2017-07-19 17:43 sickpig Note Added: 44118
2018-02-15 12:03 c_schmitz Status assigned => closed
2018-02-15 12:03 c_schmitz Fixed in Version => 3.0.x