- Posts: 8
- Thank you received: 0
Ask the community, share ideas, and connect with other LimeSurvey users!
Please Log in to join the conversation.
Please Log in to join the conversation.
Please Log in to join the conversation.
Please Log in to join the conversation.
Please Log in to join the conversation.
Probably the most common mistake ever made when it comes to digitalizing questionnaires.As we need to create an online survey that corresponds as much as we can to the format used on paper (not editable),
Please Log in to join the conversation.
I could not find a way to reorder the array for it to start with the text field. I tried to use the function ".prepend()" instead of ".append()" but the subquestions' titles were then placed on the middle of the array:
<script type="text/javascript" data-author="Tony Partner"> $(document).on('ready pjax:scriptcomplete',function(){ // Identify the questions var qArrayID = {QID}; var qArray = $('#question'+qArrayID); var qMultiText = qArray.nextAll('.multiple-short-txt:eq(0)'); var qMultiTextBis = qMultiText.nextAll('.multiple-short-txt:eq(0)'); // Hide the multi-short-text question $(qMultiText).hide(); $(qMultiTextBis).hide(); // Remove the core column widths $('table.questions-list col:not(.col-answers)', qArray).css('width', 'auto'); // Insert the header cells $('table.questions-list thead td:eq(0)', qArray).after('<th class="answer-text inserted-column-label" /></th><th class="answer-text-bis inserted-column-label-bis" /></th>'); $('.inserted-column-label, .inserted-column-label-bis', qArray).css('width','30%'); // Insert the answer row cells $('tr.answers-list', qArray).each(function(i) { $('.answertext', this).after('<td class="answer-item text-item"></td><td class="answer-item text-item-bis"></td>'); }); // Load the column label for the text inputs $('.inserted-column-label:eq(0)', qArray).text($('.ls-label-question', qMultiText).text()); $('.inserted-column-label-bis:eq(0)', qArray).text($('.ls-label-question', qMultiTextBis).text()); // Loop through the multi-short-text sub-questions $('li.answer-item', qMultiText).each(function(i) { // Move the text inputs into the array $('input[type="text"]', this).appendTo($('tr.answers-list:eq('+i+') .text-item', qArray)); }); $('li.answer-item', qMultiTextBis).each(function(i) { // Move the text inputs into the array $('input[type="text"]', this).appendTo($('tr.answers-list:eq('+i+') .text-item-bis', qArray)); }); }); </script>
Please Log in to join the conversation.
Please Log in to join the conversation.
Please Log in to join the conversation.
<script type="text/javascript" charset="utf-8"> $(document).on('ready pjax:scriptcomplete',function(){ // Identify this question var thisQuestion = $('#question{QID}'); // Column-specific classes $('tr.subquestion-list', thisQuestion).each(function(i) { $('th, td', this).each(function(i) { $(this).addClass('column-'+i); }); }); // Insert checkboxes $('.answer-item.column-1, .answer-item.column-2, .answer-item.column-3, .answer-item.column-4, .answer-item.column-7, .answer-item.column-8', thisQuestion).addClass('custom-checkbox-item'); $('.custom-checkbox-item', thisQuestion).each(function(i) { var thisID = $('input:text:eq(0)', this).attr('id'); $('label', this).before('<input class="" id="'+thisID+'" value="Y" type="checkbox" name="'+thisID.replace(/answer/, '')+'" />'); if($('input:text:eq(0)', this).val() == 'Y') { $('input:checkbox:eq(0)', this).prop('checked', true); } $(this).removeClass('text-item').addClass('checkbox-item'); $('input:text:eq(0)', this).remove(); }); // Identify exclusive items $('.answer-item.column-1, .answer-item.column-2, .answer-item.column-3, .answer-item.column-4, .answer-item.column-5, .answer-item.column-6', thisQuestion).addClass('non-exclusive-item'); $('.answer-item.column-7, .answer-item.column-8', thisQuestion).addClass('exclusive-item'); // Listeners for exclusive items $('.non-exclusive-item input:checkbox', thisQuestion).on('change', function(e) { if($(this).is(':checked')) { $(this).closest('tr.subquestion-list').find('.exclusive-item input:checkbox').prop('checked', false); } }); $('.non-exclusive-item input:text', thisQuestion).on('keyup change', function(e) { if($.trim($(this).val()) != '') { $(this).closest('tr.subquestion-list').find('.exclusive-item input:checkbox').prop('checked', false); } }); $('.exclusive-item input:checkbox', thisQuestion).on('change', function(e) { if($(this).is(':checked')) { var thisItem = $(this).closest('.answer-item'); $(this).closest('tr.subquestion-list').find('.answer-item').not(thisItem).find('input:checkbox').prop('checked', false); $(this).closest('tr.subquestion-list').find('input:text').val(''); } }); }); </script>
<script type="text/javascript" charset="utf-8"> $(document).on('ready pjax:scriptcomplete',function(){ var thisQuestion = $('#question{QID}'); // Add a question class thisQuestion.addClass('custom-array'); // Column-specific classes $('table.subquestion-list tr', thisQuestion).each(function(i) { $('th, td', this).each(function(i) { $(this).addClass('column-'+i); }); }); }); </script>
<style type="text/css">.custom-array table.subquestion-list col {width: auto !important;}.custom-array table.subquestion-list thead .column-0 { width: 16%; } .custom-array table.subquestion-list thead .column-1 { width: 7%; } .custom-array table.subquestion-list thead .column-2 { width: 7%; } .custom-array table.subquestion-list thead .column-3 { width: 7%; } .custom-array table.subquestion-list thead .column-4 { width: 7%; } .custom-array table.subquestion-list thead .column-5 { width: 21%; } .custom-array table.subquestion-list thead .column-6 { width: 21%; } .custom-array table.subquestion-list thead .column-7 { width: 7%; } .custom-array table.subquestion-list thead .column-8 { width: 7%; }</style>
Please Log in to join the conversation.
Please Log in to join the conversation.
// Insert checkboxes $('.answer-item.column-1, .answer-item.column-2, .answer-item.column-3, .answer-item.column-4, .answer-item.column-7, .answer-item.column-8', thisQuestion).addClass('custom-checkbox-item');
// Identify exclusive items $('.answer-item.column-1, .answer-item.column-2, .answer-item.column-3, .answer-item.column-4, .answer-item.column-5, .answer-item.column-6', thisQuestion).addClass('non-exclusive-item'); $('.answer-item.column-7, .answer-item.column-8', thisQuestion).addClass('exclusive-item'); // Listeners for exclusive items
Please Log in to join the conversation.