Welcome to the LimeSurvey Community Forum

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

Search Results (Searched for: random)

11 Feb 2026 20:42
Replied by osrjunior on topic How to do randomization?
After "termômetro" (that gives me who is and who isn't polarized), the groups ending in 1 has the 2 control questions, and the groups ending in 2 has the treatment questions. As I do not know how to randomize the questions (even by even), thats where I am now 
11 Feb 2026 19:20 - 11 Feb 2026 19:21
Replied by Joffm on topic How to do randomization?
HI,

What is this self

[url] www.limesurvey.org/manual/ExpressionScri...%22that%22_variables [/url]

You should really send the lss export of your survey.
This way we see your approach and can help better.

Because: (abs(lula_valor_nota - bolso_valor_nota) >=8 AND (lula_valor_nota > bolso_valor_nota)
is really complicated and not necessary.
Why the abs-function? If "lula_valor_nota - bolso_valor_nota) >=8" it is obvious that lula was greater then bolso.

Joffm
10 Feb 2026 19:41
Replied by osrjunior on topic How to do randomization?
It's my firtst time at lime.

What I figure out is: (abs(lula_valor_nota - bolso_valor_nota) >= 8) AND (lula_valor_nota > bolso_valor_nota)

give me the condition group to left polarized group.

I have two questions of control and two of treatment in this group (and the others too, but I can just replicate once you show me one).

Here is where comes the {if(is_empty(self),rand(1,2),self)} in a equation question, for that I know.

What is this self and how do I link the to questions of control with 1 and two of treatment with 2?
05 Feb 2026 13:46
05 Feb 2026 10:59
Replied by Joffm on topic How to do randomization?
Hi, you only have to create a random number (1 to 2).
We usually use this construct 
{if(is_empty(self),rand(1,2),self)}
to make sure that this random number is not changed.
Now, if the number is equal 1, display the control group, otherwise the treatment group.
The other part of the condition is your calculation of the difference.

But this is shown and explained many, many times here in the forum.

Joffm
04 Feb 2026 21:24
Please help us help you and fill where relevant:
Your LimeSurvey version: LimeSurvey Community Edition   Version 6.15.22+251103
Own server or LimeSurvey hosting: green-cobra-426206.hostingersite.com/lim...php?r=dashboard/view
Survey theme/template: Fruity
==================
In short, how do I perform a 50% / 50% randomization?

I have six groups: right-polarized (control and treatment), non-polarized (control and treatment), and left-polarized (control and treatment). I use a feeling thermometer based on a formula of 0-to-10 scales measuring how much the respondent sympathizes with former president Bolsonaro and president Lula.If the score given to Lula is higher than Bolsonaro’s, and the difference is greater than or equal to 8, the respondent is assigned to the left-polarized group (and here I need randomization so that 50% go to control and 50% to treatment).If the score given to Bolsonaro is higher than Lula’s, and the difference is greater than or equal to 8, the respondent is assigned to the right-polarized group (here I also need 50/50 randomization between control and treatment).If the respondent does not fit either of the two previous cases, they are assigned to the non-polarized group (again with 50/50 randomization between control and treatment). 
 
27 Jan 2026 11:26
Just because I stumbled over this, some additional context – it is now January 2026, some five months after this conversation. LS7 has just been released as a beta version, and the end of life (EOL) of LS6 will be in less than four months, on 3 April 2026: [url] www.limesurvey.org/manual/LimeSurvey_roadmap [/url].
22 Jan 2026 19:02
Hi, I do not see any issue.
LimeSurvey response table
 
csv-Export opened in Excel
 
csv-Export opened in Wordpad
 

So everything is there, but you should use the correct settings (you seem to use the full question text instead of the codes)

BTW:
There is a small glitch in your table. The two buttons are not aligned equally.
 
In the third cell there is no "vertical-align:middle"

And in my opinion you shouldn't use the survey description (this ugly centered text) , but the welcome message (nicely left aligned).
Remember: The survey description is something like a subtitle (one line).

And avoid to copy/paste such texts, only in plain text mode. You always get some garbage of the other format.

Avoid to use dropdowns with only a few answer options. Dropdowns are really annoying for the respondent. He has to click once to open it, have a look which options are offered and click again to select it.
Better list(radio) or bootstrap buttons.
 
In the "country" question a dropdown is useful, either as a normal dropdown, or an "autocomplete" question (see Tutorial 2. )

Last: QInfo was used to show at least one question in this group. This because QSelect is hidden by javascript. This would usually result in a question with buttons where the question text and the answer options are hidden; but still there are the two buttons.
But you have this Info text "Instructions". This is a real question on the screen. Move it to GCalc and remove the "QInfo".

Joffm
 
22 Jan 2026 17:01
Hello,

I'd really appreciate it if I could get some help about my last question on response statistics and their CSV exports. Because afterwards we plan to go live with the survey. 

Many thanks again!
20 Jan 2026 19:00
 
Thanks for the responses and suggestions. I'll keep them in mind.

I understand that there's already name restriction embedded in the design. I also added German as a second language using the first method you mentioned.

For now, I activated the survey (the original version without weighted randomization) for some pretesting. You previously shared a picture showing how I'd be seeing the response statistics. However, I do not see any of the 10 conjoint choices when I export the results as a CSV file (except for the one that I shared as a screenshot under the name "Response stats sample"). What might have gone wrong? I also attached the current LSS file.

Thanks.
 
20 Jan 2026 16:59 - 20 Jan 2026 17:02
To your "weighted randomisation".
Two solutions:
1. The one I mentioned already (50% 60:40,  50% 80:20)
This script
Code:
$(document).on('ready pjax:scriptcomplete',function(){ // Split the array (a1: German names, a2: Turkish names)     var a1 = ["A","B","C","D","E","F","G","H","I","J"];     var a2 = ["K","L","M","N","O","P","Q","R","S","T"]; // Shuffle both arrays     a1 = shuffle(a1);     a2 = shuffle(a2); // Create a random number that returns 6 or 8     number=6+2*Math.floor(Math.random() * 2); // Create the empty final array      var aFin = ; // In a loop from 0 to the calculated number (6 or 8)      for (var i = 0; i < number; i++) { // Create a new temporary array         var aTmp = ; // where you push the German "name" and the Turkish "name" at position i // You get "number" pairs of different ethnicity         aTmp.push(a1[i]);         aTmp.push(a2[i]); // Shuffle this array that the order of "German" - "Turkish" is always different         aTmp = shuffle(aTmp).join(''); // Push this array of two names into the final array         aFin.push(aTmp);      } // Now you care about the rest // In a loop from "number" to 10 with a step of 2      for (var i = number; i < 10; i+=2) { // Create a new temporary array         var aTmp = ; // where you push the German "name" at position i and the "name" at position i+1         aTmp.push(a1[i]);         aTmp.push(a1[i+1]);         aTmp = shuffle(aTmp).join('');         aFin.push(aTmp);         var aTmp = ; // here you push the Turkish "name" at position i and the "name" at position i+1         aTmp.push(a2[i]);         aTmp.push(a2[i+1]);         aTmp = shuffle(aTmp).join('');         aFin.push(aTmp);      } // Now the array aFin looks like [ BM, IR, SG, OA, CQ, KF, DE, JH, LN, PO ] // Six pairs of different ethnicity, followed by two German pairs and two Turkish pairs // This array again is shuffled      aFin = shuffle(aFin).join(''); // and finally you get the desired string like JHCQIRDEPOKFSGLNBMOALN      $('#question{QID} input[type="text"]:eq(0)').val(aFin); //$('#question{QID}').hide(); });


The other more sophisticated way is to create a function that returns all possible distributions, but with an average of 70:30
I could imagine to create a random number from 1 to 100
If it is
1 - 2 : the distribution is 0 : 10 -> only equal ethnicities
3 - 7 : 2 : 8
8 - 17 : 4 : 6
18 - 47 : 6 : 4
48 - 77 : 8 : 2
78 - 100 : 10 : 0 -> only different ethnicities

You only need to adapt the creating of "number" (of course you are free to weight change the intervals, to get more 60:40, less 20:80, or whatever)

Code:
    var number=1+Math.floor(Math.random() * 100);     if (number<3) { number=0; }     else if (number<8) { number=2; }     else if (number<18) { number=4; }     else if (number<48) { number=6; }     else if (number<78) { number=8; }     else  { number=10; }




 
19 Jan 2026 17:37
Hi,

Q1: Name Restriction

You see that all 20 names are randomised and used one by one. So no name will appear twice.
I hope you studied the script to understand what is done.

Q2: Weighted Randomization by Ethnicity

1. 70:30 is not possibly. That's mathematics. To get 70% mixed pairs you need 7 names. Now there are 3 names left. One pair and a single one.
So we generalise: Sometimes 80:20, sometimes 60:40

2. What thoughts are going through your mind about this? How can this be approached?
Currently, the 20 names are generated completely in random order.
How can 6 pairs be generated, each consisting of one name from A-J and one from K-T?
How can 4 pairs be generated, 2 consisting of both names from A-J and 2 consisting of both names from K-T?  

Q3: Multilingual Survey (English + German)

You have to distinguish two cases.
  1. You create the survey in one language at the start and enter all texts.
    Then you add a second language.
    All texts are copied to the second language tab.
    E.g. in the German tab there will be the English subquestion texts, answer options, etc. which you have to translate.
    But scripts, etc. alwayys stay the same
  2. You create the survey in two language at the start.
    You enter the text in one language.
    Now you have to copy all question texts with the scripts, etc. to the second language tab and translate subquestion text resp. answer options.
19 Jan 2026 12:39 - 19 Jan 2026 12:40
Thanks Joffm, you're a magician! 🪄 Now it finally works!

I had a few further questions:

Q1: Name Restriction
  • As I said in the first post, I'd like to implement a name restriction so the respondents would not get shocked when they see the same name with different field of study, grade, semester, etc. Is it feasible to implement name restrictions in the current randomization approach—EITHER ensuring no profile with the same name appears more than once per respondent, OR ensuring that if a name repeats, the attribute levels are identical? Which option would be more feasible?

Q2: Weighted Randomization by Ethnicity
  • Would it be possible to apply weighted randomization? For example, let's say we want approximately 70% of profile pairs are mixed ethnicity (German vs. Turkish names) and 30% show same-ethnicity pairs (German vs. German names OR Turkish vs. Turkish names)? If so, what's the most practical approach?

Q3: Multilingual Survey (English + German)
  • If I add German language to my survey alongside English (so that it's easier to reach native German respondents), would the JavaScript and ExpressionScript logic (Pool, QSelect, eqSet equations, etc.) work identically in both languages, or would code changes be required?

Thanks again.
18 Jan 2026 16:46 - 18 Jan 2026 17:11
Hi,
your mistake was not to enter the values as "default answer" in "Pool".
I admit I did not mention this explicitly.

And in the script of "QSelect" there were missing brackets
  // Fill the array, numbers from 1 to 144
  var arr1 = ;

Must be
  var arr1 = ;

I saw that they were missing in my script. Sometimes the HTML editor has its own ideas. Therefore its better to use the source code editor, which you select in your account (upper right corner).


Here I attach two sample surveys.

1. Using the library "PapaParse"
[url] www.papaparse.com/ [/url]
You need a csv file like this (here called "profiles.csv") uploaded to the "files" directory of the survey.

ProfileID,Field,Grade,Extracurricular,Semester
1,Mechanical Engineering,2.7 (Satisfactory) (Very Good),Student Parliament,3rd semester (Bachelor)
2,Mechanical Engineering,2.7 (Satisfactory) (Very Good),Student Parliament,5th semester (Bachelor)
3,Mechanical Engineering,2.7 (Satisfactory) (Very Good),Student Parliament,3rd semester (Master)
4,Mechanical Engineering,2.7 (Satisfactory) (Very Good),Sports Club,3rd semester (Bachelor)
...
98,Psychology,2.7 (Satisfactory),Student Parliament,5th semester (Bachelor)
99,Psychology,2.7 (Satisfactory),Student Parliament,3rd semester (Master)
100,Psychology,2.7 (Satisfactory),Sports Club,3rd semester (Bachelor)
...
142,Business Administration,2.7 (Satisfactory),Food Bank Volunteer,3rd semester (Bachelor)
143,Business Administration,2.7 (Satisfactory),Food Bank Volunteer,5th semester (Bachelor)
144,Business Administration,2.7 (Satisfactory),Food Bank Volunteer,3rd semester (Master)

All 144 combinations
As there are only twenty names we will use an array for them.

Now the only thing you have to do is to adapt the indices.
QSelect_1 is a string of characters representing the names
This is the first character, starting at position 0 (substr starts at 0) with a length of 1
    var y1='{substr(QSelect_1,0,1)}';
This is the second character, starting at position 1 with a length of 1
    var y2='{substr(QSelect_1,1,1)}';

The next tests will use the indices 2 and 3, then 4 and 5, and so on

QSelect_2 is a string of three digit numbers representing the profiles
This are the first three characters, starting at position 0 (substr starts at 0) with a length of 3
    var x1 = '{substr(QSelect_2,0,3)}';
This are the second three characters, starting at position 3 (substr starts at 0) with a length of 3
    var x2 = '{substr(QSelect_2,3,3)}';
The next tests will use the indices 6 and 9, then 12 and 15, and so on

This survey shows two ways to create the table.
  • With the library "tinyslider"
  • A "normal" HTML table.

Feel free to adapt the colors (all in the css part at the end of the source code resp. in the tinyslider tables as bootstrap declarations)
 

File Attachment:

File Name: limesurvey...Papa.lss
File Size:98.44 KB


2. The approach with ExpressionScript that I described already.
Again with different ways to create the table. (tinyslider, bootstrap table, generic)
Again you have to adapt the indices in eqSetx.
Have a look at the default answers of "Pool".
 

File Attachment:

File Name: limesurvey...8_ES.lss
File Size:225.39 KB


Joffm

BTW: Only such questions like "QSelect" that contain javascript are hidden either by "d-none" or as you see in the code by $('#question{QID}').hide();
All other questions hide by "Always hide this question"
18 Jan 2026 08:10 - 18 Jan 2026 08:15
Hi, 

Thanks for the detailed guide.

I followed your roadmap but the profile attributes aren't populating in my table—only the structure shows (see the attached table display). What might be the issue causing this? I also attached my Lss file. 

Thanks again.
Displaying 166 - 180 out of 234 results.

Lime-years ahead

Online-surveys for every purse and purpose