Welcome to the LimeSurvey Community Forum

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

Search Results (Searched for: random)

  • Giulio_vifo
  • Giulio_vifo's Avatar
15 Mar 2024 11:43
grazie,

l'articolo che hai condiviso permette di arrivare alla soluzione, basta adattarla al caso specifico. Per l'indagine in corso causa tempi stretti ho proceduto limitando le rotazioni, ma quanto prima farò un tentativo e nel caso condividerò gli esiti nel forum.
  • Giulio_vifo
  • Giulio_vifo's Avatar
15 Mar 2024 11:37
ti ringrazio,
in effetti però non devo far ruotare gruppi di domande ma modalità di risposta multipla entro la stessa domanda.
  • Joffm
  • Joffm's Avatar
14 Mar 2024 13:04 - 14 Mar 2024 13:09
Replied by Joffm on topic Choice Based Max-Diff Design

Also display the Version along with set number

I do not understand that.

G1 always displays set 1
G2 always displays set 2
...
Please study the few equations.

And revise the creation of the random number.
I wrote

2. Create a random number from 1 to your number of versions (question type 'equation') (eqRand)

In my example there were only three sets, therefore "3"

BTW:
If there are really only 30 versions (in your Excel screenshot there seemed to be more)
you also can create 30 Groups (versions), each with six questions (sets).
Create a random number and display the according group by condition .
This way everything is fixed and you do not need to restructure your data.

Joffm
 
  • lfanfoni
  • lfanfoni's Avatar
13 Mar 2024 19:38
Ho l'impressione che in questo caso la funzionalità "gruppi random" non vada bene: quella funziona per randomizzare blocchi di intere domande all'interno dei gruppi, non per randomizzare blocchi di sotto-domande di una domanda multiresponse.
C'è questo articolo sul forum: forums.limesurvey.org/forum/can-i-do-thi...f-random-order-array
Usa javascript per "ancorare" il primo elemento di un array e mettere random tutti gli altri.
Se non ci riesci, ti suggerisco di postare in formato lss una survey con un facsimile della tua domanda con 10 item per cui gli ultimi due vuoi lasciare fissi e i primi 8 random. Può darsi che qualche esperto (penso ovviamente a Joffm) ti possa fornire la soluzione già bella che pronta.
  • ritapas
  • ritapas's Avatar
13 Mar 2024 09:27
Nel manuale c'è proprio un esempio come questo, devi usare la funzionalità "gruppi random"
  • Joffm
  • Joffm's Avatar
12 Mar 2024 23:53
Replied by Joffm on topic Choice Based Max-Diff Design
Hi,
For these first steps you also can use a javascript solution.
Here I show only ExpressionScript.
1. Create a question of type long text. (QBase)
In the default answer enter your model in this form:
#001182345765821268445612756
#002752386452136621431851457
#003345612348756432153247541
You see in red the version (three digits) followed by the 6 sets of 4 items

2. Create a random number from 1 to your number of versions (question type 'equation') (eqRand)
{if(is_empty(eqRand),rand(1,3),eqRand)}

3. Adjust this random number to 3 digits  (question type 'equation') (eqRand2)
{if(eqRand<10,join('#00',eqRand),if(eqRand<100,join('#0',eqRand),join('#',eqRand)))}

4. Find the matching string in QBase (question type 'equation') (eqVersion)
{substr(QBase,strpos(QBase,eqRand2)+4,24)}

5. Create a question of type multiple short text (Set) with 6 subquestions 1,2,3,4,5,6 (=6 Sets); place it at the end of the group.

6. Split the string (from eqVersion) and assign it to the text question (question type 'equation') (eqSet)
{Set_1=substr(eqVersion,0,4)}
{Set_2=substr(eqVersion,4,4)}
{Set_3=substr(eqVersion,8,4)}
{Set_4=substr(eqVersion,12,4)}
{Set_5=substr(eqVersion,16,4)}
{Set_6=substr(eqVersion,20,4)}


These last two steps are not really necessary but they ease the piping of the texts.

All these questions are hidden.

As mentioned before all this can also be done in javascript
Rough idea:
  1. Create an array containing for all versions these 24 digit strings.
  2. Shuffle the array
  3. Take the first element and distribute 6x4 substrings into the multiple text question.
You will find a lot of examples here. You only have to adapt a little bit.

Now you may create 6 Groups, each with one question with the Maxdiff Layout. All groups get the same randomization group name.
And now you enter these four IF-constructs into the answer options of the first MaxDiff question
{if(substr(Set_1,0,1)=='1','Cooling performance',if(substr(Set_1,0,1)=='2','Energy efficiency',if(substr(Set_1,0,1)=='3','Trouble Free running',if(substr(Set_1,0,1)=='4','Looks of the air-conditioner', if(substr(Set_1,0,1)=='5','Very Low Noise level of the indoor unit',if(substr(Set_1,0,1)=='6','Compact Indoor unit size',if(substr(Set_1,0,1)=='7','Copper Coil reliability – Rust Free','Air throw – speed/ power for fast & even cooling')))))))}

{if(substr(Set_1,1,1)=='1','Cooling performance',if(substr(Set_1,1,1)=='2','Energy efficiency',if(substr(Set_1,1,1)=='3','Trouble Free running',if(substr(Set_1,1,1)=='4','Looks of the air-conditioner', if(substr(Set_1,1,1)=='5','Very Low Noise level of the indoor unit',if(substr(Set_1,1,1)=='6','Compact Indoor unit size',if(substr(Set_1,1,1)=='7','Copper Coil reliability – Rust Free','Air throw – speed/ power for fast & even cooling')))))))}

{if(substr(Set_1,2,1)=='1','Cooling performance',if(substr(Set_1,2,1)=='2','Energy efficiency',if(substr(Set_1,2,1)=='3','Trouble Free running',if(substr(Set_1,2,1)=='4','Looks of the air-conditioner', if(substr(Set_1,2,1)=='5','Very Low Noise level of the indoor unit',if(substr(Set_1,2,1)=='6','Compact Indoor unit size',if(substr(Set_1,2,1)=='7','Copper Coil reliability – Rust Free','Air throw – speed/ power for fast & even cooling')))))))}

{if(substr(Set_1,3,1)=='1','Cooling performance',if(substr(Set_1,3,1)=='2','Energy efficiency',if(substr(Set_1,3,1)=='3','Trouble Free running',if(substr(Set_1,3,1)=='4','Looks of the air-conditioner', if(substr(Set_1,3,1)=='5','Very Low Noise level of the indoor unit',if(substr(Set_1,3,1)=='6','Compact Indoor unit size',if(substr(Set_1,3,1)=='7','Copper Coil reliability – Rust Free','Air throw – speed/ power for fast & even cooling')))))))}


To enter the answer options into the second MaxDiff question you only have to Change "Set_1" to "Set_2", then "Set_3", and so on.

To analyze later, you have to check which item was displayed in which set at which place.
This all you see in the text question "Set".
This way you can restructure the dataset to match the requirements of the analysis.
 

File Attachment:

File Name: limesurvey...4529.lss
File Size:109 KB


Joffm

N.B.
IN this example the items in each question are in random order. If you do not want this just set the flag in the script to "false".
 
  • Giulio_vifo
  • Giulio_vifo's Avatar
12 Mar 2024 22:25
Per favore aiutaci ad aiutarti e compila dove necessario:
La tua versione di LimeSurvey: LimeSurvey Cloud   Versione 6.4.12
Server proprio o LimeSurvey Cloud:cloud
Tema: Esclusione di modalità di risposta dalla rotazione random

==================
Ciao, 

Ho una domanda a risposta multipla con 10 modalità di risposta: 8 devono ruotare in modo random, ma le ultime due (altro, non saprei) devono restare fisse in fondo, senza ruotare con le altre. Come posso limitare la rotazione alle prime 8 modalità di risposta? grazie mille
  • tpartner
  • tpartner's Avatar
12 Mar 2024 17:27 - 12 Apr 2024 14:02
Replied by tpartner on topic Array randomize with "Other" text field
It's all about the order in which portions of the script are executed.

You want to fix the row at the bottom before moving the text input. 

Code:
<script type="text/javascript" data-author="Tony Partner">
    $(document).on('ready pjax:scriptcomplete',function(){
 
        // Define the subquestion code to be fixed at the bottom of the array
        var fixedCode = '10';
 
        // Identify the questions
        var qID = {QID};
        var thisQuestion = $('#question'+qID);
        var nextQuestion = thisQuestion.nextAll('.text-short:eq(0)');
 
        // Move the fixed row to the bottom
        $('table.subquestion-list tbody:eq(0)', thisQuestion).append($('tr[id$="X'+qID+fixedCode+'"]'));
 
        // Fix up the row background colours
        $('tr.answers-list', thisQuestion). each (function(i){
            $(this).removeClass('ls-even ls-odd');
            if(i % 2 == 0) {
                $(this).addClass('ls-even');
            }
            else {
                $(this).addClass('ls-odd');
            }
        });
 
        // Hide the next question
        nextQuestion.hide();
 
        // Move the text input
        $('tr[id^="javatbd"]:last th.answertext', thisQuestion).append($('.answer-item', nextQuestion));
 
        // Clean-up styling
        $('th.answertext .answer-item', thisQuestion).css({
            'padding': 0
        });
        $('th.answertext .answer-item div', thisQuestion).css({
            'padding': 0
        });
 
    });
</script>

Sample survey:  

File Attachment:

File Name: limesurvey...2615.lss
File Size:38 KB
  • vzyldd
  • vzyldd's Avatar
12 Mar 2024 08:39
Please help us help you and fill where relevant:
Your LimeSurvey version: LimeSurvey Community Edition Version 5.4.15+221212
Own server or LimeSurvey hosting: Own
Survey theme/template: Fruity
==================
Greetings.

I need to keep the last option at the end of an array when randomizing the sub-questions. The problem is that the last sub-question also contains a text field (inserted using a script  & instructions from Tony). I tried fixing the position of the last sub-question using another Tony script (as below). Without the text field inserted, this works perfect. With the text field inserted, randomization also moves this text field and does not keep it with the last sub-question. Any ideas how I can keep the last sub-question and the text field together? 

lss attached.<script type="text/javascript" charset="utf-8">
$(document).on('ready pjax:complete',function() {
 
// Define the subquestion code to be fixed at the bottom of the array
var fixedCode = '10';
 
// Move that row to the bottom
$('#question{QID} table.subquestion-list tbody:eq(0)').append($('tr[id$="X{QID}'+fixedCode+'"]'));
 
// Fix up the row background colours
$('#question{QID} tr.answers-list'). each (function(i){
$(this).removeClass('ls-even, ls-odd');
if(i % 2 == 0) {
$(this).addClass('ls-even');
}
else {
$(this).addClass('ls-odd');
}
});
});
</script>
  • MariaAP
  • MariaAP's Avatar
12 Mar 2024 02:30
Replied by MariaAP on topic Randomisation groups order
Hi Joffm,

Thank you so much. This worked perfectly!

Maria
  • Joffm
  • Joffm's Avatar
11 Mar 2024 19:20 - 11 Mar 2024 19:21
Replied by Joffm on topic Choice Based Max-Diff Design
Apologize,
the sript in the workaround section is for 2.50/2.73.
Here something that works in 3.x. - 6.x.
Code:
<script type="text/javascript" charset="utf-8">
 
  function maxDiff(qID, randomize) {
 
    // Identify some elements
    var thisQuestion = $('#question'+qID);
    var thisTable = $('table.subquestion-list:eq(0)', thisQuestion);
 
    // Assign a new question class
    $(thisQuestion).addClass('max-diff-array');
 
    // Move the columns
     $('thead tr:eq(0)', thisTable).prepend($('thead tr:eq(0) th:eq(1)', thisTable));
    $('tr.answers-list', thisTable).each(function(i){
    $('td.answer-item:eq(0)', this).prependTo(this);
    });
 
    // Random rows
    if(randomize) {
        var rowsArr = ;
        $('tr.answers-list', thisTable).each(function(i){
            $(this).attr('data-index', i);
            rowsArr.push(i);
        });
        shuffleArray(rowsArr);
        $(rowsArr).each(function(i){
            $('tbody', thisTable).append($('tr[data-index="'+this+'"]', thisTable));
        });
    }
 
    // Prevent clicking twice in the same row
    $('input[type="radio"]', thisQuestion).on('click', function () {
 
        $('input[type="radio"]', thisQuestion).prop('disabled', false);
        $('input[type="radio"]:checked', thisQuestion).each(function(i) {
            var thisRow = $(this).closest('tr.answers-list');
            $('input[type="radio"]', thisRow).not(this).prop('disabled', true);
        });
    });
 
    // Fix up the row classes
    var rowClass = 1;
    $('tr.answers-list', thisTable).each(function(i) {
        $(this).addClass('array'+(2-(i%2)));
    });
}
function shuffleArray(array) {
    for (var i = array.length - 1; i > 0; i--) {
        var j = Math.floor(Math.random() * (i + 1));
        var temp = array[i];
        array[i] = array[j];
        array[j] = temp;
    }
    return array;
}
  
  $(document).ready(function(){
        // Call the maxDiff() function
        // Set the second parameter to true for randomized rows
        maxDiff({QID}, true);
    });
</script>
<style type="text/css">.ls-answers tbody .answertext {
    text-align: center;
  }
</style>[/i][/i]
  • Joffm
  • Joffm's Avatar
11 Mar 2024 10:46
Replied by Joffm on topic Randomisation groups order
Hi, Maria,
here
[url] manual.limesurvey.org/ExpressionScript_-...#Access_to_variables [/url]
you find all propperties to access variables.
There is ".gseq" that returns the sequential number of the group, starting from 0

At the end of your survey you can create a question of type equation where you use the function "list()" to store these sequential numbers
{list(randfreqsexual.gseq,randfreqhumil.gseq,randfreqmonitor.gseq,randfreqthreats.gseq)}

You will get something like 3,5,2,4
meaning:
Story1 was on fourth place
Story2 was on sixth place
Story3 was on third place
​​​​​​​Story4 was on fifth place

Remember:
In first and second place there are "About you" and "randgender"
The counting starts at 0.

To improve you could subtract the sequence number of the group before in the list-function to start your list with 1.

Joffm
​​​​​​​
  • MariaAP
  • MariaAP's Avatar
11 Mar 2024 08:56 - 11 Mar 2024 09:03
Randomisation groups order was created by MariaAP
Your LimeSurvey version: Version 5.6.7
==================
Hi everyone,

I have a survey with different groups and I would like to randomise the order of 4 different groups (keeping the questions order in each group the same). I have included "randgroup1" under the box "randomisation group" for each of the 4 groups that I want to randomise. This works. However, is there any other way of doing this and register the order in which participants see the 4 different groups?

I have attached a copy of the survey for more clarity. The groups whose order of appearance I want to randomise are the ones titled "Story 1", "Story 2", "Story 3" and "Story 4".

Thank you!

Best,
Maria
  • Joffm
  • Joffm's Avatar
09 Mar 2024 08:31 - 09 Mar 2024 08:34
Na, dann kannst Du sie doch schon gleich in verschiedenen Reihenfolgen anlegen.
Brauchst Du ja nur zu verschieben.
Frage 1
SQ001:  A
SQ002:  B
SQ003:  C
SQ004:  D

Frage 2
SQ003: C
SQ001: A
SQ004: D
SQ002: B

Frage 3
SQ004: D
SQ002: B
SQ001: A
SQ003: C

Macht in den Daten nichts kaputt, und Du bekommst, was Du möchtest.

Joffm
  • Joffm
  • Joffm's Avatar
09 Mar 2024 08:17 - 09 Mar 2024 10:59
Hi,
You used the same randomization group name .
So ALL your 64 questions are shuffled.
And some 8 are in the first group.
So the condition with the relevanceStatus doesn't fit at all.

Either you use different randomization group names for the questions in each group, like "Tak1", "Task2", ,,,

Or two much simplier approaches.
1. Use a simple random number to select randomly one of the eight questions in each group.
Create 8 questions of type equation at the start of  the first group.("rand1", "rand2",..., "rand8")
Each with the equation {if(is_empty(self),rand(1,8 ),self)}. And you hide these questions.

Now the condition of your questions is only "rand1==1", "rand1==2",... "rand4==7",...
No need for randomization group names on question level.

2. Split each of the question groups into two "Question1a" / "Question1b", "Question2a" / "Question2b", ...
Set each "QuestionXb" to hidden by entering a condition "0" and do not enter a randomization group name.
Put only one question into the groups "QuestionXa", the rest into "QuestionXb"
All questions in these two groups get the same randomization group name as above "Task1", "Task2",..., "Task8"

Joffm
Displaying 136 - 150 out of 653 results.

Lime-years ahead

Online-surveys for every purse and purpose