This day challenge was to install limesurvey and copy an existing survey built with EUSurvey. One of the question was an array with comments  for every sub-question in the last column. LimeSurvey does not offer a built in question for that you need to tweak the array question to work.

So here is my solution.

LimeSurvey Array with Comments

  1. Create the array with the answers and sub-questions.
  2. Create a Multiple short text question with as many sub-question as many there are in the array.
  3. Edit the Array question.

LimeSurvey Array with Comments

  1. Add the following code to copy the Multi short text questions to the Array.
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){

    // Identify the questions
    var thisQuestion = $('#question{QID}');
    var nextMultiText1 = $(thisQuestion).nextAll('.multiple-short-txt:eq(0)');

    // Hide the next questions
    $(nextMultiText1).hide();

    // Add extra columns to the array
    $('table.question thead tr th:eq(6)', thisQuestion).after('<th class="newColumn1" />');
    $('table.question tbody tr', thisQuestion).each(function(i) {
         $('td:eq(5)', this).after('<td class="newColumn1" />');
    });

    // Move the hidden question text to the inserted columns
    $('table.question thead tr th.newColumn1', thisQuestion).text($('.questiontext', nextMultiText1).text());

    // Move the text inputs and dropdowns
    $('input.text', nextMultiText1).each(function(i){
        $('table.question tbody tr:eq('+i+') td.newColumn1', thisQuestion).append(this);
    });

    // Some cleanup styles (for the default template)
    $('col', thisQuestion).css({
        'width': 'auto'
    });
    $('table.question tbody th, table.question tbody td', thisQuestion).css({
        'padding': '4px 10px'
    });
});
</script>

Please note that the script has to be added to all language versions.

Survey can be downloaded from this link:
http://eduroll.eu/wp-content/uploads/2017/09/limesurvey_survey_nagygzs.zip

Cheers.

Leave a comment

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.