- Posts: 10109
- Thank you received: 3595
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Choice Based Max-Diff Design
- tpartner
-
Topic Author
- Away
- LimeSurvey Community Team
-
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Please Log in to join the conversation.
- Joffm
-
- Away
- LimeSurvey Community Team
-
- Posts: 12942
- Thank you received: 3979
We have no crystal ball.
Please help us help you and fill where relevant:
Your LimeSurvey version: [see right hand bottom of your LimeSurvey admin screen]
Own server or LimeSurvey hosting:
Survey theme/template:
BTW: This works, even in version 6.x.
So, you should send the lss export of this relevant question.
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Please Log in to join the conversation.
- Joffm
-
- Away
- LimeSurvey Community Team
-
- Posts: 12942
- Thank you received: 3979
the sript in the workaround section is for 2.50/2.73.
Here something that works in 3.x. - 6.x.
<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]
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Please Log in to join the conversation.
- tpartner
-
Topic Author
- Away
- LimeSurvey Community Team
-
- Posts: 10109
- Thank you received: 3595
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Please Log in to join the conversation.
- Joffm
-
- Away
- LimeSurvey Community Team
-
- Posts: 12942
- Thank you received: 3979
Now I am really confused.Er...no...
When I had a look at the workaround I saw a different code (with lots of "ui.").
Now it is the same as I showed here. (cache?)
Very strange.
@rajkumar_dms
Your scales are wrong. Swap.
And where is the script?
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Please Log in to join the conversation.
- tpartner
-
Topic Author
- Away
- LimeSurvey Community Team
-
- Posts: 10109
- Thank you received: 3595
Maybe. Can you please clear your cache and try again? If you still see a problem I'll edit it.Now I am really confused.
When I had a look at the workaround I saw a different code (with lots of "ui.").
Now it is the same as I showed here. (cache?)
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Please Log in to join the conversation.
- Joffm
-
- Away
- LimeSurvey Community Team
-
- Posts: 12942
- Thank you received: 3979
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Please Log in to join the conversation.
- Joffm
-
- Away
- LimeSurvey Community Team
-
- Posts: 12942
- Thank you received: 3979
Seeing your Excel sheet:
How many questions do you want to ask each respondent?
How do you select the displayed "row" of the sheet?
In my opinion you have to create as many questions of this kind as you ask to one respondent.
Then you use an algorithm to select the displayed items and pipe them by ExpressionScript into the questions.
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Please Log in to join the conversation.
- Joffm
-
- Away
- LimeSurvey Community Team
-
- Posts: 12942
- Thank you received: 3979
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:
- Create an array containing for all versions these 24 digit strings.
- Shuffle the array
- Take the first element and distribute 6x4 substrings into the multiple text question.
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.
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".
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Please Log in to join the conversation.
- Joffm
-
- Away
- LimeSurvey Community Team
-
- Posts: 12942
- Thank you received: 3979
If you want to display later, use ExpressionScript.
And the other?
Show us.
Create a prototype of the survey and send the lss export.
Remember: You asked for a MaxDiff, nothing else. This is what you got.
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Please Log in to join the conversation.
- Joffm
-
- Away
- LimeSurvey Community Team
-
- Posts: 12942
- Thank you received: 3979
I do not understand that.Also display the Version along with set number
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
In my example there were only three sets, therefore "3"2. Create a random number from 1 to your number of versions (question type 'equation') (eqRand)
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
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Please Log in to join the conversation.
- Joffm
-
- Away
- LimeSurvey Community Team
-
- Posts: 12942
- Thank you received: 3979
Here you see the variables "Setx"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.
and here the results of the questions
As you see
in the first set there was selected
most = 1 "Set1[1]"
least = 2 "Set1[2]"
And in "Set1 (4637)" you see that
displayed item1 was your option 4 ("Looks of the air-conditioner")
displayed item2 was your option 6 ("Compact Indoor unit size")
in the second set there was selected
most = 2
least = 3
In Set 2
displayed item2 was your option 5
displayed item3 was your option 1
It is as you defined in the model.
And this?
Why should it? Your survey is of the same size, there are no more calculations - only in QBase there are a few more linesSupposed if their is more 100 version that would be create problem for us & also impact on runtime
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Please Log in to join the conversation.