Multiple question types in array

More
1 year 11 months ago #129343 by Stan
Stan created the topic: Multiple question types in array
Hi all,

i would like to let some questions appearing in an array. The workaround in the Manual is very good but the Javascript-code doesn't set it up in the way i want it. Then the code is taking in all the next following questions in the change, while i just want to put only 2 or 3 questions in the same array. Is there a way to modify the code, so that it would take only a specific number of questions and not influence the following ones? Thanks.

Using LS Version 2.06+ Build 151018

Please Log in to join the conversation.

More
1 year 11 months ago #129345 by holch
holch replied the topic: Multiple question types in array
From what I read in the explanation of the workaround you can adapt the columns and lines so that it takes only certain questions on the page.

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds
The following user(s) said Thank You: Stan

Please Log in to join the conversation.

More
1 year 11 months ago - 1 year 11 months ago #129356 by Stan
Stan replied the topic: Multiple question types in array
Thanks holch for reply.

I tried to manipulate the code without success (despite of a quick Java Tutorial). I certainly need a hint on this.
Here is a LINK to the survey i'm working on.
For example, i just want the two first questions to be displayed in an array. And the following others normally.
Last Edit: 1 year 11 months ago by Stan. Reason: Complete information

Please Log in to join the conversation.

More
1 year 11 months ago #129362 by holch
holch replied the topic: Multiple question types in array
Off-topic: Seeing your example, I am not even sure why you want these two questions in an array. They don't really have anything to do one with the other (e.g. the same subquestion per line). These are actually two separate questions and I personally would treat and display them as such.

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds

Please Log in to join the conversation.

More
1 year 11 months ago #129374 by tpartner
tpartner replied the topic: Multiple question types in array
It seems to me that you have called the sideBySide() function with 4 rows and 4 columns, so it will attempt to manipulate 16 questions.

If you only want 2 questions in a single row, this:
sideBySide(4, 4, 1);

Should be something like this:
sideBySide(1, 2, 1);

Having said that, if only a couple of questions are to be manipulated, you may be better off just aligning them side-by-side with CSS.

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: Stan

Please Log in to join the conversation.

More
1 year 11 months ago #129389 by Stan
Stan replied the topic: Multiple question types in array
Hi holch,

don't worry :-) I just wanted to show how the code is displaying the questions (without paying attention to the logic).

Please Log in to join the conversation.

More
1 year 11 months ago #129390 by Stan
Stan replied the topic: Multiple question types in array
Thank you tpartner,

i applied everything as you recommended and it works. Here a snapshot.
Attachments:

Please Log in to join the conversation.

More
1 year 11 months ago - 1 year 11 months ago #129391 by Stan
Stan replied the topic: Multiple question types in array
I do have another question.
The next following question is looking like this - And i want questions 1 and 2 to look like above in an array.


So i simply inserted the whole code in the question "1" (it's actually the 7th question in my survey:
sideBySide(1, 2, 7);
and the result is this:


The questions "1" and "2" are joining the array above. While i want them to stay at their place. In other words, i would like to have the array above two times (or more when necessary) in the survey at different places. Because these questions will be asked very often.
How can we make that happen?
Attachments:
Last Edit: 1 year 11 months ago by Stan.

Please Log in to join the conversation.

More
1 year 11 months ago - 1 year 11 months ago #129410 by tpartner
tpartner replied the topic: Multiple question types in array
That workaround was not intended to be used more than once on a page and, if all you want to do is align various sets of two questions side-by-side, I think it may be overkill anyway.

Can you attach a small sample survey containing only that group?

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last Edit: 1 year 11 months ago by tpartner.
The following user(s) said Thank You: Stan

Please Log in to join the conversation.

More
1 year 11 months ago #129461 by Stan
Stan replied the topic: Multiple question types in array
Thanks tpartner,

HERE is a sample survey containing only the group but without the workaround.
HERE the same sample with the workaround like before.

Please Log in to join the conversation.

More
1 year 11 months ago #129464 by holch
holch replied the topic: Multiple question types in array
To help you Tpartner will probalby need that you export a sample survey (containing only the part in question). He can't work on your survey, and it is a bit much to ask of him to rebuild the survey to help you. ;-)

Help him/us to help you.

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds
The following user(s) said Thank You: tpartner

Please Log in to join the conversation.

More
1 year 10 months ago #129516 by tpartner
tpartner replied the topic: Multiple question types in array
Yes, please attach an EXPORT of a small sample survey containing only that group, not a link to an existing 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.

More
1 year 10 months ago #129560 by Stan
Stan replied the topic: Multiple question types in array
Sorry holch and tpartner,

i didn't understood it that way. Here is an export of the sample survey. Thanks a lot.

File Attachment:

File Name: limesurvey...7256.lss
File Size:48 KB
Attachments:

Please Log in to join the conversation.

More
1 year 10 months ago - 1 year 10 months ago #129574 by tpartner
tpartner replied the topic: Multiple question types in array
Add this script to the first question of each pair you want to display side-by-side. Note that some of the selectors and styles in this script are specific to the default template so may need to be changed for other templates.

<script type="text/javascript" charset="utf-8">		
	$(document).ready(function() {	
 
		// Identify the questions
		var thisQuestion = $('#question{QID}');
		var nextQuestion = $(thisQuestion).nextAll('div[id^="question"]:eq(0)');
		var theseQuestions = $(thisQuestion).add(nextQuestion);
 
		// Place the questions side-by side
		$(theseQuestions).wrapAll('<div style="width:75%; margin: 0 auto" />');
		theseQuestions.css({
			'float': 'left',
			'width': '50%'
		});
		$('> table', theseQuestions).css({
			'width': '100%'
		});
 
		// Some styling for the textareas
		$('textarea', theseQuestions).removeAttr('cols').css({
			'margin-left': '0',
			'margin-right': '0',
			'width': '100%'
		});
 
		// Equalize heights
		if($(thisQuestion).is(':hidden')) { 
			$(theseQuestions).css({
				'position': 'absolute',
				'left': '-9999em'
			}).show();
			equalizeHeights();
			$(theseQuestions).css({
				'position': 'relative',
				'left': 'auto'
			}).hide();
		}
		else {
			equalizeHeights();
		}
 
		function equalizeHeights() {
			var questionTextHeight = 0;
			$('td.questiontext', theseQuestions).each(function(i) {
				if($(this).height() > questionTextHeight) {
					questionTextHeight = $(this).height()
				}
				$('td.questiontext', theseQuestions).height(questionTextHeight);
			});
			var answerHeight = 0;
			$('td.answer', theseQuestions).each(function(i) {
				if($(this).height() > answerHeight) {
					answerHeight = $(this).height()
				}
				$('td.answer', theseQuestions).height(answerHeight);
			});
			var helpHeight = 0;
			$('td.survey-question-help', theseQuestions).each(function(i) {
				if($(this).height() > helpHeight) {
					helpHeight = $(this).height()
				}
				$('td.survey-question-help', theseQuestions).height(helpHeight);
			});
		}		
    });
</script>

Here is an abbreviated version of your survey with the script in the source of questions 2 and 5:

File Attachment:

File Name: limesurvey...7256.lss
File Size:24 KB

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
Last Edit: 1 year 10 months ago by tpartner.
The following user(s) said Thank You: Stan

Please Log in to join the conversation.

More
1 year 10 months ago #129593 by Stan
Stan replied the topic: Multiple question types in array
Waouh! Thanks a lot, tpartner.

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!