Willkommen, Gast
Benutzername: Passwort: Angemeldet bleiben:
  • Seite:
  • 1
  • 2

THEMA: Random assignment to conditions

Random assignment to conditions 8 Monate 1 Woche her #103895

  • hutzel
  • hutzels Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 1
  • Karma: 0
Hello everyone,

is it possible in Limesurvey to get a random assignment to different conditions (like control /experimental group)? It should be a equal distribution as possible.

Until today i did it with a javascript code like this:
    var min = 0;
    var max = 3;
 
 
     var random = Math.floor(Math.random() * (max - min + 1) + min);
 
    $('#question1234').hide();
    $(document).ready(function() { 
    document.getElementById('answer1234X123X12').value = random;
    });

I produced a random number and put it as an answer for a hidden question, so I can refer to this answer later.

But is there a better way to do this?
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Random assignment to conditions 8 Monate 1 Woche her #103910

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 4206
  • Dank erhalten: 790
  • Karma: 360
You can use Expression Manager to load an equation type question with a random number - manual.limesurvey.org/Expression_Manager...e_Question_Per_Group

.
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Random assignment to conditions 8 Monate 6 Tage her #104088

  • MarcellavZ
  • MarcellavZs Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 13
  • Karma: 0
Hello,

I have a similar question. In my survey I have 4 conditions. Via a hidden question ({rand(1,4)}) and linking each question that belongs to one of the 4 conditions through 'token, previous question, value equals ...' my survey already randomly assigns participant to one of the four conditions but that doesn't happens equally. For example, I want that 40 participants are assigned to condition a, 40 participant to condition b ans so on. The technical department of my university says that it isn't possible via Limesurvey so now I have come to you.. I hope that there is a solution, otherwise I think that the only possibility is to manual assign people to one of the conditions with their email address in advance..JavaScript is really a different language for me so please help me.

Thanks!
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Random assignment to conditions 8 Monate 6 Tage her #104094

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 4206
  • Dank erhalten: 790
  • Karma: 360
Well, you can use the {SUBMITID} variable (which is available AFTER the first page submission) and the JavaScript modulus operator to load a hidden short-text question with sequential numbers between 1 and 4.

Note though, that the sequential number will increment with every respondent, even those who don't complete the survey.

Add this script to the source of a short-text question:
<script type="text/javascript" charset="utf-8">	
 
	$(document).ready(function() { 
 
		var submitID = {SAVEDID};
 
 		// Hide this question
		$('#question'+qID).hide();
 
		// Find sequential number between 1 and 4 based on the SUBMITID
		var conditionNumber = (submitID % 4) + 1;
 
 		// Load the hidden question
		$('#question'+qID+' input.text').val(conditionNumber);
	});
</script>

.
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
Letzte Änderung: 8 Monate 3 Tage her von tpartner.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Random assignment to conditions 8 Monate 6 Tage her #104096

  • MarcellavZ
  • MarcellavZs Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 13
  • Karma: 0
Hi Tony,

Thank you! I will try to implement what you have said in my survey. I'm sure it works, now I only need to make it work with my technical skills... I will try. Thanks!
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Random assignment to conditions 8 Monate 3 Tage her #104137

  • LBOATENG10
  • LBOATENG10s Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 3
  • Karma: 0
Hello,

I also have a similar issue. I am conducting an on-line research with 12 conditions. I would like each condition to have 15 participants. Thus, can someone please provide me step-by-step instructions on how to set that up; I am new to Lime Survey and to the world of coding.

Thank you,

Lois
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Random assignment to conditions 8 Monate 3 Tage her #104155

  • Hendrik
  • Hendriks Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 9
  • Karma: 0
Hi Tony,

Thank you for this answer it looks useful, except...
I tried
{SUBMITID}
which results in "unknown variable".

I also tried all kinds of variations:
{SUBMIT_ID} {SUBMITID} {Submitid} {SubmitId} {SubmitID} {SUBMID} {QID}
All of the SUBMITID variations give the error, while QID shows up valid.

This is in a question in the second group, so it should be available, right?

Do you have any idea what I am doing wrong here?
I am using LS 2.00+ Build 131206

Thanks for any help,
Kind regards,
Hendrik Jan
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Random assignment to conditions 8 Monate 3 Tage her #104159

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 4206
  • Dank erhalten: 790
  • Karma: 360
Oops, sorry, I meant {SAVEDID} :blush:

(Note that it is only available after the first question page is submitted)
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
Der Administrator hat öffentliche Schreibrechte deaktiviert.
Folgende Benutzer bedankten sich: Hendrik

Random assignment to conditions 8 Monate 3 Tage her #104165

  • Hendrik
  • Hendriks Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 9
  • Karma: 0
Thank you; {SAVEDID} works.

For anybody else reading this; {SAVEDID} is only useful on an active survey, on an inactive suvey it only returns an empty string.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Random assignment to conditions 8 Monate 3 Tage her #104173

  • Hendrik
  • Hendriks Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 9
  • Karma: 0
Also be aware that the modulo function (%) doesn't work yet.
You'll have to use
{SAVEDID - (floor(SAVEDID/4)*4) + 1}
.
Letzte Änderung: 8 Monate 3 Tage her von Hendrik. Begründung: typo
Der Administrator hat öffentliche Schreibrechte deaktiviert.
  • Seite:
  • 1
  • 2
Moderatoren: ITEd
Ladezeit der Seite: 0.355 Sekunden
Donation Image