View Issue Details

This issue affects 1 person(s).
 6
IDProjectCategoryView StatusLast Update
14817Bug reportsExpression Managerpublic2026-10-23 21:17
ReporterDenisChenu Assigned Toc_schmitz  
PrioritynoneSeverityminor 
Status confirmedResolutionopen 
Product Version3.17.x 
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.
Attached Files
Bug heat6
Complete LimeSurvey version number (& build)3.17.2 github
I will donate to the project if issue is resolvedNo
Browserff
Database type & versionnot relevant
Server OS (if known)not relevant
Webserver software & version (if known)not relevant
PHP Versionnot relevant
Git branch / Pull Request URL

Users monitoring this issue

There are no users monitoring this issue.

Activities

DenisChenu

DenisChenu

2019-04-26 09:09

developer   ~51582

Updated : usage of .question seems the issue

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

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

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

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.

ollehar

ollehar

2021-05-12 15:48

reporter   ~64383

Last edited: 2021-05-12 15:52

Why would you do count() on QCODE.question? It's a text field, no? Not an array.

DenisChenu

DenisChenu

2021-05-12 15:52

developer   ~64387

See https://bugs.limesurvey.org/view.php?id=14817#c51773

count(QCODE.question) must return 1, always.

See https://bugs.limesurvey.org/view.php?id=14817#c51782 too
{list(that.QCODE.question)} == {list(QCODE_SQ01.question, QCODE_SQ02.question)} = Text of subquetsion 1,Text of subquestion 2

ollehar

ollehar

2021-05-12 15:53

reporter   ~64388

count(QCODE.question) must return 1, always.

Or invalidate the expression: "count() requires an array, found string"

DenisChenu

DenisChenu

2021-05-12 15:53

developer   ~64389

With {if(count(self.NAOK) == count(self.question) ,"OK","")} : the attended behaviour are if all answer are filled : get OK, else get "".

ollehar

ollehar

2021-05-12 15:55

reporter   ~64390

But that's the same as count(self.NAOK) == 1?

DenisChenu

DenisChenu

2021-05-12 15:55

developer   ~64391

Or invalidate the expression: "count() requires an array, found string"

Not the case today, and clearly : User wait 1 … Like {count(QCODE.NAOK)} return 0 o 1.

Manual :

count the number of answered (non-blank) questions in the list

DenisChenu

DenisChenu

2021-05-12 15:57

developer   ~64392

But that's the same as count(self.NAOK) == 1?

No : count(self.NAOK) return 0 if answer is empty …

It' in the lss and in the screenshot … https://bugs.limesurvey.org/file_download.php?file_id=11562&type=bug

DenisChenu

DenisChenu

2021-05-12 15:58

developer   ~64393

But that's the same as count(self.NAOK) == 1?

Yes, BUT ; with count(self.NAOK) == count(self.question) : you can use it in all quetsoion. Just copy/paster don't care of number of answers.

ollehar

ollehar

2021-05-12 15:59

reporter   ~64394

So QCODE.question is an array IF there are subquestions??

DenisChenu

DenisChenu

2021-05-12 16:03

developer   ~64395

No : that.QCODE.question

QCODE.question didn't exist if it's an array (except with the plugin).

DenisChenu

DenisChenu

2021-05-12 16:04

developer   ~64396

https://manual.limesurvey.org/Expression_Manager#The_reserved_.27this.27.2C_.27self.27.2C_and_.27that.27_variables

c_schmitz

c_schmitz

2026-10-23 21:16

administrator   ~86741

Checked on current master with limesurvey_survey_countQuestionBrokenJS.lss:

  • The comparison from the title, if(count(that.Q00.question) == count(that.Q00.NAOK), ...), works now. .question is handled as a fixed value in JavaScript since 4.0.
  • (count(that.Q00.question) - count(that.Q00.NAOK)) is still broken: it keeps its initial value and does not update on the page.

The cause is not the subtraction itself but its position in the text. When the JavaScript for an expression that uses a fixed attribute (.question, .qid, .sgqa, ...) is built, the current group/question position of Expression Manager gets reset. Every expression after it in the same text is then treated as static and is not updated anymore. If the line before it is removed, the subtraction updates correctly.

This only happens in group-by-group and question-by-question surveys.

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
2019-04-26 09:07 DenisChenu Additional Information Updated
2019-04-26 09:07 DenisChenu Severity partial_block => 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
2019-05-03 18:57 DenisChenu Note Edited: 51777
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
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
2021-05-12 15:48 ollehar Note Added: 64383
2021-05-12 15:52 DenisChenu Note Added: 64387
2021-05-12 15:52 ollehar Note Edited: 64383
2021-05-12 15:53 ollehar Note Added: 64388
2021-05-12 15:53 DenisChenu Note Added: 64389
2021-05-12 15:55 ollehar Note Added: 64390
2021-05-12 15:55 DenisChenu Note Added: 64391
2021-05-12 15:57 DenisChenu Note Added: 64392
2021-05-12 15:58 DenisChenu Note Added: 64393
2021-05-12 15:59 ollehar Note Added: 64394
2021-05-12 16:03 DenisChenu Note Added: 64395
2021-05-12 16:04 DenisChenu Note Added: 64396
2026-10-23 21:16 c_schmitz Note Added: 86741
2026-10-23 21:17 c_schmitz Assigned To => c_schmitz
2026-10-23 21:17 c_schmitz Status new => confirmed