Welcome to the LimeSurvey Community Forum

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

list radio - question and answers side-by-side

  • ThomasKohlmann
  • ThomasKohlmann's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 7 months ago #204675 by ThomasKohlmann
list radio - question and answers side-by-side was created by ThomasKohlmann
Hi,
I would like to present the question of a list(radio)-type question and the answer options side-by-side (see attachment). Any suggestion how this could be done is greatly appreciated. I am using Limesurvey 3 on an own server and on limequery.com.
Best,
Thomas
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 7 months ago #204676 by Joffm
As there are identical answer options this is a typical question of type array.
Either in default display

Here you may improve the design of the header by css

or in drop-down layout


Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 7 months ago - 3 years 7 months ago #204680 by Joffm
Hi, Thomas,
just to mention it.

You can do it the way you showed.


I do not think it is the best way.
1. You use an array(text)
2. It is a waste of space (I assume there re more than these three items)

To do this enter this javascript snippet into the question text (in source code mode)
Code:
<script type="text/javascript" charset="utf-8">
  $(document).ready(function(){  
 
    // Identify this question
    var thisQuestion = $('#question{QID}');
 
    // Assign column-specific classes
    $('table.subquestion-list tr', thisQuestion).each(function(i) {
 
      $('> *:gt(0)', this).each(function(i){
        $(this).addClass('column-'+(i+1));
        $(this).attr('data-column', i+1);
      });
    });
 
 
    // Hide the text inputs in columns 1
    $('.column-1 input[type="text"]', thisQuestion).hide();
 
    // Loop through all column-1 inputs
    $('.answer-item.column-1 input[type="text"]', thisQuestion).each(function(i) {
      var thisID = $(this).attr('id');
      var thisValue = $(this).val();
 
      // Insert the radios
      $(this).parent().addClass('radio').append('<span class="inserted-radio-wrapper">\
                    <input id="'+thisID+'-1" class="radio" value="1" name="'+thisID.replace(/answer/, '')+'_radio" type="radio">\
                    <label class="control-label radio-label" for="'+thisID+'-1">Ja, ohne Schwierigkeiten</label>\
                  </span><br/>\
                  <span class="inserted-radio-wrapper">\
                    <input id="'+thisID+'-2" class="radio" value="2" name="'+thisID.replace(/answer/, '')+'_radio" type="radio">\
                    <label class="control-label radio-label" for="'+thisID+'-2">Ja, mit leichten Schwierigkeiten</label>\
                  </span><br/>\
                  <span class="inserted-radio-wrapper">\
                    <input id="'+thisID+'-3" class="radio" value="3" name="'+thisID.replace(/answer/, '')+'_radio" type="radio">\
                    <label class="control-label radio-label" for="'+thisID+'-3">Ja, mit mittleren Schwierigkeiten</label></span><br/>\
                  <span class="inserted-radio-wrapper">\
                    <input id="'+thisID+'-4" class="radio" value="4" name="'+thisID.replace(/answer/, '')+'_radio" type="radio">\
                    <label class="control-label radio-label" for="'+thisID+'-4">Ja, mit erheblichen Schwierigkeiten</label></span><br/>\
                  <span class="inserted-radio-wrapper">\
                    <input id="'+thisID+'-5" class="radio" value="5" name="'+thisID.replace(/answer/, '')+'_radio" type="radio">\
                    <label class="control-label radio-label" for="'+thisID+'-5">Dazu bin ich nicht in der Lage</label></span><br/>\
                  <span class="inserted-radio-wrapper">\
                    <input id="'+thisID+'-6" class="radio" value="6" name="'+thisID.replace(/answer/, '')+'_radio" type="radio">\
                    <label class="control-label radio-label" for="'+thisID+'-6">Weiß ich nicht</label>\
                  </span>');
 
      // Initial radio states
      $(this).closest('td').find('input[type="radio"][value="'+thisValue+'"]').prop('checked', true);
    });
 
    // Listener on the radios
    $('.answer-item.column-1 input[type="radio"]', thisQuestion).on('click', function() {
      var thisInput = $(this).closest('td').find('input[type="text"]');
      $(this).closest('td').find('input[type="text"]').val($(this).val());
      checkconditions($(thisInput).val(), $(thisInput).attr('name'), 'text');
    });
 
 
    // Some clean-up styles for the radios (could be placed in template.css)
    $('thead th, .answer-item.column-1', thisQuestion).css({
      'text-align': 'left',
            'margin-left': '0px'
    });
    $('.answer-item.column-1 .inserted-radio-wrapper', thisQuestion).css({
      'display': 'inline-block',
      'margin': '0px 0px 0 0px',
            'padding-left':'20px'
    });
    $('.answer-item.column-1 label', thisQuestion).css({
      'padding': '0'
    });
        $('.ls-answers tbody .answertext', thisQuestion).css({
            'text-align': 'left',
            'vertical-align': 'top'
    });
    $('.answer-item.column-1 .radio-label', thisQuestion).css({
      'padding-left': '3px',
      'margin-right': '3px',
            'padding':'0px 0px 0px 3px',
            'margin-left':'10px'
    });
 
 
    // Fix up the row background colours
    var rowIndex = 0;
    $('table.subquestion-list tbody tr', thisQuestion).each(function(i){
      rowIndex ++;
      $(this).removeClass('array1, array2');
      if(rowIndex % 2 == 0) {
        $(this).addClass('array1');
      }
      else {
        $(this).addClass('array2');
      }
    });
  });
</script>

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 3 years 7 months ago by Joffm.
The following user(s) said Thank You: ThomasKohlmann
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 7 months ago #204707 by holch
I agree with Joffm. I would go with Array/Matrix question in your case.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The following user(s) said Thank You: ThomasKohlmann
The topic has been locked.
  • ThomasKohlmann
  • ThomasKohlmann's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 7 months ago #204711 by ThomasKohlmann
Replied by ThomasKohlmann on topic list radio - question and answers side-by-side
Dear Joffm,

Just in case my recent "quick reply" did not get through: Thank you very much for your very helpful advice. The JavaScript snippet with an Array(text) question does exactly what I need (question on the left, response options in vertical format on the right). I would usually go for the solution using a matrix question, but this time the vertical response format was needed.

I am deeply impressed by the substantial help I received so quickly!

Best regards,
Thomas
The topic has been locked.
  • ThomasKohlmann
  • ThomasKohlmann's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 7 months ago #204712 by ThomasKohlmann
Replied by ThomasKohlmann on topic list radio - question and answers side-by-side
Dear Holch,

Thanks for your reply. Yes, the Array-type question does the job very well. As I need a vertical format of the reponse categories, a Matrix-type question would probably not work.

Best regards,
Thomas
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 7 months ago #204715 by holch

Thanks for your reply. Yes, the Array-type question does the job very well. As I need a vertical format of the reponse categories, a Matrix-type question would probably not work.


That is somehow contradictory. Because the question type is called Array in English and Matrix in German. So either it works, or it doesn't.

Now if you really need the answer options to be aligned vertical, then you could think of "Array by column", where the answer options are vertical and the subquestions are horizontal. But subquestions usually are longer.

But to be honest, I don't see why the answer options would need to be vertically aligned, despite some weird personal preference.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The topic has been locked.
  • ThomasKohlmann
  • ThomasKohlmann's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 7 months ago #204720 by ThomasKohlmann
Replied by ThomasKohlmann on topic list radio - question and answers side-by-side
Dear Holch,

Thank you very much for the clarification. You are perfecly right that array and matrix are just two terms for the same type of questions.

Your suggestion to use the "Array by column" type might work, yet, I did not find out how the answer options could be placed to the right and the subquestions to the left. I would be very grateful if you could give me a clue how this can be done.

Vertical alignment of answer options ist not only a matter of personal preference. My survey consists of questions with different response category types (agreement, frequency, yes/no, etc.). So with several questions on one screen page, it may be easier for the respondent to find the appropriate answer if they are always aligned in the same way. Furthermore, with vertical alignment, there will never be a problem with space if the number of answer options is large - with horizontal alignment this could be a challenge.

Best regards.
Thomas
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 7 months ago #204722 by holch
If your questions, different to the screenshot you showed, has different answer options per question/subquestion, then Array by column won't help either, because it is basically just an array that is turned by 90°...

By the way, I had not seen your answer to Joffm, when I sent my answer.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The following user(s) said Thank You: ThomasKohlmann
The topic has been locked.
  • ThomasKohlmann
  • ThomasKohlmann's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 7 months ago #204723 by ThomasKohlmann
Replied by ThomasKohlmann on topic list radio - question and answers side-by-side
Dear Holch,

Thank you very much for your helpful comments.

Best,
Thomas
The topic has been locked.
  • ThomasKohlmann
  • ThomasKohlmann's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 7 months ago #205152 by ThomasKohlmann
Replied by ThomasKohlmann on topic list radio - question and answers side-by-side
Hi,

I sucsessfully implemented everything in an array-question. Now I tried to modified the look a little bit, with the theme.css. I need to get get rid of the first empty row, because they distract to much. First, I tried to hide the hole first row, but I can't find anything about that(SC1). Second, I tried to hide all borders. So I searched for every container, marked them up to be sure that everything is in and then I hide them. So every border exept of 4 lines are away(SC2).

Are there any suggestion how this could be done properly?


Best regards,
Thomas
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 7 months ago #205156 by Joffm
Hi,
1. Do not change anything in theme.css. Always use the custom.css.

And if you thing you would like to remove this header row,
the webdevelopment tool shows you the way:


So you might add this to your custom .css
Code:
tr.ls-heading {
    display: none;
}

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: ThomasKohlmann
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose