Welcome to the LimeSurvey Community Forum

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

MaxDiff Question

  • RitaShen
  • RitaShen's Avatar Topic Author
  • Away
  • Premium Member
  • Premium Member
More
8 years 3 months ago #140860 by RitaShen
MaxDiff Question was created by RitaShen
I follow the step by the website, but cannot built the layout like that,
how can I do for this?
www.limesurvey.org/manual/Workarounds:_Q...axDiff_question_type

the attachment is
Attachments:
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 3 months ago #140861 by tpartner
Replied by tpartner on topic MaxDiff Question
LimeSurvey version?

I'm not in a position to debug this weekend but can you give us a link to a live test survey?

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • RitaShen
  • RitaShen's Avatar Topic Author
  • Away
  • Premium Member
  • Premium Member
More
8 years 3 months ago #140864 by RitaShen
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 3 months ago #140865 by tpartner
Replied by tpartner on topic MaxDiff Question
I ask again, what LimeSurvey version?

That appears to be a link to the LimeSurvey admin section, not the survey.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • RitaShen
  • RitaShen's Avatar Topic Author
  • Away
  • Premium Member
  • Premium Member
More
8 years 3 months ago #140866 by RitaShen
Replied by RitaShen on topic MaxDiff Question
sorry to give you the wrong link.
www.pushknock.com/projects/limesurvey/index.php/941186?lang=en

I use the version2.50
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 3 months ago #140889 by Joffm
Replied by Joffm on topic MaxDiff Question
Hi, Rita,
looking at your survey I see something like the default template of LS version 2.05/2.06.
But you say you work with version 2.50.

You know that the "old" templates don't work correctly in 2.50.
On the other side I fear that the example which was created and tested with version 1.87 will not work in newer versions, especially 2.50

Please, provide a sample survey with just this question (*.lss).

Best regards
Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 3 months ago #140896 by tpartner
Replied by tpartner on topic MaxDiff Question
If using version 2.50, follow these steps to create a MaxDiff question type:

1) Set up your survey to use JavaScript .

2) Create an Array (flexible labels) by column question with 2 "answers" - these will be the left and right columns.

3) Create a copy the default template.

4) Add the following to the end of template.js in your new template:
Code:
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) th:eq(1)', thisTable).prependTo('thead tr:eq(0)', 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.radio', thisQuestion).on('click', function () {
 
    $('input.radio', thisQuestion).prop('disabled', false);
    $('input.radio:checked', thisQuestion).each(function(i) {
      var thisRow = $(this).closest('tr.answers-list');
      $('input.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;
}

5) Add something like the following to the end of template.css in your new template:
Code:
.max-diff-array th.answertext { 
  text-align: center;
  border-right: 3px solid #FFFFFF;
  border-left: 3px solid #FFFFFF;
}
 
/* Override the responsive "no-more-tables" stuff */
@media only screen and (max-width: 801px) {
 
  .max-diff-array .no-more-tables table {
    display: table;
    border-collapse: inherit;
  }  
 
  .max-diff-array .no-more-tables thead, 
  .max-diff-array .no-more-tables tbody {
    display: table-row-group;
  }
 
  .max-diff-array .no-more-tables tr {
    left: auto;
    position: relative;
    top: auto;
    display: table-row;
    border: 0 none;
  }  
 
  .max-diff-array .no-more-tables th, 
  .max-diff-array .no-more-tables td {
    display: table-cell;
    text-align: center !important;
    color: #2c3e50;
    font-size: 15px;
  }
 
  .max-diff-array th.answertext { 
    border-right: 3px solid #FFFFFF;
    border-left: 3px solid #FFFFFF;
  }
 
  .max-diff-array .answer-item label span {
    display: none !important;
  }  
}

6) Add a script like this to the question source of the Array (flexible labels) question:
Code:
<script type="text/javascript" charset="utf-8">     
  $(document).ready(function(){
    // Call the maxDiff() function
    // Set the second parameter to true for randomized rows
    maxDiff({QID}, true);
  });
</script>



Sample template and survey attached:

File Attachment:

File Name: Demo_MaxDi...r_25.zip
File Size:301 KB


File Attachment:

File Name: Demo_MaxDiff.lss
File Size:17 KB

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: RitaShen
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 3 months ago - 8 years 3 months ago #140898 by tpartner
Replied by tpartner on topic MaxDiff Question
I have updated the workaround page here - www.limesurvey.org/manual/Workarounds:_Q...mplating#Version_2.5

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 8 years 3 months ago by tpartner.
The following user(s) said Thank You: elissa, RitaShen
The topic has been locked.
  • RitaShen
  • RitaShen's Avatar Topic Author
  • Away
  • Premium Member
  • Premium Member
More
8 years 3 months ago #140921 by RitaShen
Replied by RitaShen on topic MaxDiff Question
thanks for helping.

I have another question about design.
I want to use the Implicit Association Test (IAT)
www.limesurvey.org/manual/Workarounds:_M...ation_Test_.28IAT.29
But the template seems that cannot implement on the version 2.5
it will show "undefined", not association terms and the other text elements for the interface into the Question Help section.
my survey:https://www.pushknock.com/projects/limesurvey/index.php/survey/index/sid/412754/newtest/Y/lang/en

thank you
Attachments:
The topic has been locked.
  • RitaShen
  • RitaShen's Avatar Topic Author
  • Away
  • Premium Member
  • Premium Member
More
8 years 3 months ago #140922 by RitaShen
Replied by RitaShen on topic MaxDiff Question
I have to use the IAT template, so I just download the template from the website
www.limesurvey.org/manual/Workarounds:_M...ation_Test_.28IAT.29
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 3 months ago - 8 years 3 months ago #140941 by tpartner
Replied by tpartner on topic MaxDiff Question

But the template seems that cannot implement on the version 2.5...

I have updated the workaround page with a new survey and template for the "Implicit Association Test (IAT)" in LimeSurvey version 2.5 - www.limesurvey.org/manual/Workarounds:_M...ascript#Version_2.50


Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 8 years 3 months ago by tpartner.
The following user(s) said Thank You: RitaShen
The topic has been locked.
  • RitaShen
  • RitaShen's Avatar Topic Author
  • Away
  • Premium Member
  • Premium Member
More
8 years 3 months ago #141005 by RitaShen
Replied by RitaShen on topic MaxDiff Question
thanks for help!

can we use the image for answers in the IAT question?

I have try once, but it won't show anything

thank you
The topic has been locked.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose