Check out the LimeSurvey source code on GitHub!

Dual Scale Array to Multiple Scale Array Possibility?

More
4 years 10 months ago #78177 by tpartner
It looks like you have extra line breaks or empty paragraphs in the question texr for question 1. I would need to see the source (a live survey) to know which.

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.

More
4 years 10 months ago #78179 by DianaS7
I tried again and now the 1st and 2nd columns are aligned, but not the 2rd. As you can see:

dianas.limequery.com/index.php?sid=57517&newtest=Y&lang=en


This is the source of question 1:

Question 1 <script type="text/javascript" charset="utf-8">

$(document).ready(function() {

// Call the function wit the start and end question positions
sideBySide(1, 3);

function sideBySide(start, end) {

// Add some temporary classes to the target questions
$('div[id^="question"]').each(function(i){
var qNum = i + 1;
var el = $(this);
if (qNum >= start && qNum <= end) {
$(el).addClass('targetQ');
}
});

// Wrap the questions in a div
$('.targetQ').wrapAll('<div class="targetWrapper" />');
$('.targetWrapper').after('<div style="clear:both" />');

// Add some classes to the questions in the target wrapper
$('.targetWrapper .targetQ').addClass('inlineQuestion inlineQuestionSub');
$('.targetWrapper .inlineQuestionSub:first').removeClass('inlineQuestionSub').addClass('inlineQuestionPrime');

// Remove the text from the secondary questions
$('.targetWrapper .inlineQuestionSub th.answertext').text('');

// Apply some styles (these are for the default template)
$('.targetWrapper .inlineQuestion').css({ 'float': 'left' });
$('.targetWrapper .inlineQuestion col, .targetWrapper .inlineQuestion th.answertext').css({ 'width': 'auto' });
$('.targetWrapper .inlineQuestion .question-wrapper').css({ 'width': '100%' });
$('.targetWrapper .inlineQuestion td.answer').css({ 'padding': '0.5em 0' });
$('.targetWrapper .inlineQuestion td.questiontext').css({ 'text-align': 'center' });

// Center the wrapper div
var wrapperWidth = 0;
$('.targetWrapper .inlineQuestion').each(function(i){
wrapperWidth = wrapperWidth + $(this).width();
var padLeft = $('.answertext:eq(0)', this).width() + 3;
$('.questiontext', this).css({ 'padding-left':padLeft+'px', 'padding-right':'3px' });
});
$('.targetWrapper').css({ 'width':wrapperWidth+'px', 'margin': '0 auto' });

// Set the row heights
var wrapperWidth = 0;
$('.targetWrapper .inlineQuestionSub').each(function(i){
$('tbody[id^="javatbd"]', this).each(function(i){
var ansHeight = $('.targetWrapper .inlineQuestionPrime th.answertext:eq('+i+')').innerHeight();

if($.browser.mozilla) {
$('th.answertext', this).height(ansHeight-1);
}
else {
$('th.answertext', this).innerHeight(ansHeight);
}
});
});

// Remove the temporary classes
$('.targetQ').removeClass('targetQ');
$('.targetWrapper').removeClass('targetWrapper');
}
});

</script>

Please Log in to join the conversation.

More
4 years 10 months ago #78183 by tpartner
This workaround is limited to questions of the same type.

If you use different question types you will need to add some custom CSS to control the row heights.

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.

More
4 years 10 months ago #78184 by DianaS7
Yes, I changed everything to the same type and it´s perfect :)

Thank you

Diana

Please Log in to join the conversation.

More
4 years 10 months ago #78194 by DianaS7
I just have one more question.
Do you if it´s possible to add another option to a text/numeric type question. See in the image attached, please.

Thnaks,

Diana
Attachments:

Please Log in to join the conversation.

More
4 years 10 months ago #78198 by tpartner
That doesn't seem related to this discussion. Please start new threads for new topics.

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.

More
4 years 10 months ago #78763 by DianaS7
Hi Tony,

The multiple scale array is working perfectly in Google Chrome and Internet Explorer, but it doesn´t work in Mozilla.

There´s anything I can do?

Thanks,

Diana

Please Log in to join the conversation.

  • lsorg
  • lsorg's Avatar
  • Visitor
  • Visitor
3 years 7 months ago - 3 years 7 months ago #98099 by lsorg

tpartner wrote: Ah, okay, use this:

<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function() {
		// Loop through all questions (except boilerplates) and add some classes
		$('div[id^="question"]').each(function(i){
			if (!$(this).hasClass('boilerplate')) {
				$(this).addClass('inlineQuestion inlineQuestionSub');
			}
		});
		$('.inlineQuestionSub:first').removeClass('inlineQuestionSub').addClass('inlineQuestionPrime');
 
		// Wrap the questions in a div
		$('.inlineQuestion').wrapAll('<div class="inlineWrapper" />');
 
		// Remove the text from the secondary questions
		$('.inlineQuestionSub th.answertext').text('');
 
		// Apply some styles (these are for the default template)
		$('.inlineQuestion').css({ 'float': 'left' });
		$('.inlineQuestion col, .inlineQuestion th.answertext').css({ 'width': 'auto' });
		$('.inlineQuestion .question-wrapper').css({ 'width': '100%' });
		$('.inlineQuestion td.answer').css({ 'padding': '0.5em 0' });
		$('.inlineQuestion td.questiontext').css({ 'text-align': 'center' });
 
		// Center the wrapper div
		var wrapperWidth = 0;
		$('.inlineQuestion').each(function(i){ 
			wrapperWidth = wrapperWidth + $(this).width();
			var padLeft = $('.answertext:eq(0)', this).width() + 3;
			$('.questiontext', this).css({ 'padding-left':padLeft+'px', 'padding-right':'3px' });
		});
		$('.inlineWrapper').css({ 'width':wrapperWidth+'px', 'margin': '0 auto' });
 
		// Set the row heights
		var wrapperWidth = 0;
		$('.inlineQuestionSub').each(function(i){
			$('tbody[id^="javatbd"]', this).each(function(i){ 
				var ansHeight = $('.inlineQuestionPrime th.answertext:eq('+i+')').innerHeight();
				//$('th.answertext', this).css({ 'height':ansHeight+'px' });
 
				if($.browser.mozilla) {
					$('th.answertext', this).height(ansHeight);
				}
				else {
					$('th.answertext', this).innerHeight(ansHeight);
				}
			});
		});
	});
 
</script>


Hey guys,

I'm using limesurvey since a few days and it is fantastic.
Now I had the same issue like the thread starter. I copy the script and it worked to build the questions side by side.

But my problem is that it builds all question in the chapter side by side. But I only want the first and the second question side by side.

Does anyone know how I can change the script code that it only puts the questions side by side that I want? I think it would work with the question id, but I don't know how.

Best regards,
lsorg
Last Edit: 3 years 7 months ago by lsorg.

Please Log in to join the conversation.

More
3 years 7 months ago #98115 by DenisChenu
$('div[id^="question"]').each(function(i){

to

$('#question42,#question43').each(function(i){
If your question number are 42 and 43.

Please read jquery documentation : api.jquery.com/category/selectors/

Denis

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).

Please Log in to join the conversation.

  • lsorg
  • lsorg's Avatar
  • Visitor
  • Visitor
3 years 7 months ago #98129 by lsorg
Great job. That's amazing, it works fantastic.

Thanks.

Please Log in to join the conversation.

More
11 months 2 weeks ago #132899 by dagustin
Hi everyone!

I have the same problem as Newbeedu. The main difference is that I must use selectboxes because the answers list is very long. I tried with Tpartner's script but it doesnt work. Could someone help me?

Thank you and have a nice day!

Please Log in to join the conversation.

More
11 months 2 weeks ago #132902 by tpartner
dagustin, this topic and the workarounds are very old and may not be suitable for recent versions. Please start a new thread explaining exactly what you are trying to do and include screenshots, your LimeSurvey version number and a small sample survey.

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.

Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form