View Issue Details
|ID||Project||Category||View Status||Date Submitted||Last Update|
|15405||Bug reports||Expression Manager||public||2019-10-15 11:32||2021-03-10 17:07|
|Summary||15405: Numerical vs alphabetical order in EM, <, >, vs strcmp etc|
"2" > "18" behaves differently in JS and PHP
The intuition behind "A2" > "A18" is wrong
Default answer code is A1. Press plus, and it become A10, A11, etc. Condition designer uses <, >, etc, but comparing "A2" < "A18" is probably not what user wants (instead "A02" < "A18" OR compare question order).
|Steps To Reproduce||User had survey which broke. Mandatory question was hidden on client (browser) but "shown" on server, leading to mandatory violation BUT without any possibility to actually fill in the question. The origin of the problem was "2" > "18" (age compare).|
|Additional Information||Two commits (that were reverted):|
|Tags||No tags attached.|
|Complete LimeSurvey version number (& build)||latest master|
|I will donate to the project if issue is resolved||No|
|Database & DB-Version||-|
|Server OS (if known)||-|
|Webserver software & version (if known)||-|
"2" > "18" is not really different (bvecause you can 't have it in JS)
With Q00 as single choice with number Q00 as 5 : Q00 < "10" is different in PHP and JS …
Seems i made an error in https://github.com/LimeSurvey/LimeSurvey/blob/93455a7c64c78793375acb4e2eed6963c6cc6334/application/helpers/expressions/em_core_helper.php#L327
Maybe must be STRING for both ?
`'A2' > 'A18' ` : no issue in my point of view (no diff in JS and PHP) … but send a warning is better.
limesurvey_survey_jsphpIssueCompare.lss (18,722 bytes)
@ollehar : in my opinion : must separate the issue
1. PHP vs JS compare must be equal ( Q00 < "18") : 1st issue
2. intuition/ default answer code
PS : since 2.05 : my advice when compare number is always do intval(Q00) before ;)
|But we agree: Warning (or error) when doing "18", e.g. [0-9]* in quote?|
Yes : my opinion :
1. We must fix JS vs PHP (or if not able to fix : send an error) for Q00 < "18"
2. Send a warning about usage of "[0-9]*" and "" (adding "" to force string) and '[0-9]*' and ''
The A2 > A10 is another issue :)
|Related: Lots of people (except Denis) agree answer codes should be numeric as default, not alphanumeric.|
My **real** opinion : empty default answer code (for the 1st)
If have number : seond can be number +1
Same for subquestion code
Same for question code
|@ollehar : can we list the real part wher it's **broken** : i mean compare is different between PHP and JS ?|
|"2" > "18" is different in PHP and JS.|
But : did you have a Survey for this.
I know it's different, but since we have an hacked compare with PHP : maybe we can try to dix it .
I think i do an error :
If both can be number AND and are string : sometimes it‘s OK sometimes not.
For example (in JS)
1. Q00 < "18" => compare as number ( WORD vs FORCED STRING)
2. Q00 + "" < "18" => compare as string ( FORCED STRING vs FORCED STRING)
|Please, don't try to hack EM more - it's already too complex. The best solution is a warning message, IMO.|
Not for this part : since code are already updated since some year now …
The fix can be use && here : https://github.com/LimeSurvey/LimeSurvey/blob/033b995ee5698109120694479a391b3e2ec59ad5/application/helpers/expressions/em_core_helper.php#L328
|Again, I disagree. Writing < "18" is always a conceptual error from the users side.|
Yes, it can be. But the biggest issue : JS must be same than PHP.
Since it's hard ( impossible ?) to fix `2 < '18'` and `'2' < '18'` in JS :
1. PHP must have the same behaviour :)
2. A warning **must** be shown on admin part each time a user have "[0-9 ]*" or '[0-9 ]*' inside equation :)
1. Don't know how to fix
2. Yes, for this BUT also for answer codes BECAUSE "A2" < "A18", so still unintuitive behvaiour. Question is: What is users intention? Anyway, let's discuss next team meeting? With Carsten.
|2019-10-15 11:32||ollehar||New Issue|
|2019-10-15 11:34||ollehar||Steps to Reproduce Updated||View Revisions|
|2019-10-15 11:37||ollehar||Additional Information Updated||View Revisions|
|2019-10-15 11:38||DenisChenu||Note Added: 54044|
|2019-10-15 11:38||DenisChenu||Note Edited: 54044||View Revisions|
|2019-10-15 11:41||ollehar||Description Updated||View Revisions|
|2019-10-15 11:42||DenisChenu||File Added: limesurvey_survey_jsphpIssueCompare.lss|
|2019-10-15 11:43||DenisChenu||Note Added: 54045|
|2019-10-15 14:34||ollehar||Note Added: 54046|
|2019-10-15 14:37||DenisChenu||Note Added: 54047|
|2019-10-15 14:38||ollehar||Note Added: 54048|
|2019-10-15 14:41||DenisChenu||Note Added: 54049|
|2019-10-17 08:01||DenisChenu||Note Added: 54067|
|2019-10-17 10:27||ollehar||Note Added: 54072|
|2019-10-17 11:35||DenisChenu||Note Added: 54078|
|2019-10-17 11:36||DenisChenu||Note Added: 54079|
|2019-10-17 11:38||ollehar||Note Added: 54081|
|2019-10-17 11:41||DenisChenu||Note Added: 54082|
|2019-10-17 11:47||ollehar||Note Added: 54083|
|2019-10-17 12:45||DenisChenu||Note Added: 54087|
|2019-10-17 15:10||ollehar||Note Added: 54088|
|2019-10-31 10:20||DenisChenu||Relationship added||related to 15501|
|2021-03-10 17:07||ollehar||Assigned To||=> ollehar|
|2021-03-10 17:07||ollehar||Status||new => closed|
|2021-03-10 17:07||ollehar||Resolution||open => fixed|
|2021-07-28 17:47||DenisChenu||Bug heat||4 => 6|
|2021-07-28 19:49||guest||Bug heat||6 => 4|