View Issue Details

IDProjectCategoryView StatusLast Update
08324Bug reports[All Projects] Expression Managerpublic2019-10-14 16:38
Reportersammousa Assigned ToDenisChenu  
PriorityhighSeveritymajor 
Status closedResolutionfixed 
Product Version2.05 RC 
Target Version2.05 RCFixed in Version2.05+ 
Summary08324: Broken numeric interpretation of answer codes.
Description

The fix you applied here: https://github.com/LimeSurvey/LimeSurvey/commit/28d42568d7fc2994041b11a5ba70f36d77affc74

breaks numeric interpretation of answer codes.

Steps To Reproduce
  1. Import the survey.
  2. Execute it.

Question q3 has the formula q1+q2 but will show things like 11, 12 instead of 2 and 3, applying concatenation instead of addition.

Additional Information

Simple test survey attached.

TagsNo tags attached.
Complete LimeSurvey version number (& build)3e257de1c0534bb1ba4150810536
I will donate to the project if issue is resolvedNo
BrowserChrome
Database & DB-VersionMySQL5.5
Server OS (if known)Win7
Webserver software & version (if known)PHP
PHP Version5.5

Relationships

parent of 10860 closedDenisChenu Regular expression fail (2.06+) 
related to 14337 closedDenisChenu Broken numeric interpretation of answer codes 
child of 07805 closedDenisChenu Comparaison String and Numeric is different in same page and other page 

Activities

sammousa

sammousa

2013-10-30 21:51

reporter  

limesurvey_survey_673882.lss (61,393 bytes)
DenisChenu

DenisChenu

2013-10-31 10:14

developer   ~27049

Hi,

Yes , but Answer code is code, not numeric , no ?

I think it's a bad solution to force whole to be numeric. It can be reverse, but then suremy some other bug with comparaison.

We can use sum if needed ?

DenisChenu

DenisChenu

2013-10-31 11:40

developer   ~27054

Last edited: 2013-10-31 11:42

View 2 revisions

Whe tryning to impor your lss in mast 205 and last 200:

simplexml_load_file(): ./205/tmp/sm76bcc7x5z38f6dv5ud.lss:432: parser error : Extra content at the end of the document

Due to debug: have to fix

DenisChenu

DenisChenu

2013-10-31 12:16

developer  

limesurvey_survey_numeric-again.lss (15,299 bytes)
DenisChenu

DenisChenu

2013-10-31 12:29

developer   ~27055

Last edited: 2013-10-31 12:33

View 2 revisions

Uploaded a new lss file showing difference with numeric/not numeric : maybe the solution is:

1) Force to be numeric, and if not : set both in string.
2) If one is set to numeric : try the second (205 have some difference actually in PHP/JS)
3) ?

c_schmitz

c_schmitz

2013-10-31 13:36

administrator   ~27056

I think a plus (+) character should be used for numeric only and the operators should be automatically forced to be numeric.

If one of the operators could not be enforced to be
numeric it should be assumed as 1 if is is a non-empty string, otherweise 0 if empty. (I think that's almost the PHP way, isn't it?)

See also: http://php.net/manual/en/language.types.type-juggling.php

DenisChenu

DenisChenu

2013-10-31 14:16

developer   ~27057

Fix committed to 2.05 branch: http://bugs.limesurvey.org/plugin.php?page=Source/view&id=13397

DenisChenu

DenisChenu

2013-10-31 14:28

developer   ~27058

Then need fix in JS only (and see what to to with lt/gt ...)

DenisChenu

DenisChenu

2013-11-03 16:28

developer   ~27071

Hi,

Then solution is:
+/-/.. : convert to num ' "a"=>0, "01"=>1 etc ...

But need lt,gt .. need comparison fix too here.

DenisChenu

DenisChenu

2013-11-04 10:54

developer   ~27076

Last edited: 2013-11-04 10:59

View 3 revisions

OK,

Looking at public function GetJavaScriptEquivalentOfExpression

We get BINARYOP at $token[1] , and can do some update if $token[2]=="+"
In JS : If you add a number and a string, the result will be a string!, in PHP : it's a numeric allways ....

Maybe use "+" in Anything + Anythingelse force Anything to be numeric is the good way.

Need to have clean comparaison :
http://www.php.net/manual/en/types.comparisons.php

Like PHP or not ?

DenisChenu

DenisChenu

2013-11-15 19:05

developer   ~27203

See http://bugs.limesurvey.org/view.php?id=7805

DenisChenu

DenisChenu

2019-06-28 12:27

developer   ~52635

Fix committed to master branch: http://bugs.limesurvey.org/plugin.php?page=Source/view&id=29025

ollehar

ollehar

2019-10-14 16:30

administrator   ~54039

Ban '+' on strings.

ollehar

ollehar

2019-10-14 16:31

administrator   ~54040

Show warning to use "join" instead of "+" or ".".

ollehar

ollehar

2019-10-14 16:31

administrator   ~54041

Mantis link to github is broken ass bullshit fuckery ><

DenisChenu

DenisChenu

2019-10-14 16:31

developer   ~54042

Last edited: 2019-10-14 16:31

View 2 revisions

@ollehar : no … it work … https://bugs.limesurvey.org/view.php?id=14198

But send an warning for '' and '[0-9]' seems the best solution.

ollehar

ollehar

2019-10-14 16:38

administrator   ~54043

BAN BAN BAN!

Related Changesets

LimeSurvey: 2.05 2ff91165

2013-10-31 13:16:13

DenisChenu

Details Diff
Dev: fixed issue 08324: Broken numeric interpretation of answer codes.
Dev: this reopen 07805: because "1" is string in JS
Affected Issues
07805, 08324
mod - application/helpers/expressions/em_core_helper.php Diff File
mod - scripts/expressions/em_javascript.js Diff File

LimeSurvey: master 63765d27

2019-06-11 19:07:30

DenisChenu


Committer: GitHub Details Diff
Fixed issue 14337: Comparaison String and Numeric is different in same page and other page

Dev: Fixed issue 08324: Broken numeric interpretation of answer codes.
Dev: If can be number : return a number in JS
Dev: JS with number+"" do a compare by string : then same for PHP
Dev: adding a Survey test
Affected Issues
08324, 14337
mod - application/helpers/expressions/em_core_helper.php Diff File
mod - assets/scripts/expressions/em_javascript.js Diff File
add - tests/data/surveys/limesurvey_survey_checkCompareTestSurvey.lss Diff File
add - tests/helpers/JsPhpCompareTest.php Diff File

Issue History

Date Modified Username Field Change
2013-10-30 21:51 sammousa New Issue
2013-10-30 21:51 sammousa Status new => assigned
2013-10-30 21:51 sammousa Assigned To => DenisChenu
2013-10-30 21:51 sammousa File Added: limesurvey_survey_673882.lss
2013-10-31 10:11 DenisChenu Relationship added child of 07805
2013-10-31 10:14 DenisChenu Note Added: 27049
2013-10-31 11:40 DenisChenu Note Added: 27054
2013-10-31 11:42 DenisChenu Note Edited: 27054 View Revisions
2013-10-31 12:16 DenisChenu File Added: limesurvey_survey_numeric-again.lss
2013-10-31 12:29 DenisChenu Note Added: 27055
2013-10-31 12:33 DenisChenu Note Edited: 27055 View Revisions
2013-10-31 13:36 c_schmitz Note Added: 27056
2013-10-31 14:16 DenisChenu Changeset attached => LimeSurvey 2.05 2ff91165
2013-10-31 14:16 DenisChenu Note Added: 27057
2013-10-31 14:16 DenisChenu Resolution open => fixed
2013-10-31 14:28 DenisChenu Note Added: 27058
2013-10-31 14:28 DenisChenu Assigned To DenisChenu =>
2013-11-03 16:28 DenisChenu Note Added: 27071
2013-11-04 10:54 DenisChenu Note Added: 27076
2013-11-04 10:57 DenisChenu Note Edited: 27076 View Revisions
2013-11-04 10:59 DenisChenu Note Edited: 27076 View Revisions
2013-11-04 22:24 DenisChenu Assigned To => DenisChenu
2013-11-15 19:05 DenisChenu Note Added: 27203
2013-11-15 19:05 DenisChenu Status assigned => closed
2013-11-15 19:05 DenisChenu Fixed in Version => 2.05+
2016-04-11 14:26 DenisChenu Relationship added parent of 10860
2018-12-11 15:34 DenisChenu Relationship added related to 14337
2019-06-28 12:27 DenisChenu Changeset attached => LimeSurvey master 63765d27
2019-06-28 12:27 DenisChenu Note Added: 52635
2019-10-14 16:30 ollehar Note Added: 54039
2019-10-14 16:31 ollehar Note Added: 54040
2019-10-14 16:31 ollehar Note Added: 54041
2019-10-14 16:31 DenisChenu Note Added: 54042
2019-10-14 16:31 DenisChenu Note Edited: 54042 View Revisions
2019-10-14 16:38 ollehar Note Added: 54043