Welcome to the LimeSurvey Community Forum

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

Latin square design in LimeSurvey with different randomizations by participant

  • Ben2021
  • Ben2021's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 1 month ago - 3 years 1 month ago #223206 by Ben2021
Please help us help you and fill where relevant:
Your LimeSurvey version: Version 5.0.13
Own server or LimeSurvey hosting:
Theme:

==================

I am trying to implement a study on LimeSurvey with the following properties: 
(i) there is a total of 14 pairs of questions <a1, a2>, <b1, b2>, <c1,c2>, etc.
(ii) each participant must answer only one of the two questions for each pair (e.g. a participant answers a1, b2, c1)
(iii) each participant must answer the same number of x1 questions and x2 questions, where x holds for a, b, c, etc. So each participant answers 7 questions of x1 type and 7 questions of the x2 type.
(iv) questions must be displayed in random order for each participant
This is a type of Latin Square design except that I don't have a small number of groups of questions. Instead each participant potentially sees a different set of questions from the other participants.
I think I managed to do a questionnaire with properties (i), (ii), and (iv). But I don't know how to ensure that each participant sees the same number of x1 and x2 questions. What I have so far is this: for each pair of questions, I have a specific group, and I ask LimeSurvey only to display one of the two questions in this group (cf. (ii)). In addition, I managed to get the groups to be displayed in random order, achieving the result in (iv). However I don't know how to do (iii). Is it possible on LimeSurvey?
 
Last edit: 3 years 1 month ago by Ben2021.
The topic has been locked.
More
3 years 1 month ago #223208 by jelo
Depending on your survey design you might use the shown sequence to limit the display of questions.
And you can save the random order to later know in with sequence the questions where shown.

forums.limesurvey.org/forum/can-i-do-thi...ndomization-sequence

And this thread might help you:
forums.limesurvey.org/forum/design-issue...-follow-up-questions

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The following user(s) said Thank You: Ben2021
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 1 month ago #223213 by Joffm
Hi,
I'd do it this way.
1. Create a question of type "short text". You may call it "pool".
2. In the source code insert this javascript snippet
Code:
<script type="text/javascript" charset="utf-8">
 
function shuffle(array) {
  var currentIndex = array.length, temporaryValue, randomIndex;
 
  // While there remain elements to shuffle...
  while (0 !== currentIndex) {
 
    // Pick a remaining element...
    randomIndex = Math.floor(Math.random() * currentIndex);
    currentIndex -= 1;
 
    // And swap it with the current element.
    temporaryValue = array[currentIndex];
    array[currentIndex] = array[randomIndex];
    array[randomIndex] = temporaryValue;
  }
 
  return array;
}
 
 
    $(document).on('ready pjax:scriptcomplete',function(){
// Fill the array with 14 characters
      var arr = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N"];
 
// Shuffle the array
      arr = shuffle(arr);
      arrfinal = arr.slice(0,7).join(',');
      $('#question{QID} input[type="text"]').val("#"+arrfinal);
// Hide the question
 
      $('#question{QID}').hide();
   });
</script>

Means: You create an array with 14 characters, shuffle it and take the first seven characters which you insert into the text of the question
You will get something like 
#C,N,I,E,B,F,H

3. All your 14 questions get the same "randomization group name" to display them in randomized order.
By relevance equation display the questions.
Use the function "strpos" to decide if a character is in the string or not.
[url] www.limesurvey.org/manual/ExpressionScri...mplemented_functions [/url]

The "a" questions if the character is IN the string
The "b" questions if the character is NOT IN the string.

Like
Question 1a:  strpos(pool,"A")>0
Question 1b:  strpos(pool,"A")==0
Question 2a:  strpos(pool,"B")>0
Question 2b:  strpos(pool,"B")==0
...
Question 14a:  strpos(pool,"N")>0

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: Ben2021
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 1 month ago #223214 by Joffm
Here a working example

 

File Attachment:

File Name: limesurvey...2772.lss
File Size:36 KB


Joffm
 

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: Ben2021
The topic has been locked.
  • Ben2021
  • Ben2021's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 3 weeks ago - 3 years 3 weeks ago #223425 by Ben2021
Thanks so much, Joffm! I really appreciate that you took the time to even provide a working example. It will make it much easier to implement.

I just have a follow-up question. I have tried to add some filler questions that will appear randomly in the same randomization group as my 14 questions (they are not selected from pairs of questions but they will all appear for all participants). I am not sure how to adapt your code to do this. I have added my filler questions at the end of the group of questions in the working example. But when I do the survey, all the filler questions appear at the end, as if they were not part of the same randomization group as the other questions. Usually, to randomize questions, I use a constant value for all questions in the field "Randomization group", but in your example I don't see anything in this field, so I guess the randomization groups are decided by another method - probably in the javascript code. Unfortunately, I am not proficient in javascript.
Thank you very much for your help
Last edit: 3 years 3 weeks ago by Ben2021. Reason: add question
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 3 weeks ago #223427 by Joffm
Please show what you did.
lss export of the relevant questions.
Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: Ben2021
The topic has been locked.
  • Ben2021
  • Ben2021's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 3 weeks ago #223431 by Ben2021
I am attaching your working example with two questions that I added in the group G2 (Q15, Q16). The condition is set to 1 because I always want those questions to be displayed. But I would like them to be randomized in the same group as the other questions. Thanks!
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 3 weeks ago #223433 by Joffm
Each of the question has the randomization groupname "randgroup1".
Except Question 1A.
That was a test to check your attention 
Sorry.
 

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: Ben2021
The topic has been locked.
  • Ben2021
  • Ben2021's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 3 weeks ago #223434 by Ben2021
Ok, great! Indeed I just checked for Question 1A and saw nothing there so I assumed it was the same for the other question... But yes I just saw that it is indeed randgroup1 for the other questions.
Thanks again for your all your help, Joffm!
The topic has been locked.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose