Welcome to the LimeSurvey Community Forum

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

How to randomly show questions under previous random restrictions?

More
3 years 6 months ago - 3 years 6 months ago #224874 by xueting
Hi all,
In my survey, respondents are supposed to do the following steps: 

Step 1) report max. 4 trips from 6 purposes: W,G,N,L,S,T; and if they indicate they do all WGN activities, then report 3 trips for WGN and 1 trip randomly out of LST; but if they do NOT more than 2 types of WGN, then there will be more than 1 trip out of LST to ensure max. 4 trips and the number of trips is as many as possible. – Thanks to Joffm’s help, this part is well implemented.

Step 2) a question asking if they would choose any listed new modes.

Step 3) a question asking if they would switch their current mode for their different purposes in step 1 to new modes they just chose. As they reported max. 4 trips in step 1, so in step 3 there will be max. 4 questions (picture below shows an example).I was wondering, can there randomly be only 1 question out of those max. 4 questions? What I have done is listing all possible combinations of step 1, and write down their equations. I planned to use IF-Statements for each question in step 3. But I was wondering is there any efficient method?
 The lss.file is attached.
Thank you for any help you can provide! 

File Attachment:

File Name: limesurvey... (1).lss
File Size:80.73 KB

Version: 3.27.35
Regards,
Xueting
Last edit: 3 years 6 months ago by xueting. Reason: pictures not show

Please Log in to join the conversation.

More
3 years 6 months ago - 3 years 6 months ago #224878 by Joffm
Quick idea:
Randomize the question by entering the same randomization group name to all.
As relevance equation you may sum up the relevance status of all "other" questions and say something like "sum<1"
Like
Q1: sum(Q2.relevanceStatus,Q3.relevanceStatus,...)<1
Q2: sum(Q1.relevanceStatus,Q3.relevanceStatus,...)<1
Not really tested, Just try.
Of course added to the existing relevance equation (if(strpos...)

As usual you find "relevanceStatus" in "Access to variables" in the manual.

Joffm

 

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

Please Log in to join the conversation.

More
3 years 6 months ago #224888 by xueting
The method works! Such a smart way!

Thanks a lot and have a nice evening.
Xueting

Please Log in to join the conversation.

More
3 years 6 months ago #224889 by LISHANGQI
The logic and effect of this set of relevance equations are truly surprising and interesting to a coding beginner :)

Please Log in to join the conversation.

More
3 years 6 months ago - 3 years 6 months ago #225259 by xueting
Hi Joffm,
Here comes a new question.

Because the total number of those questions is not big enough (only 8), there is a consequence after randomly showing 1 question here: sometimes not all trips that have been reported would show in this part (step 3). Sometimes 4 trips are all involved, which is good, but sometimes 3 or even 2 trips involved. The ideal case is 2 (8/4=2) questions for each trip if 4 trips reported.

I was wondering is it possible to control the number of questions for each trip that would randomly show to achieve the ideal situation?

Thanks,
Xueting
Last edit: 3 years 6 months ago by xueting.

Please Log in to join the conversation.

More
3 years 6 months ago #225262 by Joffm
Sorry, I have no idea what you are talking about.

If it is related to the "sum(....relevanceStatus,...) " equation, of course you can change the comparison.
Set it to <2, >4, or to a calculation like ==strlen(Q123)

Sorry, without a real survey and a proper explanation, I can't say more.

Joffm


 

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

Please Log in to join the conversation.

More
3 years 6 months ago - 3 years 6 months ago #225285 by xueting
Hi Joffm,

Thank you for your reply.

The lss. file is attached. I'd like to explain by the following example.

Step1) 4 trips from 6 purposes were randomly selected: ABCF stand for: WGNT
 
Step2) s1-s8: questions asking if they would choose any listed new modes.
 
Step3) Switch 1- switch 8: questions asking if they would switch their current mode for their different purposes in step 1 to new modes they just chose.
 

Because "sum(....relevanceStatus,...) " equations were used to let the 1 out of 4 switch questions (for WGNT) randomly show after each "s1-8"questions,
so we got:
Switch1-for T
Switch2-for N
Switch3-for W
Switch4-for N
Switch5-for T
Switch6-for W
Switch7-for N
Switch8-for T

In summary,
for W -  Switch3,6
for G  -  No show
for N  -  Switch2,4,7
for T   -  Switch 1,5,8

Here no switch questions for G, this is what I said "sometimes not all trips that have been reported would show in this part".

The ideal situation is, 2 questions randomly show for each WGNT. Wondering is it possible?

I hope I've made it clear. Thank you for your attention!

 

File Attachment:

File Name: limesurvey... (1).lss
File Size:359.14 KB

Regards,
Xueting
 
Last edit: 3 years 6 months ago by xueting.

Please Log in to join the conversation.

More
3 years 6 months ago #225288 by Joffm
Hi,
you wanted to have a random selection

can there randomly be only 1 question out of those max. 4 questions?

and you got one.
And as the selection is randomly each time there is always the chance that something is never selected.
Calculate the probability. It's about 18%

Now you say

The ideal situation is, 2 questions randomly show for each WGNT. Wondering is it possible?

Two questions randomly?
You know how it works.
At the moment you sum up the relevanceStatus and show questions as long as it is less than 1.
Meaning: At the start the sum is equal 0, after the first question it is equal 1
Now it is really obvious what you have to do to get 2 random questions.

But, do you really avoid that one of the four is never displayed. Remember, it is still a random selection. But this probability is only about 1.5%

In my opinion you should revise this part of the survey.
A rough idea:
There is the string "eqGroupsFinal" like "WGNT".
By the way:
As the order of the characters is not important for the first part of your survey (there is only asked "does the strinfg contain the character?) you may randomize the order.

Now ask the
1st switch about the first character
2nd switch about the second character
3rd switch about the third character
​​​​​​​4th switch about the fourth character
​​5th switch about the fifth character
...
This way there is only one question "Switch" and you taylor the display.
1. Join the string with itself to have a string at least 6 characters long
2. Get the character by the function "substr"
3.a. Display the question text of switch 1 using a nested IF, like
"Would you switch your current mode {if(substr(string,0,1)=="A","W",if(substr(string,0,1)=="B","G",if(substr(string,0,1)=="C","N",if(substr(string,0,1)=="D","L",if(substr(string,0,1)=="E","S","T")))))} to other modes?"
3.b. Display the question text of switch 2 using a nested IF, like
"Would you switch your current mode {if(substr(string,1,1)=="A","W",if(substr(string,1,1)=="B","G",if(substr(string,1,1)=="C","N",if(substr(string,1,1)=="D","L",if(substr(string,1,1)=="E","S","T")))))} to other modes?"
...

This might be another option.

Joffm




 

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

Please Log in to join the conversation.

More
3 years 6 months ago #225308 by xueting
Thank you Joffm very much for your time and effort!

It seems your understanding was every time 2 questions randomly show. But sorry that I didn't make it clear by saying "The ideal situation is, 2 questions randomly show for each WGNT". 

The ideal situation is still everytime only 1 question randomly show but at the same time to ensure that finally every trip purpose would appear 2 times, or at least avoid that any of the four is never displayed.

For instance, if WGNT trips were reported.
Then there would be in total 8 switch questions, and ideally 2 questions go for W, 2 for G, 2 for N, 2 for T, in stead of the former situation: 2 for W, 0 for G, 3 for N and 3 for T. Wondering is it possible?

Also thanks for your idea about using nested IF, the thing is in those switch questions there are not only the question texts itself "would you switch your...?", but also texts of information about details of reported trips using Expression Manager like {tripdistanceW.shown} (this part was omitted in the lss. file). So seems this method would not work in this situation where texts related to previous questions.

Many thanks,
Xueting

 

Please Log in to join the conversation.

More
3 years 6 months ago #225310 by Joffm
I showed you how you can achieve that.

One typo:
I wrote

1. Join the string with itself to have a string at least 6 characters long

Should be 8 characters.
So either you had four trips -> the string is "WGNTWGNT"; each is asked twice
Or only three trips: "WGTWGTWGT"; W and G are asked three times T two times
And so on.
Create a small sample survey and try.

Also thanks for your idea about using nested IF, the thing is in those switch questions there are not only the question texts itself "would you switch your...?", but also texts of information about details of reported trips using Expression Manager like {tripdistanceW.shown} (this part was omitted in the lss. file). So seems this method would not work in this situation where texts related to previous questions.

Of course it does.
If you have to insert an ExpressionScript value into the TRUE-part of an IF-statement, it is like this
{if(condition,"Some text "+eqCalculatedValue+" and some more text",if(...))}

Joffm

 

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

Please Log in to join the conversation.

More
3 years 6 months ago - 3 years 6 months ago #225332 by xueting
Hi Joffm,
Thanks a lot!
I tried but I'm not sure that I fully understand.
What I've done is
1) using lencha to make string have 8 characters.
 

2) Display the question text of switchs using a nested IF, like
"Would you switch your current mode {if(substr(string,0,1)=="A","W",if(substr(string,0,1)=="B","G",if(substr(string,0,1)=="C","N",if(substr(string,0,1)=="D","L",if(substr(string,0,1)=="E","S","T")))))} to other modes?"

3) Set the 8 switch questions in the same randomization group.

Result of one example:
4 trips WGNT, and in the end I got switch questions of NGTNTWGW, 2 for each one, which is good.

The thing is the chosen options in s1-s8 no longer show as options in the switch questions. For instance
in the following situation option 6 and 7 should show in the options of switch1.
 


Then I realized that maybe I should've let the switch question random, but let the string characters random, wondering is there any method?

The lss. file is attached, thanks again for your attention!
 

File Attachment:

File Name: limesurvey...7763.lss
File Size:208.9 KB


Regards,
Xueting
Last edit: 3 years 6 months ago by xueting.

Please Log in to join the conversation.

More
3 years 6 months ago #225345 by xueting
Additionally, a more ideal situation is not let the string characters random, but to pick an order from a list like the following for 4 trips, respondent 1 completes switch questions according to row 1, respondent 2 as in row 2, ...respondent 24 row 24, respondent 25 back to row1, respondent 26 - row2, etc. I was wondering is it possible?
 

Many thanks,
Xueting

Please Log in to join the conversation.

More
3 years 6 months ago - 3 years 6 months ago #225353 by Joffm
I think you misunderstood this

As the order of the characters is not important for the first part of your survey (there is only asked "does the string contain the character?) you may randomize the order.

That was meant that we usually have an order of "WGN(LST)". But you may change to something else "NG(LST)W", or so.

Not to randomize the switches.


And your new idea?
Easy to realize by a question of type "long text" where you enter your scheme as default answer; each line in a row.
Then you may use the SAVEDID to select the row by a function like (substr(Q0,(SAVEDID-1)*10,8) (not really tested)

Are you able to read German? Anyway, there is Google translate.
You may read this
[url] forums.limesurvey.org/forum/german-forum...ragen-gruppen#211405 [/url]

In short: Both methods are at the end not better than a random selection of one of the 24 rows.
Meaning, you can create a random number (1-24) to select your row.

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 3 years 6 months ago by Joffm.

Please Log in to join the conversation.

More
3 years 6 months ago #225370 by xueting
Thanks a lot for offering those methods.

Before trying the new ideas, I was still wondering how to realize the former idea: 2 questions randomly go to each trip if 4 trips reported. Now I deleted the randomization for switch questions, and got the following results for trips WGNL: WGNLWGNL, I was wondering how to randomize the order? The new lss. file is attached. Many thanks.
 

File Attachment:

File Name: limesurvey... (1).lss
File Size:207.92 KB

Regards,
Xueting

Please Log in to join the conversation.

More
3 years 6 months ago #225372 by Joffm

I was wondering how to randomize the order?

You are working with LimeSurvey for a long time now. You should know that it is not possible because you had to order two groups in the same way.

1. I already wrote

That was meant that we usually have an order of "WGN(LST)". But you may change to something else "NG(LST)W", or so.

This is easy done with a random number and a nested "IF" in eqWGNGroups to join in different orders.
Then (LST) is still the last one.
But you may insert this last character at a different place of the string by 
joining a random substring of WGN, the (LST), the rest of WGN.
Like (a rough idea in the evening)
a. eqRandInsert: {if(is_empty(eqRandInsert),rand(0,eqNumWGN),eqRandInsert)}
b. eqGroupsFinal: {join(substr(eqWGNGroups,0,eqRandInsert),eqLSTGroupsFinal,substr(eqWGNGroups,eqRandInsert))}
Just try.
This will give you a random sequence of four (or three). But it is repeated twice.
In my opinion this is sufficient.
 
2. Use a javascript snippet to create a random string.
a. Create two random strings of all 6 characters and join them. (javascript snippet)
b. According to the answers of the participant remove the not mentioned of WGN and the not selected from LST.
Example:
The random string is "GSNLWTSWLGNT"
eqGroupsFinal is "WGNS"
Now remove all characters from the random string that are not in eqGroupsFinal. functions "strpos" and "str_replace".
You get: "GSNWSWGN".

3. Find a different question type for switch instead "list(radio). A type where you can use "subquestion relevance" to avoid the hidden multiple and the equation.
This way you may have s1 and switch1 in one group and can randomize them.
But in my opinion s1 and switch1 shouldn't be on the same screen.
So a display "question by question" might be better.
In an online survey it is always advisable to have only one question on one screen.

Conclusion:
1. sufficient, uses the existing equations.
2. creates a fully randomized string.
3. is the easiest to implement.

So, be creative, use your brains. You may use all implemented functions.
It is your survey.

Joffm

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

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose