Optimize expression code

More
1 month 1 week ago - 1 month 1 week ago #159485 by holch
holch created the topic: Optimize expression code
I have a survey example with basically 4 questions.

1. Frequency of using services from a department
2. Evaluation of the services of the respective department regarding 4 aspects (departments only shown if not "never" in the first question)
3. Comments for departments that have been rated 6 or below in any of the 4 aspects in question 2
4. Comments for departments that have been rated 7 or higher in any of the 4 aspects in question 2

I have attached an example survey. I think I figured out how to show the subquestions (departments) in question 3 and 4 depending on the evaluation in question 2 (currently only implemented for department 1 in question 3). However, I was wondering if this can be done easier or more elegant?

Currently it looks like this:
ID01_1_1<7 OR ID01_1_2<7 OR ID01_1_3<7 OR ID01_1_4<7

As I probably will have more departments (up to 3) and also more aspects (up to 10) I was wondering if I can somehow streamline this code? Or do I have to go for the "OR" solution for each of these cases?

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds
Attachments:
Last Edit: 1 month 1 week ago by holch.

Please Log in to join the conversation.

More
1 month 1 week ago #159489 by DenisChenu
DenisChenu replied the topic: Optimize expression code
I think you can use countifop ( manual.limesurvey.org/Expression_Manager#Access_to_Functions )
BUT : it's better if you add some string in subquestion.

For example with X/Y
countifop("<",7,self.sq_X)

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in to join the conversation.

More
1 month 1 week ago #159522 by holch
holch replied the topic: Optimize expression code
Hi Denis!
Thank you for the response. I will give this a try.
I just didn't understand what you meant with "it's better if you add some string in subquestion". Could you please clarify?

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds

Please Log in to join the conversation.

More
1 month 1 week ago #159553 by DenisChenu
DenisChenu replied the topic: Optimize expression code
Because : with sq_XXX : you can filter the subquestion you need.

Then , if you add code to column and a different one for line, it's more easy to filter what you want. Example with X for column and Y for line.

Get the list of answer in the first column: list(self.sq_Y1.NAOK)
Get the list of answer in the second line: list(self.sq_X2.NAOK)

I add 0 too , for example :
X01
X02

X10
X11

then : i can use sq_X01 for 1st line. If i don't add the 0 : sq_X1 giv answer on 1st column + answer on 10 and 11 columns.

Denis

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in to join the conversation.

More
1 month 1 week ago #159563 by jelo
jelo replied the topic: Optimize expression code

DenisChenu wrote: If i don't add the 0 : sq_X1 giv answer on 1st column + answer on 10 and 11 columns.

Is that behavior intended? So sq_X1 is always "sqX1*"? Looks like a very nasty trap.

Please Log in to join the conversation.

More
1 month 1 week ago #159570 by DenisChenu
DenisChenu replied the topic: Optimize expression code
intended, and clearly seems better from my POV.

manual.limesurvey.org/Expression_Manager....27that.27_variables

sq_X - where X is a row or column identifier. Only sub-questions matching pattern X are selected. Note that search is done on complete code identifier, then sq_X match and include subquestions nX, X, Xn (e.g. if you use sq_1, subquestions a1, 1a, 1, 11 or 001 was included). Put attention at dual scale question type where subquestions code are QCODE_SQCODE_1 and QCODE_SQCODE_1 and to ranking question type where subquestions code are QCODE_1,QCODE_2 ....


It's a lift filtering : self.NAOK give you whole list of answer in a pseudo-array. self_sq_X.NAOK give you the list of answers containing X in the name/code.

I use it to make quicker condition with subquestion.

For example : Y01,N02,Y03,N04,N05 in MULTI question

count(that.MULTI.sq_Y)>0

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in to join the conversation.

More
1 month 1 week ago #159571 by jelo
jelo replied the topic: Optimize expression code
Thanks for pointing out.

Please Log in to join the conversation.

More
1 month 1 week ago #159573 by DenisChenu
DenisChenu replied the topic: Optimize expression code
Maybe the issue is to put SQ001 by default when there are axis.

Maybe it can be best to
1: Add (by default) SX001 and SY001
2: When using quick add without code : using SX001,SX002 etc … too (currently we set to 1,2,3 …, and it's really not the best)

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!