Welcome to the LimeSurvey Community Forum

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

1 row at least mandatory - Array text

  • boshra.m
  • boshra.m's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
2 years 3 months ago #232895 by boshra.m
1 row at least mandatory - Array text was created by boshra.m
Please help us help you and fill where relevant:
Your LimeSurvey version: LimeSurvey Cloud Version 5.4.3
Own server or LimeSurvey hosting: LimeSurvey hosting
Survey theme/template: Fruity
==================
Hello,

I have read through the manual and forums and I am not sure how to do the following:
I have an array texts questions where I am trying to make it so that the respondent has to fill out at least one of the rows, it doesn't matter which. I', also trying to make it so that they can enter numbers or texts and still the same would apply.

Would really really appreciate help with this!!

 

Please Log in to join the conversation.

More
2 years 3 months ago #233035 by LISHANGQI
Replied by LISHANGQI on topic 1 row at least mandatory - Array text
You can use the Question validation equation in edit-logic-validation equation. by something like {!is_empty( Qcode_SQ001) or !is_empty(Qcode_SQ002) or...}

Please Log in to join the conversation.

  • boshra.m
  • boshra.m's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
2 years 3 months ago - 2 years 3 months ago #233152 by boshra.m
Replied by boshra.m on topic 1 row at least mandatory - Array text
Hello,

Thank you for your response!It worked for one of my questions but weirdly enough when I did the same thing for another question, it keeps saying that I have an undefined variable. Any ideas why?

Thank you very much.

For reference, this is what I have in the Question validation equation:!is_empty(p51_p51a) or !is_empty(p51_p51b)   

File Attachment:

File Name: limesurvey...4736.lss
File Size:27 KB
Last edit: 2 years 3 months ago by boshra.m.

Please Log in to join the conversation.

More
2 years 3 months ago #233169 by LISHANGQI
Replied by LISHANGQI on topic 1 row at least mandatory - Array text
Hi,

I think it is because this is an array-text question and there are subquestions for both columns and rows. So you should write the code in this way : Qcode_Y_X. So it should be: (! is_empty(p51_p51a_a) and ! is_empty(p51_p51a_b) and ! is_empty(p51_p51a_c) and ! is_empty(p51_p51a_d))or (! is_empty(p51_p51b_a) and ! is_empty(p51_p51b_b) and ! is_empty(p51_p51b_c) and ! is_empty(p51_p51b_d)) to make sure at least one row is fully filled.
The following user(s) said Thank You: boshra.m

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 3 months ago - 2 years 3 months ago #233174 by Joffm
Replied by Joffm on topic 1 row at least mandatory - Array text
@LISHANGQI is absolutely right.
Please, read again the manual about the question codes naming
[url] www.limesurvey.org/manual/ExpressionScri...code_variable_naming [/url]
And if you read about the variables "self" and "that"
[url] www.limesurvey.org/manual/ExpressionScri....22that.22_variables [/url]

you may shorten your validation to
count(self.sq_p51a)==4 or count(self.sq_p51b)==4


  


Joffm

I am always wondering about this doubling of codes.
Why do you code the y-axis again with the question code, so in your dataset you get "p51_p51a_a"
In my opinion better: y-axis "Y01", "Y02",... or "YA", "YB",... and the x-axis "X01", "X02",... 
This is a big advantage when using "self" and "that"
 

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 2 years 3 months ago by Joffm.
The following user(s) said Thank You: LISHANGQI, boshra.m

Please Log in to join the conversation.

More
2 years 3 months ago #233176 by LISHANGQI
Replied by LISHANGQI on topic 1 row at least mandatory - Array text
Wow, it is a much better solution!

Please Log in to join the conversation.

  • boshra.m
  • boshra.m's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
2 years 3 months ago #233207 by boshra.m
Replied by boshra.m on topic 1 row at least mandatory - Array text
Hi Joffm,

Thank you so much you are a lifesaver. Yeah it's just how we need it for our codebook.

I want to use the same principle and apply it where I have an array (radio) question and want rows 1-4 mandatory. Therefore, could I use this same principal and instead of using 'or' I use 'and'. Would I be missing something by just simply doing this? I did test it out and it's not working which is why I believe I am wrong somewhere.

Thank you.

Please Log in to join the conversation.

  • boshra.m
  • boshra.m's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
2 years 3 months ago #233208 by boshra.m
Replied by boshra.m on topic 1 row at least mandatory - Array text
Thank you for your response @lishangqi!

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 3 months ago #233209 by Joffm
Replied by Joffm on topic 1 row at least mandatory - Array text
Hi,
I hope you understood how the "self" and "that" variable work.
And keep in mind that an array(text) or array(numbers) are two-dimensional - subquestions in y-axis and x-axis, answers in cells.
But an array is one-dimensional - subquestions in y-axis, answers in rows (or x-axis)

This means if you code the subquestion in a useful way like
M001
M002
M003
M004
O005
O006
meaning "Mxxx" is a mandatory subquestion, "Oxxx" is a optional subquestion.

Then obviously the count of answered M-subquestions has to be 4 to fulfill your requirement.
count(self.sq_M)==4

Of course you can do it the other way enter all subquestion codes like
count(Q1_SQ001,Q1_SQ002,Q1_SQ003,Q1_SQ004)==4
but  "self" and "that" are really mighty and save a lot of work.

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: boshra.m

Please Log in to join the conversation.

  • boshra.m
  • boshra.m's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
2 years 3 months ago #233267 by boshra.m
Replied by boshra.m on topic 1 row at least mandatory - Array text
Ah okay I see, thank you!

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose