- Posts: 11655
- Thank you received: 2742
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Optimize expression code
- holch
- Topic Author
- Away
- LimeSurvey Community Team
Less
More
6 years 6 months ago - 6 years 6 months ago #159485
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Optimize expression code was created by holch
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:
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?
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:
Code:
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 answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Attachments:
Last edit: 6 years 6 months ago by holch.
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13642
- Thank you received: 2491
6 years 6 months ago #159489
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on 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
BUT : it's better if you add some string in subquestion.
For example with X/Y
Code:
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 , plugin development .
I don't answer to private message.
The topic has been locked.
- holch
- Topic Author
- Away
- LimeSurvey Community Team
Less
More
- Posts: 11655
- Thank you received: 2742
6 years 6 months ago #159522
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on 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?
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 answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13642
- Thank you received: 2491
6 years 6 months ago #159553
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on 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
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 , plugin development .
I don't answer to private message.
The topic has been locked.
- jelo
- Offline
- Platinum Member
Less
More
- Posts: 5033
- Thank you received: 1257
6 years 6 months ago #159563
by jelo
The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
Replied by jelo on topic Optimize expression code
Is that behavior intended? So sq_X1 is always "sqX1*"? Looks like a very nasty trap.DenisChenu wrote: If i don't add the 0 : sq_X1 giv answer on 1st column + answer on 10 and 11 columns.
The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13642
- Thank you received: 2491
6 years 6 months ago #159570
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic Optimize expression code
intended, and clearly seems better from my POV.
manual.limesurvey.org/Expression_Manager....27that.27_variables
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
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 , plugin development .
I don't answer to private message.
The topic has been locked.
- jelo
- Offline
- Platinum Member
Less
More
- Posts: 5033
- Thank you received: 1257
6 years 6 months ago #159571
by jelo
The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
Replied by jelo on topic Optimize expression code
Thanks for pointing out.
The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13642
- Thank you received: 2491
6 years 6 months ago #159573
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on 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)
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 , plugin development .
I don't answer to private message.
The topic has been locked.