Welcome to the LimeSurvey Community Forum

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

Block randomize 20 True/false questions

  • MattiasL
  • MattiasL's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 months 4 weeks ago #252744 by MattiasL
Block randomize 20 True/false questions was created by MattiasL
Please help us help you and fill where relevant:
Your LimeSurvey version:   LimeSurvey Cloud   Version 3.28.76
Own server or LimeSurvey hosting: LimeSurvey hosting
Survey theme/template: fruity
==================
I have 20 questions that I want to show to each responder. Each of the 20 questions have two versions (a "true" version and a "false" version), so in reality I have made a total of 40 questions but, as said, only 20 should be shown to the participant. I want to randomize which version is shown for each question. This would be be easy if it weren't for the fact that I need them to be block randomized so that every participant is shown ten false and ten true questions in total. If I had fewer questions I could create a question group for each scenario, but now there would be two many combination so that solution would not be feasible. 

Perhaps there is a way to sample ten "1" and ten "0" without replacement to determine which version of each question is showned and ensure that there is ten of each?

Thankful for help!

Kind regards,
Mattias

Please Log in to join the conversation.

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 months 4 weeks ago #252750 by holch
Replied by holch on topic Block randomize 20 True/false questions
If the questions need to be completely randomized (so even between true and false versions), things might get a little complicated. But if you are OK with defining beforehand where the true and where the false questions are (you can choose the positions just as you like though).

So I would put 20 questions each in it's own group first, mixing 10 true and 10 false, where the false and where the true questions you must define, e.g. t-t-f-t-f-f-t-t-t.... Be aware in this solution the order of true and false will always be the same for every participant though! But with 20 positions I don't think that they will figure out the pattern.

Then I would put one group with 10 false and one group with 10 true. These two groups will later be hidden and are basically our "pools" for choosing the questions randomly.

Now you give every single "true" question the same randomization group name, e.g. "true" and every single "false" question gets also the same randomization group name (but different ot the one for true of course), let's say false.

What will happen? You have 10 positions for "true" questions that you will show, but 20 questions that are in the randomization group. So Limesurvey will randomize the position of the 20 question options over the 20 positions available. 10 will be shown, 10 will be in the hidden group.

And thinking about it, if you give all the 10+10 questions groups that we will show the same randomization group name, then you can even randomize the position of the 20 questions that should be shown. 10 of which will be true, 10 will be false.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The following user(s) said Thank You: MattiasL

Please Log in to join the conversation.

  • MattiasL
  • MattiasL's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 months 4 weeks ago #252753 by MattiasL
Replied by MattiasL on topic Block randomize 20 True/false questions
I'm sorry, I realize that my question was incorrectly stated. The order of the questions themselves should not be randomized. Question 1 should be first then Question 2 second and so on up to Question 20 which should be last. Only the version of each question (true or false version) should be randomized. I need this to be different for each participant so I can't randomize which questions are true or false beforehand. And in total there should be 10 false versions and 10 true versions for every participant. If I randomize the false and true version of each question (put them in the same randomization group), there may be more false versions than true versions for some participants and sometimes more true than false for others, and that will unfortunately not work for me.

Thank you very much for taking time to answer to my question!

Mattias

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 months 4 weeks ago #252755 by Joffm
Replied by Joffm on topic Block randomize 20 True/false questions
Hi,
while @holch answered, I was looking for the old thread that handled exactly this your question.

So to ease our life, please send the lss export of these relevant questions.

Joffm

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

Please Log in to join the conversation.

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 months 4 weeks ago #252756 by holch
Replied by holch on topic Block randomize 20 True/false questions
Well, then forget about my solution, because it won't help you with your problem.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The following user(s) said Thank You: MattiasL

Please Log in to join the conversation.

  • MattiasL
  • MattiasL's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 months 4 weeks ago #252757 by MattiasL
Replied by MattiasL on topic Block randomize 20 True/false questions
I'm sorry that my question was unclear/incorrectly stated. Thank you very much for your effort to help me out!

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 months 4 weeks ago #252759 by Joffm
Replied by Joffm on topic Block randomize 20 True/false questions
Hi,
the rough javascript idea is
In a qestion of type "short text" you insert a script (eqCalc)
1. you create two arrays
arrayT:  with ten times "T"
arrayF: with ten times "F"

2. Join the arrays to arrayG
3. Shuffle this array 

Now you get something like "TFFTTTFTFFTFTTFTTFFF"
And you can set the relevance equation ot the
first TRUE question "substr(eqCalc,0,1)=="T"
first FALSE question "substr(eqCalc,0,1)=="F"
second TRUE question "substr(eqCalc,1,1)=="T"

As said before: Send the lss export.

Joffm

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

Please Log in to join the conversation.

  • MattiasL
  • MattiasL's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 months 4 weeks ago #252764 by MattiasL
Replied by MattiasL on topic Block randomize 20 True/false questions
Hi Joffm,

That sounds like something I had in mind!

I created a new survey with only the question group that contains the relevant questions. Questions that starts with TFE are true versions of a question and if they start with TFF they are false versions. 

Thanks,
Mattias L
Attachments:

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 months 4 weeks ago - 4 months 4 weeks ago #252779 by Joffm
Replied by Joffm on topic Block randomize 20 True/false questions
Here the lss.
I only entered the relevance equation into the first ten pairs.
But you know and see how it works.

 

File Attachment:

File Name: limesurvey...1541.lss
File Size:104 KB


Best regards
Joffm

The script can be simplified to
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 arrays
    var arrG = ["T","T","T","T","T","T","T","T","T","T","F","F","F","F","F","F","F","F","F","F"];
    arrG = shuffle(arrG).join('');;
 
    $('#question{QID} input[type="text"]').val(arrG);
});
</script>
 

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 4 months 4 weeks ago by Joffm. Reason: new script added
The following user(s) said Thank You: MattiasL

Please Log in to join the conversation.

  • MattiasL
  • MattiasL's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 months 3 weeks ago #252851 by MattiasL
Replied by MattiasL on topic Block randomize 20 True/false questions
Thank you very much, Joffm!

Unfortunately, I can't get it to work. All questions are still shown.

A guess is that I can't use Javascript with my admin's current settings. When I go into a question and click on "Script" I get the following message: "This optional script field will be wrapped, so that the script is correctly executed after the question is displayed. You do not have sufficient permissions to update the script." Can that be it?

Also, the Limesurvey version was updated to Limesurvey 6 before I tried the script. Maybe that is causing an issue?

Best,
Mattias

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 months 3 weeks ago #252853 by Joffm
Replied by Joffm on topic Block randomize 20 True/false questions
I usually do not use the script tab.
I entered the script in the question text.
Did you import my sample?
Did you check the source code of the question text?

Best, you send the lss export.

Joffm 
 

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

Please Log in to join the conversation.

  • MattiasL
  • MattiasL's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 months 3 weeks ago - 4 months 3 weeks ago #252854 by MattiasL
Replied by MattiasL on topic Block randomize 20 True/false questions
Here's the lss file after uploading it to Limesurvey and then downloading it again.

Now I realize that the first 10 questions rather don't show at all. Probably because the condition to show them is not met.
Last edit: 4 months 3 weeks ago by MattiasL. Reason: Clarification.

Please Log in to join the conversation.

Lime-years ahead

Online-surveys for every purse and purpose