Multiple question types in array modifiy

More
4 years 1 month ago #98524 by tpartner
tpartner replied the topic: Multiple question types in array modifiy
Can you activate a test survey for me to see?

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.

  • lsorg
  • lsorg's Avatar
  • Visitor
  • Visitor
4 years 1 month ago #98528 by lsorg
lsorg replied the topic: Multiple question types in array modifiy
Hello tpartner

here is the test link: Link

Thanks for your efforts.

Please Log in to join the conversation.

More
4 years 1 month ago #98529 by tpartner
tpartner replied the topic: Multiple question types in array modifiy
Add this to the end of template.css:
.inlineRow td.questiontext {
	font-weight: normal;
}
 
#inlineWrapper0 td.questiontext {
	font-weight: bold;
}

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.

  • lsorg
  • lsorg's Avatar
  • Visitor
  • Visitor
4 years 1 month ago - 4 years 1 month ago #98553 by lsorg
lsorg replied the topic: Multiple question types in array modifiy
Amazing. Thank you very much. It works perfectly now.

Thanks for your help.

Best regards
lsorg


P.S. Now it is time for me to spend some money for this great project. :)
Last Edit: 4 years 1 month ago by lsorg.

Please Log in to join the conversation.

More
4 years 3 weeks ago #99427 by arpsh
arpsh replied the topic: Multiple question types in array modifiy

tpartner wrote: Ah, I see. The "Multiple question types in array" workaround won't work for you because it's designed for individual questions, not array type or multiple-text type questions.

In your case I think it would be easiest to simply create a new column in your array and insert the "Age" text inputs into it.

Here's your survey back with the array question placed before the multiple-text question. The source of the array question contains the script below


A much belated thank you to tpartner for his gracious help getting an alternate workaround for this scenario, which seems to be working perfectly. Your assistance is greatly appreciated, even if it took me a few months to realise I hadn't actually posted a response .... :blush:

Please Log in to join the conversation.

More
3 years 10 months ago #101409 by dh_ffm
dh_ffm replied the topic: Multiple question types in array - how to adopt for template blueandgrey?
Hello -

I successfully adopted the 'multiple questions in array' example ( manual.limesurvey.org/images/5/59/Limesurvey_survey_62584.lss ) for my purposes and it worked great - as Long as I used the Default template.

However, we are working with a template which is based on blueandgrey. We discovered an entry in this Forum where this issue was discussed and my colleague made several attempts to adjust the code but so far the result is that either None of the questions is displayed or - and this is the case with this latest Version - all questions are not listed side by side in an Array but one after the other (stacked vertically). And it does this now with both templates - Default and blueandgrey.

Any idea how to fix this?

This is what it Looks like at the Moment:
Test Survey multiple question types in array

Here is the code:
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function() { 
 
		// Call the "sideBySide" function with number of rows, columns and start question (?)
		sideBySide(3, 5, 1);   
    });
 
	function sideBySide(rows, columns, startQuestion) {
 
		/*********** 
		Display multiple questions side by side
		***********/
 
		if ($('div.qRow1').length == 0) {
 
			var rowNum = 0;
			var colNum = 1;
			var rowList = new Array(); 
 
			//////// Add question classes for later use ////////
 
			// Loop through all questions and add row and column specific classes
			$('div[id^="question"]').each(function(i) {
				if(rowNum <= rows { // This IF condition only needed if there are questions following the "inline" questions
					$(this).addClass('qRow'+rowNum+'').addClass('qCol'+colNum+'').addClass('inlineQuestion');
					if(rowNum == 0 && colNum > 1) {
						$(this).addClass('columnLabel');
					}
					if(rowNum > 0 && colNum == 1) {
						$(this).addClass('rowLabel');
					}
					else if(rowNum > 0 && colNum > 1) {
						$(this).addClass('questionCell');
					}
					if(colNum == columns) {
						rowList.push('qRow'+rowNum+'');
						rowNum++;
						colNum = 1;
					}
					else {
						colNum++;
					}
				}
				else {
					$(this).addClass('normalQuestion');
				}
			}); 
 
			//////// Survey layout manipulation ////////
 
			// Fix the width of the survey
			$('table.container').css({
				'width': '900px'
			});
 
			// Wrap each "row" in a wrapper div
			$(rowList).each(function(i) {
				$('.'+this+'').wrapAll('<div id="inlineWrapper'+i+'" class="inlineRow" />');
			}); 
 
			// Style the wrapper divs
			$('.inlineRow').css({
				'width': '850px',
				'margin': '0 auto 0 auto',
				'clear': 'both'
			});
			$( '.inlineRow:first' ).css({
				'margin-top': '10px'
			});
 
			// Get all the questions to sit politely side by side
			$( '.inlineQuestion' ).css({
				'float': 'left',
				'overflow':'hidden',
				'margin-bottom': '-1px'    
			});
			$( '.inlineQuestion div.question' ).css({
							'padding':'0',
							'height':'41px',
							'margin': '0',
							'border': '0 none',
							'width': '100%'
			});
			$( '.inlineQuestion .questionhelp' ).hide();
			$( '.inlineQuestion .survey-question-help' ).parent().hide();
 
			// A little space under the last row
			$( '.inlineRow:last .inlineQuestion' ).css({
				'margin-bottom': '10px'
			});
 
			// Any questions not displayed inline (this is only needed if there are questions following the "inline" questions)
			$( '.normalQuestion' ).css({
				'clear': 'both'   
			});
 
			//////// Column manipulation ////////
 
			// Set the column widths - can be set individually if necessary
			// Must add up to less than 100%
			$( '.qCol1' ).css({
				'width': '12%'
			});
			$( '.qCol2, .qCol3, .qCol4, .qCol5' ).css({
				'width': '22%'
			});
 
			//////// Question manipulation ////////
 
			// Hide the answer element in boilerplate questions
			$( 'div.boilerplate .answers' ).hide();
 
			// Hide the question text elements in non-boilerplate questions
			$('div.questionCell .questiontext').hide();
 
			// Push the question tables to 100%
			$( 'div.inlineRow table' ).css({
				'width': '100%'
			});
 
			// Get everything to line up nicely vertically
			$( '.inlineQuestion .questiontext, .inlineQuestion .answers p' ).css({
				'text-align': 'center'
			});
 
			// Adjust cell heights so everything lines up nicely horizontally
			$( '.inlineQuestion .answers, .inlineQuestion .questiontext' ).css({
				'height':'35px',
				'overflow':'hidden',
				'padding':'0.5em'
			});
			$( '#inlineWrapper0 .inlineQuestion' ).css({ 'height':'50px' });
			$( '#inlineWrapper0 .questiontext' ).css({
				'height':'50px'
			});
 
			// Yes-no question styles
			$( 'div.yes-no ul' ).css({
				'text-align': 'center',
				'font-size': '90%',
				'margin': '0',
				'padding-bottom': '5px'
			});
			$( 'div.yes-no li' ).css({
				'padding-right': '1.5em'
			});
			$( 'div.yes-no .answers' ).css({
				'padding-bottom': '0'
			});
 
			// Short-text question styles
			$( 'div.text-short input' ).css({
				'width': '125px',
				'margin-left': '0'
			});
 
			// Numeric question styles
			$( 'div.numeric input' ).css({
				'width': '125px',
				'margin-left': '0'
			});
			$( 'div.numeric p.tip' ).css({
				'display': 'none'
			});
 
			// Get rid of the margins around select boxes    
			$( 'p.question' ).css({ 'margin':'0' }); 
 
		}
	}
 
</script>

Please Log in to join the conversation.

More
3 years 10 months ago - 3 years 10 months ago #101486 by tpartner
tpartner replied the topic: Multiple question types in array - how to adopt for template blueandgrey?
You have an typo in your script causing a fatal JavaScript error.

This:
if(rowNum <= rows {

Should be this:
if(rowNum <= rows) {

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last Edit: 3 years 10 months ago by tpartner.

Please Log in to join the conversation.

More
3 years 10 months ago #101490 by dh_ffm
dh_ffm replied the topic: Multiple question types in array - how to adopt for template blueandgrey?
Oops - Thanks - with this correction the side-by-side function now works with the default template but still not with blueandgrey (it does not Show any of the questions - which was my actual problem).
Greetings
Daniel

Please Log in to join the conversation.

More
3 years 10 months ago #101814 by dh_ffm
dh_ffm replied the topic: Multiple question types in array - how to adopt for template blueandgrey?

tpartner wrote: You have an typo in your script causing a fatal JavaScript error.

This:

if(rowNum <= rows {

Should be this:
if(rowNum <= rows) {


Again: Thank you for this correction of the script; however, this still does not resolve my original problem that the side-by-side function works with the Default template but does not work with the Blueandgrey template (none of the questions that I want to arrange in an array shoes up). I would be really happy about ideas how to fix this.
Greetings -
Daniel

Please Log in to join the conversation.

More
3 years 9 months ago - 3 years 9 months ago #102440 by MikeConom
MikeConom replied the topic: Multiple question types in array modifiy
Hi
I tried to use this question with function sidebyside with the Template: limespired, but is not working.
Have you a solution how can i do it?

Thanks
Last Edit: 3 years 9 months ago by MikeConom.

Please Log in to join the conversation.

More
3 years 8 months ago #103235 by Mazi
Mazi replied the topic: Multiple question types in array modifiy
"Not working" is not a very helpful error description. Please always post a link to an activated Demo survey so we can have a look at the HTML source code.


Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"

Please Log in to join the conversation.

More
3 years 8 months ago #103237 by MikeConom
MikeConom replied the topic: Multiple question types in array modifiy
Mazi

yes it was mistake becuse i didnt give more informations about this.
Now i am not working with the side by side
when i test it again i'll sent more informations

Thanks and happy new year

Please Log in to join the conversation.

More
3 years 6 months ago #106599 by quadrellis
quadrellis replied the topic: Multiple question types in array modifiy
Hi Tpartner et al,

Thanks for your code that allows the addition of a textbox adjacent to a yes no array.

Is it possible to put the text input box in the last column ther the two Yes/No array columns ?

Cheers,

Scott

Please Log in to join the conversation.

More
3 years 4 months ago - 3 years 4 months ago #108198 by Erwinx2
Erwinx2 replied the topic: Multiple question types in array modifiy



Hello,

I have made some JavaScript modifications. It allows to merge elements of two questions into one question. If you can read JavaScript you can easily adapt it. The code should be resist in template.js of your LimeSurvey-template:

 function pslSurvey(idStr,idStr1) 
{
	var $removed = $('#'+idStr).children().eq(0).remove();
	var $content = $('#'+idStr).html();
	$('#'+idStr1).append($content);
	return;
}
 
$(document).ready(function(){
	//return;
	var $myTr    = $('#javatbd969997X11X168SQ001');
	if ( $myTr.length){
		pslSurvey('javatbd969997X11X184SQ001','javatbd969997X11X168SQ001');
		$('#javatbd969997X11X168SQ001').parents().eq(1).children().eq(1).children().eq(0).append('<th class=\"answertext\">männlich</th>');
		$('#javatbd969997X11X168SQ001').parents().eq(1).children().eq(1).children().eq(0).append('<th class=\"answertext\">weiblich</th>');
		pslSurvey('javatbd969997X11X184SQ002','javatbd969997X11X168SQ002');
		pslSurvey('javatbd969997X11X184SQ003','javatbd969997X11X168SQ003');
		pslSurvey('javatbd969997X11X184SQ004','javatbd969997X11X168SQ004');
		pslSurvey('javatbd969997X11X184SQ005','javatbd969997X11X168SQ005');
		pslSurvey('javatbd969997X11X184SQ006','javatbd969997X11X168SQ006');
		$('#question184').empty();
	}
    //console.log($debug);
});


What it does:

  • remove unnecessary column
  • grab content from the second question
  • put content to the first question
  • extentend labels/column header of the first question
  • remove the second question
  • [/b]





    PS: If you can't read JavaScript, I might help... NO ADVERTISING!
    Attachments:
    Last Edit: 3 years 4 months ago by tpartner.

    Please Log in to join the conversation.

    More
    2 years 7 months ago #116656 by Mazi
    Mazi replied the topic: Multiple question types in array modifiy
    Erwinx2, which template did you use for your modifications?


    Best regards/Beste Grüße,
    Dr. Marcel Minke
    (Limesurvey Head of Support)
    Need Help? We offer professional Limesurvey support
    Contact: marcel.minke(at)survey-consulting.com'"

    Please Log in to join the conversation.

    Start now!

    Just create your account and start using Limesurvey today.

    Register now