Welcome to the LimeSurvey Community Forum

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

Search Results (Searched for: random)

07 Jan 2026 14:05
Please help us help you and fill where relevant:
LimeSurvey version: [6.15.19]
Own server or LimeSurvey Cloud: Cloud
Survey theme/template: Inherit [fruity_twentythree]
==================
Hello Limesurvey community,

I'm a first-time Limesurvey user. 

I'd like only certain participants from a previous question (yes/no type) to be randomized in these 3 groups. That is, if they answer no to the previous question, they are randomized into one of the next 3 questions, otherwise if yes, they proceed to other questions. How do I go about it? I have already created a hidden equation question coded RANDGROUP with the equation rand(1,3), but I haven't figured out how to ensure only the no responders are randomized. I tried adding a condition in the next 3 questions that are to be randomized ( e.g., if previous question == N), but seemingly something gets overwritten in the process. I see either all or none of the three questions when I preview the survey.

Additionally, two of the 3 questions participants are to be randomized are also yes/no type, while the other in an array type. For the 2 yes/no questions, I cannot find the relevance equation tab where I can input the command to show the specific question to desired assigned group. For the array question, do I have to key in the relevance equation for every subquestion?

(Side question: How evenly are participants randomized? I'd like a 1:1:1 ratio)

Looking forward to your tricks and tweaks.

Thanks in advance.
07 Jan 2026 11:29
Thanks for confirming that it is not currently working ... I have updated and tested this now to include working with Multiple Free Text and Multiple Numeric questions and tested it with the Filter exclusion as well and it all seems to work as expected. For any one interested here is the code you need to add to your custom js file
Code:
window.LSAnswerOrder = (function () {   "use strict";   function isVisible(el) {     if (!el) return false;     return !!(el.offsetWidth || el.offsetHeight || el.getClientRects().length);   }   function getVisibleQuestion() {     var list = document.querySelectorAll("div.question-container");     for (var i = 0; i < list.length; i++) {       if (isVisible(list[i])) return list[i];     }     return document.querySelector('div[id^="question"]');   }   function getQidFromQuestionDiv(q) {     var m = (q && q.id) ? q.id.match(/^question(\d+)$/) : null;     return m ? m[1] : "";   }   function dedupeKeepOrder(arr) {     var seen = Object.create(null);     var out = [];     for (var i = 0; i < arr.length; i++) {       var v = arr[i];       if (v && !seen[v]) { seen[v] = true; out.push(v); }     }     return out;   }   function codeFromInput(inp, qid) {     if (!inp) return "";     // For list radio: inp.value often is the code     var v = inp.value;     if (v && v !== "Y" && v !== "N") return v;     // For multi numeric / multi text etc., parse from name after X<qid>     var name = inp.getAttribute("name") || "";     if (!qid || !name) return "";     var marker = "X" + qid;                 // e.g. X25802     var idx = name.lastIndexOf(marker);     if (idx === -1) return "";     var after = name.substring(idx + marker.length); // e.g. "1" or "SQ001" or "SQ001_1"     var us = after.indexOf("_");     if (us > -1) after = after.substring(0, us);     return after;   }   function capture() {     var q = getVisibleQuestion();     if (!q) return;     var qid = getQidFromQuestionDiv(q);     var codes = [];     // Dropdown: store option order     var sel = q.querySelector("select");     if (sel) {       var opts = sel.querySelectorAll("option");       for (var i = 0; i < opts.length; i++) {         var val = opts[i].getAttribute("value");         if (val) codes.push(val);       }       codes = dedupeKeepOrder(codes);       sessionStorage.setItem("answerorder", codes.join(","));       console.log("Stored answerorder:", codes.join(","));       return;     }     // Tables/arrays: store row order     var tbodyRows = q.querySelectorAll("table tbody tr");     if (tbodyRows.length) {       for (var r = 0; r < tbodyRows.length; r++) {         var ctrl = tbodyRows[r].querySelector("input,select,textarea");         var code = codeFromInput(ctrl, qid);         if (code) codes.push(code);       }       codes = dedupeKeepOrder(codes);       sessionStorage.setItem("answerorder", codes.join(","));       console.log("Stored answerorder:", codes.join(","));       return;     }     // UL-based answers (this now covers: list radio/checkbox + multiple numeric + multiple short text/open text)     var ul = q.querySelector("ul.ls-answers");     if (ul) {       var lis = ul.querySelectorAll(":scope > li");       for (var l = 0; l < lis.length; l++) {         var ctrl2 = lis[l].querySelector("input,select,textarea");         var code2 = codeFromInput(ctrl2, qid);         if (code2) codes.push(code2);       }       codes = dedupeKeepOrder(codes);       sessionStorage.setItem("answerorder", codes.join(","));       console.log("Stored answerorder:", codes.join(","));     }   }   function apply() {     var orderStr = sessionStorage.getItem("answerorder") || "";     if (!orderStr) return;     var desired = orderStr.split(",");     var q = getVisibleQuestion();     if (!q) return;     var qid = getQidFromQuestionDiv(q);     // Dropdown reorder     var sel = q.querySelector("select");     if (sel) {       var map = {};       var opts = Array.prototype.slice.call(sel.querySelectorAll("option"));       for (var i = 0; i < opts.length; i++) map[opts[i].value] = opts[i];       var empty = map[""] || null;       sel.innerHTML = "";       if (empty) sel.appendChild(empty);       for (var d = 0; d < desired.length; d++) {         if (map[desired[d]]) sel.appendChild(map[desired[d]]);       }       console.log("Applied order to dropdown");       return;     }     // Table row reorder (arrays)     var tbody = q.querySelector("table tbody");     if (tbody && tbody.querySelectorAll("tr").length) {       var rowByCode = {};       var rows = Array.prototype.slice.call(tbody.querySelectorAll("tr"));       for (var r = 0; r < rows.length; r++) {         var ctrl = rows[r].querySelector("input,select,textarea");         var code = codeFromInput(ctrl, qid);         if (code) rowByCode[code] = rows[r];       }       for (var d2 = 0; d2 < desired.length; d2++) {         if (rowByCode[desired[d2]]) tbody.appendChild(rowByCode[desired[d2]]);       }       console.log("Applied order to table rows");       return;     }     // UL reorder (lists + multi numeric + multi text/open text)     var ul = q.querySelector("ul.ls-answers");     if (ul) {       var lis = ul.querySelectorAll(":scope > li");       var liByCode = {};       for (var l = 0; l < lis.length; l++) {         var ctrl2 = lis[l].querySelector("input,select,textarea");         var c = codeFromInput(ctrl2, qid);         if (c) liByCode[c] = lis[l];       }       for (var d3 = 0; d3 < desired.length; d3++) {         if (liByCode[desired[d3]]) ul.appendChild(liByCode[desired[d3]]);       }       console.log("Applied order to ul answers");     }   }   return { capture: capture, apply: apply }; })();

and then to appy it you need to add : LSAnswerOrder.capture(); in the script box of the first randomised question this will capture and store the order and then in any questions that follow with the same code / answers you add in LSAnswerOrder.apply(); to the script box

Tested on List questions / multiple questions / arrays / array with numbers / multiple free text and multiple numeric questions.

 
07 Jan 2026 08:50

I should have added that this is happening in the "Preview Survey" mode - that might have an impact. I checked the source and it's loading the cached css and it's not the browser cache.
 
What is the link for css and js ? Include assets/[randomnumber] ? Can you send a screenshot ?

Pëase : be more clear in your explanation!
07 Jan 2026 01:12 - 07 Jan 2026 01:40
Please help us help you and fill where relevant:
Your LimeSurvey version: 6.16.3
Own server or LimeSurvey hosting: LimeSurvey hosting
Survey theme/template: Fruity
==================

Hello,

I require some assistance - I have a randomised multiple numerical input question type where I would like a unique suffix to display next to each input box which changes based on the number typed in (different text displayed whether the number is over, under, or exactly matches a specified amount).

I have managed to create this in a way whereby the required descriptions are displayed in a separate text display question (rather than as a suffix), however this is not ideal as the descriptions are not in-line with each input row (see screenshots and .lss file attached).

Please note that with the desired result I would like it to work with the randomisation, keeping the appropriate descriptions in the correct row even when rows are randomised.

A workaround similar to this may work, but this one does not preserve the randomisation and I'm not sure how to incorporate the {expressions} without breaking the javascript: forums.limesurvey.org/index.php/forum/in...ut-questions?start=0


Any assistance would be greatly appreciated.

Here is what it currently looks like:



Here is what I would like it to look like:




File Attachment:

File Name: budgeting_..._WIP.lss
File Size:45.35 KB


 
06 Jan 2026 16:37 - 06 Jan 2026 16:38
Obviously this doesn't work for single questions, only multiple, arrays, etc.
single - single
 
single - multiple
 
multiple - multiple numerical
 

But there are these "old" scripts from tpartner 
1. After the "source" question create a question of type "short text"
Put this into the "source" question"
Code:
<script type="text/javascript" charset="utf-8" data-author="Tony Partner">     $(document).on('ready pjax:scriptcomplete',function(){                  //Identify the questions         var thisQuestion = $('#question{QID}');         var hiddenQuestion = $(thisQuestion).nextAll('.text-short:eq(0)');                  // Create an array of answer codes         var answerCodes = ;         $('li.answer-item', thisQuestion).each(function(i) {             answerCodes.push($(this).attr('id').split('X{QID}')[1]);         });                  // Load the hidden question         $('input:text', hiddenQuestion).val(answerCodes);             }); </script>


2. Depending on the type of the target question:
a. single, multiple
Code:
<script type="text/javascript" charset="utf-8" data-author="Tony Partner">   $(document).on('ready pjax:scriptcomplete',function(){       //Identify this question     var thisQuestion = $('#question{QID}');     var thisAnswerList = $('li.answer-item:eq(0)', thisQuestion).parent();       // Retrieve the answer codes from the "randomOrder" question     var answerCodes = '{RandOrder}'.split(',');       // Loop through the answer codes     $.each(answerCodes, function(i, val) {       // Move the answer item       $(thisAnswerList).append($('li.answer-item[id$="X{QID}'+val+'"]', thisQuestion));     });   }); </script>

b. array
Code:
<script type="text/javascript" data-author="Tony Partner">   $(document).on('ready pjax:scriptcomplete',function(){       //Identify this question     var thisQuestion = $('#question{QID}');     var thisAnswerList = $('tr.answers-list:eq(0)', thisQuestion).parent();     // Retrieve the answer codes from the "randomOrder" question     var answerCodes = '{RandOrder}'.split(',');       // Loop through the answer codes     $.each(answerCodes, function(i, val) {       // Move the answer item       $(thisAnswerList).append($('tr.answers-list[id$="X{QID}'+val+'"]', thisQuestion));     });     }); </script>


c. array(text)
Code:
<script type="text/javascript" data-author="Tony Partner">   $(document).on('ready pjax:scriptcomplete',function(){       //Identify this question     var thisQuestion = $('#question{QID}');     var thisAnswerList = $('tr.subquestion-list:eq(0)', thisQuestion).parent();     // Retrieve the answer codes from the "RandOrder" question     var answerCodes = '{RandOrder}'.split(',');       // Loop through the answer codes     $.each(answerCodes, function(i, val) {       // Move the answer item       $(thisAnswerList).append($('tr.subquestion-list[id$="X{QID}'+val+'"]', thisQuestion));     });    }); </script>


 
06 Jan 2026 14:35
Hi Dave!

Strange. Then there must have been a change again lately without any notice, because as you could see from the forum posts that I showed, a lot of people had a problem with the answer options always being in the same order.

I totally understand why you want to have the same random order for the same items throughout the survey and as I said, this is (or better was?!?) standard.

Need to check in on this, because all this back and forth is confusing. We helpers in the forum don't test all those things all the time and often rely on our past experience and or what we know from others here in the forum. If these things change frequently, it makes it harder to help.

But thank you for testing and alerting me about this. I don't have time today to do thorough testing, but I will certainly have a look into this. Might have to "relearn" the new-old behavior then.
06 Jan 2026 07:35 - 06 Jan 2026 07:47
Hi Holch

I have just tried to use a survey with a list question and a multiple choice question with the same lists and codes, randomised the answers and made it live.

Codes were all 1-5, The answer order originally was 
Dog 
Cat
Mouse
Parrot 
Rabbit

As you can see from the attached screenshots the answers were randomised .... but not in the same order ... this is the condition the script I wrote allows the same order to be carried through different questions.

The general use case for this is when we show a list of Shops randomly and ask Which if any of these have you heard of? ... and then we display a subset of those aware with and Which did you last shop at? The request is to show the original list of shops in a random order to lessen bias and then keep the list on the second question in the same order as the first (although some have been removed) so the respondent experience remains consistent.

We are running LimeSurvey Community Edition Version 6.16.3+251215  if this is the difference in what you explained and what the current implementation does.

Happy New Year
Dave
 
05 Jan 2026 20:45
Let's say you have 3 answer options in Q1, in Q2 and in Q3

1. Dog
2. Cat
3. Bird

Now the default behavior of Limesurvey is to use the seed for randomization.

So if it has been randomized in Q1 to

2. Cat
3. Bird
1. Dog

the order should be the same in Q2 and Q3 as well, always:

2. Cat
3. Bird
1. Dog

Of course, this is only true for the same session. The next respondent should get a new shuffle, but then the order should stay the same throughout the questionnaire.

And this should be the case for any question. The first answer item should be always on the same position for all questions with randomized answer options.
05 Jan 2026 20:42
Here for example a post on the topic. This is for LS5, but should be still the same in LS6.

forums.limesurvey.org/forum/design-issue...tion-of-subquestions

forums.limesurvey.org/forum/design-issue...me-for-all-questions

Here also a "bug report" about the topic.

bugs.limesurvey.org/view.php?id=18440

Did you do your tests in the preview only, or also with an activated survey? Because this seems to be applied only after the activation of the survey.
05 Jan 2026 20:35

What I have been asked to do is keep this first order across multiple follow up questions


Exactly, and this is what the standard behavior should be. We have quite a few complaints of people who can't figure out on how to get each question independently randomized.

What version of LS are you running?
05 Jan 2026 19:42
I have not seen this in live surveys Holch

If I have a list of answers in one question that is randomised so for example it comes out as 2,5,3,1,4 in order of the responses in that question and then I have the same answers on the next question and that is randomised then the order of answers change on the 2nd question.

What I have been asked to do is keep this first order across multiple follow up questions
05 Jan 2026 16:53

Just thought I would share this with everyone. We quite often get asked if we can keep the order of answers from question to question when the first list of answers has been randomised.


But that is the default behavior. The random order is based on the seed, so any following question with the same answer options / subquestions that is also randomized comes in the same order, by default.

Or did I understand the requirements wrong?

Because we often have the discussion in the forum with people who would like to have a new randomization for following questions and there you need a work around.

But in your case (if I understand it right), Limesurvey does this already out of the box.
05 Jan 2026 12:59
Please help us help you and fill where relevant:
Your LimeSurvey version: 6.x
Own server or LimeSurvey hosting: Self Hosted
Survey theme/template: Customised 
==================
Just thought I would share this with everyone. We quite often get asked if we can keep the order of answers from question to question when the first list of answers has been randomised.

This is how we do that.

In the custom.js file of the template add in the following
Code:
// Question Order Reuse (LS6 question-by-question compatible) window.LSAnswerOrder = (function () {   function isVisible(el) {     if (!el) return false;     return !!(el.offsetWidth || el.offsetHeight || el.getClientRects().length);   }   function getVisibleQuestion() {     // Prefer the visible question container     var list = document.querySelectorAll('div.question-container');     for (var i = 0; i < list.length; i++) {       if (isVisible(list[i])) return list[i];     }     // Fallback     return document.querySelector('div[id^="question"]');   }   function getQidFromQuestionDiv(q) {     // q.id like "question20855"     var m = (q && q.id) ? q.id.match(/^question(\d+)$/) : null;     return m ? m[1] : '';   }   function dedupeKeepOrder(arr) {     var seen = Object.create(null);     var out = [];     for (var i = 0; i < arr.length; i++) {       var v = arr[i];       if (v && !seen[v]) { seen[v] = true; out.push(v); }     }     return out;   }   function codeFromInput(inp, qid) {     if (!inp) return '';     // For list radio / list checkbox: value is the answer code (e.g., "1","2"...)     var v = inp.value;     if (v && v !== 'Y' && v !== 'N') return v;     // For multiple choice and many arrays: value is "Y" (or not helpful),     // so get code from the name after X<qid>     var name = inp.getAttribute('name') || '';     if (!qid || !name) return '';     var marker = 'X' + qid;     var idx = name.lastIndexOf(marker);     if (idx === -1) return '';     var after = name.substring(idx + marker.length); // e.g. "1" or "SQ001" or "SQ001_1"     // If arrays encode extra suffix after underscore, keep just the row code     // (safe for MC too: "1" has no underscore)     var us = after.indexOf('_');     if (us > -1) after = after.substring(0, us);     return after;   }   function capture() {     var q = getVisibleQuestion();     if (!q) return;     var qid = getQidFromQuestionDiv(q);     var codes = [];     // Dropdown     var sel = q.querySelector('select');     if (sel) {       var opts = sel.querySelectorAll('option');       for (var i = 0; i < opts.length; i++) {         var val = opts[i].getAttribute('value');         if (val) codes.push(val);       }     }     // Array rows: capture row order by reading first control name in each row     else if (q.querySelectorAll('table tbody tr').length) {       var rows = q.querySelectorAll('table tbody tr');       for (var r = 0; r < rows.length; r++) {         var ctrl = rows[r].querySelector('input,select,textarea');         var code = codeFromInput(ctrl, qid);         if (code) codes.push(code);       }     }     // Lists / multiple choice: capture the displayed LI order from the answers list     else {       var answerLis = q.querySelectorAll('ul.ls-answers > li');       for (var l = 0; l < answerLis.length; l++) {         var inp = answerLis[l].querySelector('input[type="radio"], input[type="checkbox"]');         var code2 = codeFromInput(inp, qid);         if (code2) codes.push(code2);       }     }     codes = dedupeKeepOrder(codes);     sessionStorage.setItem('answerorder', codes.join(','));     console.log('Stored answerorder:', codes.join(','));   }   function apply() {     var orderStr = sessionStorage.getItem('answerorder') || '';     if (!orderStr) return;     var desired = orderStr.split(',');     var q = getVisibleQuestion();     if (!q) return;     var qid = getQidFromQuestionDiv(q);     // Dropdown: reorder options     var sel = q.querySelector('select');     if (sel) {       var map = {};       var opts = Array.prototype.slice.call(sel.querySelectorAll('option'));       for (var i = 0; i < opts.length; i++) map[opts[i].value] = opts[i];       var empty = map[''] || null;       sel.innerHTML = '';       if (empty) sel.appendChild(empty);       for (var d = 0; d < desired.length; d++) {         if (map[desired[d]]) sel.appendChild(map[desired[d]]);       }       console.log('Applied order to dropdown');       return;     }     // Array: reorder table rows     var tbody = q.querySelector('table tbody');     if (tbody && tbody.querySelectorAll('tr').length) {       var rowByCode = {};       var rows = Array.prototype.slice.call(tbody.querySelectorAll('tr'));       for (var r = 0; r < rows.length; r++) {         var ctrl = rows[r].querySelector('input,select,textarea');         var code = codeFromInput(ctrl, qid);         if (code) rowByCode[code] = rows[r];       }       for (var d2 = 0; d2 < desired.length; d2++) {         if (rowByCode[desired[d2]]) tbody.appendChild(rowByCode[desired[d2]]);       }       console.log('Applied order to array rows');       return;     }     // List / Multiple choice: reorder answer LIs (this fixes your Q2)     var ul = q.querySelector('ul.ls-answers');     if (ul) {       var lis = ul.querySelectorAll(':scope > li');       var liByCode = {};       for (var l = 0; l < lis.length; l++) {         var inp = lis[l].querySelector('input[type="radio"], input[type="checkbox"]');         var c = codeFromInput(inp, qid);         if (c) liByCode[c] = lis[l];       }       for (var d3 = 0; d3 < desired.length; d3++) {         if (liByCode[desired[d3]]) ul.appendChild(liByCode[desired[d3]]);       }       console.log('Applied order to list/multiple-choice');     }   }   return { capture: capture, apply: apply }; })();

Then in the first question (the one that is the driver for the order) which has to be randomised add this into the script box
Code:
LSAnswerOrder.capture();

And then in following (non randomised) questions we add in this
Code:
LSAnswerOrder.apply();

This keep the answer lists consistent and works with local storage to do so ....

Hope this helps others

Dave
 
18 Dec 2025 10:37
Replied by heinz23 on topic Relevanzgleichung
Hallo joffm,

vielen Dank für deine Antwort!

Stimmt, das habe ich falsch geschrieben. Es geht ums anzeigen nicht ausblenden.

Die Fragegruppe soll angezeigt werden für

(is_empty(sd2.NAOK) OR sd2.NAOK != 121)

und wenn sd2 != 60 und (gleichzeitig) sd1 !=6. In allen anderen Fällen bezogen auf die 2. Bedingung (z.B. sd2 = 60 UND sd1 = 1; sd2 = 50 UND sd1 = 6) soll die Fragegruppe angezeigt werden.

Hier der entsprechende Code:
Code:
[color=#cccccc]]]></grelevance>[/color][color=#cccccc]   </row>[/color][color=#cccccc]   <row>[/color][color=#cccccc]    <gid><![CDATA[463]]></gid>[/color][color=#cccccc]    <sid><![CDATA[212449]]></sid>[/color][color=#cccccc]    <group_name><![CDATA[Past life events]]></group_name>[/color][color=#cccccc]    <group_order><![CDATA[13]]></group_order>[/color][color=#cccccc]    <description><![CDATA[Please identify x]]></description>[/color][color=#cccccc]    <language><![CDATA[en]]></language>[/color][color=#cccccc]    <randomization_group/>[/color][color=#cccccc]    <grelevance><![CDATA[([/color][color=#cccccc]  is_empty(sd2.NAOK)[/color][color=#cccccc]  OR sd2.NAOK != 121[/color]

Vielen lieben Dank für die nette Hilfe!
 
01 Dec 2025 11:15

Respondents are asked to choose between one of the two profiles. The table is based on radomized variables. Because there is only a total of 18 profile options, there is a rather high likelihood that respondents will see two identical profiles. This is a situation, we want to avoid, because it does not make much sense to ask people about which option they prefer if the provided options are identical.
What does profiles and profiles options mean? What kind of conjoint is that?
Usually you have an amount of attributes and each attribute has an certain amount levels.
You than create offers from these attributes and decide how many offers you offer for choice in one task.
Depending on the amount of attributes and amount of levels a certain amount of exposures to the probands have to be made.
An experimental plan has to be made (or is created by the conjoint software used).
With that experimental plan you could precreate all tasks as separate questions and that predefne a few flows through the survey via hiding certains tasks.
That way you don't need to randomize the attribute levels and have less exposure to errors. The need to make a lot of tasks and ensure that you don't need to change things later.

LimeSurvey is advertising a choice based conjoint feature on their website but I haven't seen any beta how these features are implemented.


 
Displaying 211 - 225 out of 234 results.

Lime-years ahead

Online-surveys for every purse and purpose