Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Pulling in array answer to single choice question text?

  • boshra.m
  • boshra.m's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
3 days 14 hours ago #268594 by boshra.m
Please help us help you and fill where relevant:
LimeSurvey version: LimeSurvey Cloud Version 6.10.0
Own server or LimeSurvey Cloud: LimeSurvey Cloud
Survey theme/template: Fruity
==================
Hello,

I previously had a question where in one group there was an Multiple short text question where participants filled out basically blanks. In the next group I had an array question and in the question text, it pulled in (one at a time), what the participant wrote in the group one question multiple short text. I did this by using the  "{questionID}" function.

My question is: I want to do the same thing but the first question in the group 1 be an array question and group 2 question 2 be a single choice question that pulls in the answer response they chose to the question text. 

Is this possible? 

Thanks! 

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 days 13 hours ago #268596 by Joffm
Hi,
please see here
[url] www.limesurvey.org/manual/ExpressionScri...code_variable_naming [/url]

Always consider the question type.
Single: there is only the question
Array, multiple: there is the question with subquestions in one dimension
Array(text), array(numbers: there is the question with subquestions in two dimensions.

If you are not sure, activate a small test survey, enter some data and have a look at the answer table.


BTW:

I did this by using the  "{questionID}"

I suppose you used the "questionCode", not the "questionID"

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in to join the conversation.

  • boshra.m
  • boshra.m's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
2 days 22 hours ago #268605 by boshra.m
Hi there,

I see what you are saying. 

However, I am still having difficulty. The issue I am having is that I tried this: "{if(Q2a_1s_3 == 'Y', Q2a_1s.question, if(Q2a_2s_3 == 'Y', Q2a_2s.question, if(Q2a_3s_3 == 'Y', Q2a_3s.question, if(Q2a_4s_3 == 'Y', Q2a_4s.question, if(Q2a_5s_3 == 'Y', Q2a_5s.question, 'No selection')))))}" but it seems to keep giving me an error.

Basically if they select a subquestion in my array table for column 3 (answer response coded as 3) of which they are only allowed to select one answer (subquestion) for the entire column then I want whatever subquestion they select for that column to pull into my next question text. 

Any idea why this isn't working?

Thanks for all your help!
 

Please Log in to join the conversation.

  • boshra.m
  • boshra.m's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
15 hours 30 minutes ago #268615 by boshra.m
Hi,

Unfortunately I have not been able to figure this out. I have attached my iss file where my attempts are  

File Attachment:

File Name: limesurvey...1-13.lss
File Size:92 KB


Most recently I tried the following code but was not successful:
if(Q3f_SQ001 == 'A3', Q1_SQ001.shown, ''),
if(Q3f_SQ002 == 'A3', Q1_SQ002.shown, ''),
if(Q3f_SQ003 == 'A3', Q1_SQ003.shown, ''),

Any guidance would be greatly appreciated!

Thank you. 
 

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
12 hours 3 minutes ago - 12 hours 2 minutes ago #268621 by Joffm
Hi,
there are some issues in your sample
1.

<p><strong>"</strong>{INSERTANS:647177X313X26143}"</p>

<p> of "PHR14A.shown" </p>

<p> of "Q3fA3.shown" </p>

a. You use this "stone age" INSERTANS. You see here the SGQA code is used,. But this code - as it is just an autoincrement value in the database - changes when you import the lss.
b. PHR14A is missing (minor)
c. Q3fA3 is not a real QCODE. Q3f is an array(numbers); you have to address both dimensions of subquestions. So the QCODE consists of QUESTIONCODE_SUBQUESTIONCODE-Y_SUBQUESTIONCODE-X.
 

2.

{if(Q1_SQ001 == "A3", Q1_SQ001.shown, "")}
{if(Q1_SQ002 == "A3", Q1_SQ002.shown, "")}
{if(Q1_SQ003 == "A3", Q1_SQ003.shown, "")}

In your sample there is no question Q1.

3.

{join(if(Q3f_SQ001 == 'A3', Q3f_SQ001.shown, ''),

Here you handle Q3f as a normal array question. The answer of subquestion SQ001 is 'A3'
But as said before you want to know the answer of the cell Q3f_SQ001_A3.

As I wrote before

If you are not sure, activate a small test survey, enter some data and have a look at the answer table.

You will see this
 
You see the correct QCODE in the header AND you see that in an array(number) selected items are stored as "1"

Furthermore you see here that to display the text of the "Other" options you have to addrress thes3e fields
 

And at last:
What do you want to display?
Obviously not the "1" of the selected cells, but the t4ext of the subquestion.
Please here you see
 
"shown" is the display value of the answer options of a (coded) question.
Example:
Single question {Q1}
1: Adam
2: Bert
3: Charles
So if a respondent selects 2,
{Q1} returns '2'
{Q1.shown} returns 'Bert'

And "question" returns the question text.
In questions without subquestions the question text, in question with subquestions the subquestion text.
And this is the crucial point.
You have to adress the cell - and get back the question text of the cell, like
 
 
The "Others" are fine.

So, what to do?
You may use some stringfunctions to remove the not wanted part of thequestion text.
Just use only the substring from the beginning to the start of '[...]',
Something like
substr(Q3f_SQ001_A2.question,0,strpos(Q3f_SQ001_A2.question,'

On the other side it may be more convenient to hard code the items, like
if(Q3f_SQ001_A2==1,'This is my first item',''),if(Q3f_SQ002_A2==1,'This is the second item','')

Joffm

And please, be more precise

but the first question in the group 1 be an array question

It is not an array, but an array(numbers).
In this case the difference is really important, it's one dimension more.









 

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 12 hours 2 minutes ago by Joffm.

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose