View Issue Details

IDProjectCategoryView StatusLast Update
14817Bug reports[All Projects] Expression Managerpublic2019-05-06 09:50
ReporterDenisChenuAssigned To 
PrioritynoneSeverityminor 
Status newResolutionopen 
Product Version3.17.x 
Target VersionFixed in Version 
Summary14817: count and comparaison broken with .question in JS
Description

Using f(count(self.NAOK) == count(self.question) ,"OK","") in expression is broken …

Steps To Reproduce

Import included survey, check the equation , test

Additional Information

Isseu with .question in JS : seems LEManyNA('483539X527X7030SQ01.question', '483539X527X7030SQ02.question') send false or something like that ?

TagsNo tags attached.
Complete LimeSurvey version number (& build)3.17.2 github
I will donate to the project if issue is resolvedNo
Browserff
Database & DB-Versionnot relevant
Server OS (if known)not relevant
Webserver software & version (if known)not relevant
PHP Versionnot relevant

Activities

DenisChenu

DenisChenu

2019-04-25 19:26

developer  

limesurvey_survey_countCompare.lss (15,413 bytes)
DenisChenu

DenisChenu

2019-04-26 09:09

developer   ~51582

Updated : usage of .question seems the issue



limesurvey_survey_countCompare2.lss (19,130 bytes)
c_schmitz

c_schmitz

2019-05-03 16:33

administrator   ~51762

I am sorry but can you please explain what the error is?

DenisChenu

DenisChenu

2019-05-03 16:37

developer   ~51763

See the screenshot :
count(self.NAOK) == 2
count(self.question) == 2
BUT
if(count(self.NAOK) == count(self.NAOK), 'OK','KO') == 'KO

c_schmitz

c_schmitz

2019-05-03 17:10

administrator   ~51766

I doubt that count(code.question) is a valid expression - and unless the question text is completely empty it should always return 1.

Anyway in the case of that.Q00.question I would expect it to return the question text of the main question.

But in this case it returns the question text of the last subquestion.

DenisChenu

DenisChenu

2019-05-03 17:18

developer   ~51767

No, because i use self : see https://manual.limesurvey.org/Expression_Manager#The_reserved_.27this.27.2C_.27self.27.2C_and_.27that.27_variables
It's a totally valid expression.

It work without issue when use it in PHP, but not comparing, where seems to use JS.

See related forum post : https://www.limesurvey.org/community/forums/development/118215-detect-if-question-is-answered?start=15



DenisChenu

DenisChenu

2019-05-03 17:28

developer   ~51768

In fact : the issue is really this : count(self.question) is OK via static variable, but not via dynamic variables.
See the updated forum post : https://www.limesurvey.org/community/forums/development/118215-detect-if-question-is-answered?start=30#184012

I have the same issue for https://github.com/LimeSurvey/LimeSurvey/pull/1256 and QCODE.help (or idea of function without JS equivalent : getStatOfQuestion ).

c_schmitz

c_schmitz

2019-05-03 17:30

administrator   ~51769

In your example file (v2) you were not using self. You were using that.Q00.question

c_schmitz

c_schmitz

2019-05-03 17:30

administrator   ~51770

Maybe you should start over with a more simple example file.

c_schmitz

c_schmitz

2019-05-03 18:00

administrator   ~51771

code. question always gives back the question text.
I am still not sure what you want to count here.

DenisChenu

DenisChenu

2019-05-03 18:13

developer   ~51773

self and that.Q00 is same inside Q00 question

See lss : OK in next page, broken in same page.



DenisChenu

DenisChenu

2019-05-03 18:16

developer   ~51774

Fixed lss : have error before, but same issue



limesurvey_survey_countQuestionBrokenJS.lss (29,985 bytes)
DenisChenu

DenisChenu

2019-05-03 18:17

developer   ~51775

I am still not sure what you want to count here.

Number of question … there are difference in PHP and in JS : then there are issue …

c_schmitz

c_schmitz

2019-05-03 18:34

administrator   ~51776

If the value of count(code.question) is undetermined because the expression is invalid in itself then it may well be different in JS and PHP.
I can't find anywhere in the documentation that count(code.question) should work or is valid.

DenisChenu

DenisChenu

2019-05-03 18:56

developer   ~51777

Last edited: 2019-05-03 18:57

View 3 revisions

No need documentation : (if Question code are valid)
count(QCODE.question) == count("my question") == 1
count(QCODE_SQ01.question,QCODE_SQ02.question) == count("Sub question 1","Sub question 2") == 2
count(that.QCODE.question) == count(QCODE_SQ01.question,QCODE_SQ02.question) == 2

The issue is 483539X527X7030SQ01.question is NOT set in ExpressionManager javascript var …

Maybe EM need a «this is a fixed var, don't take it from javascript»

c_schmitz

c_schmitz

2019-05-03 19:01

administrator   ~51778

Okay, I can agree on that one. So please close this one and reopen a new issue with

"'qcode.question' and subqestioncode.question text not valid / set wrong on in-page EM expressions"

Thank you!

DenisChenu

DenisChenu

2019-05-03 19:08

developer   ~51779

Last edited: 2019-05-03 19:08

View 2 revisions

The strange issue is : count(QCODE.question) is OK but not when comparing or make evaluation with value in page.

count(that.QCODE.question) == count(QCODE_SQ01.question,QCODE_SQ02.question) == count('Sub question 1','Sub question 2') == 2
is OK.
Not (count(that.QCODE.question) - count(that.QCODE.NAOK))

It's the reason of the exact title …

c_schmitz

c_schmitz

2019-05-03 21:26

administrator   ~51780

If you look at the content of qcode.question then you will see that it is not okay.

DenisChenu

DenisChenu

2019-05-06 09:47

developer   ~51781

Looking at HTML : LEManyNA('483539X527X7030SQ01.question', '483539X527X7030SQ02.question')

It's a minor issue, but still an issue :). And this make big change on EM javascript (allow to have «fixed var», not updated by JS).

DenisChenu

DenisChenu

2019-05-06 09:50

developer   ~51782

If you look at the content of qcode.question then you will see that it is not okay.

I don't understand ?
{list(that.Q00.question)} seems OK.



Issue History

Date Modified Username Field Change
2019-04-25 19:26 DenisChenu New Issue
2019-04-25 19:26 DenisChenu File Added: limesurvey_survey_countCompare.lss
2019-04-25 19:26 DenisChenu File Added: Capture d’écran du 2019-04-25 19-25-53.png
2019-04-25 19:26 DenisChenu File Added: Capture d’écran du 2019-04-25 19-26-06.png
2019-04-25 19:26 DenisChenu File Added: Capture d’écran du 2019-04-25 19-26-24.png
2019-04-25 19:26 DenisChenu Relationship added related to 14198
2019-04-25 19:27 DenisChenu Relationship added related to 14337
2019-04-26 09:07 DenisChenu Summary count and comparaison broken => count and comparaison broken with .question in JS
2019-04-26 09:07 DenisChenu Description Updated View Revisions
2019-04-26 09:07 DenisChenu Additional Information Updated View Revisions
2019-04-26 09:07 DenisChenu Severity major => minor
2019-04-26 09:07 DenisChenu Relationship deleted related to 14198
2019-04-26 09:07 DenisChenu Relationship deleted related to 14337
2019-04-26 09:09 DenisChenu File Added: limesurvey_survey_countCompare2.lss
2019-04-26 09:09 DenisChenu Note Added: 51582
2019-05-03 16:33 c_schmitz Note Added: 51762
2019-05-03 16:37 DenisChenu Note Added: 51763
2019-05-03 17:10 c_schmitz Note Added: 51766
2019-05-03 17:18 DenisChenu File Added: Capture d’écran du 2019-05-03 17-16-21.png
2019-05-03 17:18 DenisChenu Note Added: 51767
2019-05-03 17:28 DenisChenu Note Added: 51768
2019-05-03 17:30 c_schmitz Note Added: 51769
2019-05-03 17:30 c_schmitz Note Added: 51770
2019-05-03 18:00 c_schmitz Note Added: 51771
2019-05-03 18:13 DenisChenu File Added: limesurvey_survey_countQuestionBrokenJS.lss
2019-05-03 18:13 DenisChenu File Added: Capture d’écran du 2019-05-03 18-11-53.png
2019-05-03 18:13 DenisChenu Note Added: 51773
2019-05-03 18:15 DenisChenu File Deleted: limesurvey_survey_countQuestionBrokenJS.lss
2019-05-03 18:16 DenisChenu File Added: limesurvey_survey_countQuestionBrokenJS.lss
2019-05-03 18:16 DenisChenu Note Added: 51774
2019-05-03 18:17 DenisChenu Note Added: 51775
2019-05-03 18:34 c_schmitz Note Added: 51776
2019-05-03 18:56 DenisChenu Note Added: 51777
2019-05-03 18:57 DenisChenu Note Edited: 51777 View Revisions
2019-05-03 18:57 DenisChenu Note Edited: 51777 View Revisions
2019-05-03 19:01 c_schmitz Note Added: 51778
2019-05-03 19:08 DenisChenu Note Added: 51779
2019-05-03 19:08 DenisChenu Note Edited: 51779 View Revisions
2019-05-03 21:26 c_schmitz Note Added: 51780
2019-05-06 09:47 DenisChenu Note Added: 51781
2019-05-06 09:50 DenisChenu File Added: Capture d’écran du 2019-05-06 09-49-20.png
2019-05-06 09:50 DenisChenu Note Added: 51782