- Posts: 227
- Thank you received: 36
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
tailoring array sub-question
- first
- Topic Author
- Offline
- Elite Member
Less
More
10 years 9 months ago #97831
by first
Survey Designer and Programmer
tailoring array sub-question was created by first
There is an array type question to rate 3 cars. BMW,AUDI and Honda(sub-questions). The answers (rating options) are Good,Satisfactory and Poor. I have to show the car name that is rated good in the question text of next question.Is there any method to access the sub-question label.
Survey Designer and Programmer
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13597
- Thank you received: 2487
10 years 9 months ago #97842
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 tailoring array sub-question
Hello:
Qcode.question
The for question with sub-question:
{QCODE_SQcode.question}
Somethink like this maybe:
Qcode.question
The for question with sub-question:
{QCODE_SQcode.question}
Somethink like this maybe:
Code:
{if(QCODE_SQ001=="GOOD",join("You like ",QCODE_SQ001.question),"")}
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 following user(s) said Thank You: first
The topic has been locked.
- torrido23
- Offline
- New Member
Less
More
- Posts: 6
- Thank you received: 0
6 years 1 week ago - 6 years 1 week ago #167214
by torrido23
Replied by torrido23 on topic tailoring array sub-question
Hello,
sorry I know this thread is already quite old, but I wanted to refrain from opening a new thread (yet).
I have almost exactly the same problem, but the abovementioned syntax of DenisChenu does not work.
If I have "QCODE_SQ001.question" in the if expression it does not do anything. However, if I change ".question" to ".shown" it works just fine.
Is this a bug or what am I missing?
Thanks a lot!
sorry I know this thread is already quite old, but I wanted to refrain from opening a new thread (yet).
I have almost exactly the same problem, but the abovementioned syntax of DenisChenu does not work.
If I have "QCODE_SQ001.question" in the if expression it does not do anything. However, if I change ".question" to ".shown" it works just fine.
Is this a bug or what am I missing?
Thanks a lot!
Last edit: 6 years 1 week ago by torrido23.
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12888
- Thank you received: 3965
6 years 1 week ago #167246
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic tailoring array sub-question
Hi,
we don't know what you intend to do.
But with this expression
you get the following
So, the best is you explain your problem a bit more detalled.
Joffm
we don't know what you intend to do.
But with this expression
Code:
{join(if(Q1_SQ001==1,Q1_SQ001.question,""),if(Q1_SQ002==1,Q1_SQ002.question,""),if(Q1_SQ003==1,Q1_SQ003.question,""))}
you get the following
So, the best is you explain your problem a bit more detalled.
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Attachments:
The topic has been locked.
- torrido23
- Offline
- New Member
Less
More
- Posts: 6
- Thank you received: 0
6 years 6 days ago #167263
by torrido23
Replied by torrido23 on topic tailoring array sub-question
Hey,
thank you very much for your answer! I am sorry. I should have been more precise.
I am not exactly trying to "join" certain statements, but my issues is fairly similar (I think).
I am trying to use subquestions from an array-question as "preloads" for a multiple choice question.
Q1 would be something like "How often do you drink these beverages?" and participants shall say if they drink "coke", "sprite", "water", which are the sub-questions, "everyday", "every week", "every month", "never", which are the answer categories.
In a follow up multiple choice question Q2, I want to ask "What do you prefer?" and I want to list the aforementioned beverages in brackets if participants tick "everyday" in Q1. (I obviously have other answer categories in this question)
[ ] Beverages (beverages)
[ ] non-relevant answer category
[ ] non-relevant answer category
My code for Q2 looks like (A1 is the answer code.):
However, this does not work. What works is this, however:
This prints "everyday" if this category is ticked.
Moreover, if I use the expression "Q1_SQ001.question" outside of the if-expression, it prints me the correct subquestion ("coke", "sprite", "water").
I also tried to run your code and it does not work.
I hope this made it clearer. If not, then I will upload a sample survey with my issue.
Thank you very much for your help!
thank you very much for your answer! I am sorry. I should have been more precise.
I am not exactly trying to "join" certain statements, but my issues is fairly similar (I think).
I am trying to use subquestions from an array-question as "preloads" for a multiple choice question.
Q1 would be something like "How often do you drink these beverages?" and participants shall say if they drink "coke", "sprite", "water", which are the sub-questions, "everyday", "every week", "every month", "never", which are the answer categories.
In a follow up multiple choice question Q2, I want to ask "What do you prefer?" and I want to list the aforementioned beverages in brackets if participants tick "everyday" in Q1. (I obviously have other answer categories in this question)
[ ] Beverages (beverages)
[ ] non-relevant answer category
[ ] non-relevant answer category
My code for Q2 looks like (A1 is the answer code.):
Code:
Beverages ( {if(Q1_SQ001 == "A1", Q1_SQ001.question, )} {if(Q1_SQ001 == "A1", Q1_SQ002.question, )} {if(Q1_SQ001 == "A1", Q1_SQ003.question, )} )
However, this does not work. What works is this, however:
Code:
{if(Q1_SQ001 == "A1", Q1_SQ001.shown, )} {if(Q1_SQ001 == "A1", Q1_SQ002.shown, )} {if(Q1_SQ001 == "A1", Q1_SQ003.shown, )}
This prints "everyday" if this category is ticked.
Moreover, if I use the expression "Q1_SQ001.question" outside of the if-expression, it prints me the correct subquestion ("coke", "sprite", "water").
I also tried to run your code and it does not work.
I hope this made it clearer. If not, then I will upload a sample survey with my issue.
Thank you very much for your help!
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12888
- Thank you received: 3965
6 years 6 days ago #167265
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic tailoring array sub-question
Hi,
I still do not know exactly what you are going to do.
Okay: This is Q1:
1. Is this your second question?
Here you only enter in the subquestion text:
2. Or is it this?
Here you just add the subquestion relevance:
And if you are trying to do something quite different, send a sample *.lss
Best regards
Joffm
I still do not know exactly what you are going to do.
Okay: This is Q1:
1. Is this your second question?
Here you only enter in the subquestion text:
Code:
{join(if(Q1_SQ001=="A1",Q1_SQ001.question + " ",""),if(Q1_SQ002=="A1",Q1_SQ002.question+ " ",""),if(Q1_SQ003=="A1",Q1_SQ003.question+ " ",""),if(Q1_SQ004=="A1",Q1_SQ004.question+ " ",""),if(Q1_SQ005=="A1",Q1_SQ005.question+ " ",""),if(Q1_SQ006=="A1",Q1_SQ006.question+ " ",""))}
2. Or is it this?
Here you just add the subquestion relevance:
And if you are trying to do something quite different, send a sample *.lss
Best regards
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
- torrido23
- Offline
- New Member
Less
More
- Posts: 6
- Thank you received: 0
6 years 6 days ago #167266
by torrido23
Replied by torrido23 on topic tailoring array sub-question
Thanks again for your quick reply!
The first part of your answer is what I want to do. It just does not work for me. I copied your code but I don't get the result. The "coke", "water", "tomato juice" are not printed in the mc-question.
I added an example survey with arbitrary example questions. I hope this makes my issues clearer.
Best wishes
The first part of your answer is what I want to do. It just does not work for me. I copied your code but I don't get the result. The "coke", "water", "tomato juice" are not printed in the mc-question.
I added an example survey with arbitrary example questions. I hope this makes my issues clearer.
Best wishes
Attachments:
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12888
- Thank you received: 3965
6 years 6 days ago #167267
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic tailoring array sub-question
Hi,
1. You didn't say that there were two different question types before.
2. You did not enter anything - the "join" command.
Here a working example.
Of course you have to check if there is anything to display in Music resp. Movies (best with the functions "count" rep. "countifop")
See: manual.limesurvey.org/Expression_Manager#Implemented_Functions
Regards
Joffm
1. You didn't say that there were two different question types before.
2. You did not enter anything - the "join" command.
Here a working example.
Of course you have to check if there is anything to display in Music resp. Movies (best with the functions "count" rep. "countifop")
See: manual.limesurvey.org/Expression_Manager#Implemented_Functions
Regards
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Attachments:
The topic has been locked.
- torrido23
- Offline
- New Member
Less
More
- Posts: 6
- Thank you received: 0
6 years 6 days ago - 6 years 6 days ago #167276
by torrido23
Replied by torrido23 on topic tailoring array sub-question
Much appreciated! Your advice really helped! Thanks for your effort.
Last edit: 6 years 6 days ago by torrido23.
The topic has been locked.
- torrido23
- Offline
- New Member
Less
More
- Posts: 6
- Thank you received: 0
6 years 9 hours ago #167558
by torrido23
Replied by torrido23 on topic tailoring array sub-question
Hey,
sorry, I have to ask a follow-up question. The provided solution worked absolutely fine, until I tried to show the whole survey on one page. It seems to be the case that the survey has to be presented either question by question or group by group for processing the condition containing the ".question"-part correctly.
However, the project I am working on does only allow for the "all on one page"-version. Is there a solution for this problem or is there anything I am missing?
Thank you very much and best regards
sorry, I have to ask a follow-up question. The provided solution worked absolutely fine, until I tried to show the whole survey on one page. It seems to be the case that the survey has to be presented either question by question or group by group for processing the condition containing the ".question"-part correctly.
However, the project I am working on does only allow for the "all on one page"-version. Is there a solution for this problem or is there anything I am missing?
Thank you very much and best regards
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12888
- Thank you received: 3965
6 years 8 hours ago #167560
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic tailoring array sub-question
Hi,
at the moment i do not see why it doesn't work.
The multiple works, but the array does not.
I'l have a look.
Nevertheless, you could hardcode the genres.
Instead of Q2_SQ001.question" just enter "Horror"
Joffm
at the moment i do not see why it doesn't work.
The multiple works, but the array does not.
I'l have a look.
Nevertheless, you could hardcode the genres.
Instead of Q2_SQ001.question" just enter "Horror"
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
- torrido23
- Offline
- New Member
Less
More
- Posts: 6
- Thank you received: 0
6 years 8 hours ago #167562
by torrido23
Replied by torrido23 on topic tailoring array sub-question
Wow, that's an incredibly easy solution. That will do. I feel a little embarassed that I have not thought about just hardcoding it .... Thank you very much!
The topic has been locked.