Dual Scale Array, getting rid of one side for one question

More
2 years 5 months ago #121992 by rickyd
rickyd created the topic: Dual Scale Array, getting rid of one side for one question
Hello,

I'm trying to create a dual scale array question with many similar subquestions. For one subquestion, however, I'd like to get rid of the first scale's radio buttons and only have radio buttons in the second. I could just create another question, however for the sake of the look of the survey I'd rather have everything all together in one question. Is this something that is possible? Thank you.

Please Log in to join the conversation.

More
2 years 5 months ago - 2 years 5 months ago #122018 by tpartner
tpartner replied the topic: Dual Scale Array, getting rid of one side for one question
Set up your survey to use JavaScript and add something like this to the source of the question (modify rowNumber as required):

<script type="text/javascript" charset="utf-8">	
	$(document).ready(function() {		
 
		// The row to hide
		var rowNumber = 2;
 
		// Identify some elements
		var thisQuestion = $('#question{QID}');
		var hiddenRow = $('tr.radio-list:eq('+(rowNumber-1)+')', thisQuestion);
 
		// Assign column-specific classes
		$('tr.radio-list', thisQuestion).each(function(i){
			var column = 1;
			var scale = 1;
			$('td', this).each(function(i){
				if($(this).hasClass('radio-item')) {
					$(this).addClass('scale-'+scale+' column-'+column+'');
					column++;
				}
				else {
					column = 1;
					scale = 2;
				}
			});
		});
 
		// Click the first radio in the hidden row (in case of mandatory)
		$('.column-1.scale-1 input.radio', hiddenRow).trigger('click');
 
		// Hide the radios
		$('.scale-1 input.radio', hiddenRow).hide();
 
    });
</script>

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

Please Log in to join the conversation.

More
2 months 2 weeks ago #158943 by DerBibber17
DerBibber17 replied the topic: Dual Scale Array, getting rid of one side for one question
Hey!
I have a similar question. I want some of the subquestions in my arrays (numbers with checkboxes) or multiple choice questions only to be category separators (like it is possible to choose for list dropdown). As far as I can see limesurvey is not offering category separators in arrays or multiple choice questions.

So my idea would be to hide the checkboxes (of an array) or the radio buttons (of a multiple choice) in the rows that should only be headers for the following subquestions.
My JavaScript skills are kind of limited, so I would be grateful for some help.

Please Log in to join the conversation.

More
2 months 2 weeks ago #159001 by Joffm
Joffm replied the topic: Dual Scale Array, getting rid of one side for one question

I want some of the subquestions in my arrays (numbers with checkboxes) or multiple choice questions only to be category separators


For multiple choice maybe this helps (Tony's script).
https://www.limesurvey.org/forum/can-i-do-this-with-limesurvey/107425-headline-in-multiple-choice

Regards
Joffm
The following user(s) said Thank You: DerBibber17

Please Log in to join the conversation.

More
2 months 2 weeks ago - 2 months 2 weeks ago #159010 by tpartner
tpartner replied the topic: Dual Scale Array, getting rid of one side for one question
Regarding arrays, rather than hiding check-boxes, I would insert new sub-header rows. Something like this - www.limesurvey.org/forum/design-issues/1...-one-question#155220

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

Please Log in to join the conversation.

More
2 months 2 weeks ago #159011 by tpartner
tpartner replied the topic: Dual Scale Array, getting rid of one side for one question
...here is that JavaScript, modified slightly for array-numbers-checkboxes:

<script type="text/javascript" charset="utf-8">		
	$(document).ready(function() {	
 
		// Identify this question
		var thisQuestion = $('#question{QID}');
 
		// Define the sub-heading text strings
		var subHeading1 = 'Subheading 1';
		var subHeading2 = 'Subheading 2';
 
		var columnsLength = $('tr.subquestion-list:eq(0) > *', thisQuestion).length;
 
		// Insert the new rows
		$('tr.subquestion-list:eq(0)', thisQuestion).before('<tr class="sub-header-row"><th colspan="'+columnsLength+'">'+subHeading1+'</th></tr>');
		$('tr.subquestion-list:eq(2)', thisQuestion).before('<tr class="sub-header-row"><th colspan="'+columnsLength+'">'+subHeading2+'</th></tr>');	
 
		// Fix up the row classes
		var rowClass = 1;
		$('table.subquestion-list tbody tr', thisQuestion).each(function(i) {
			if($(this).hasClass('sub-header-row')) {
				rowClass = 1
			}
			else {
				rowClass++;
				$(this).removeClass('array1 array2')
				if(rowClass % 2 == 0) {
					$(this).addClass('array2');
				}
				else {
					$(this).addClass('array1');
				}
			}
		});
	});
</script>

And, the CSS:
.sub-header-row {
	margin-bottom: 20px;
}
 
 
.sub-header-row th {
	background-color: #547599;
	color: #FFFFFF !important;
	text-align: center;
}


Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:

Please Log in to join the conversation.

More
2 months 2 weeks ago #159053 by DerBibber17
DerBibber17 replied the topic: Dual Scale Array, getting rid of one side for one question
Thank you for the script :) Unfortunately it's not working. I inserted the script into the source of the question but nothing happens. I also tried some other things (like adding an "other"-option with textfield to some of my question), but nothing is working.
So i was wondering, if the problem is that I'm using limesurvey via my University which is offering only the german limesurvey version while the scripts are in english. Could this be part of the problem?

Please Log in to join the conversation.

More
2 months 2 weeks ago #159055 by tpartner
tpartner replied the topic: Dual Scale Array, getting rid of one side for one question
The script language does not matter.

See here for instructions on how to insert scripts - manual.limesurvey.org/Workarounds:_Manip...tc..29_in_LimeSurvey

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
2 months 1 week ago #159107 by DerBibber17
DerBibber17 replied the topic: Dual Scale Array, getting rid of one side for one question
Ok so I don't know why it's not working.
Do I have to change something in the script when I'm using it in my question (except the Subheadings)?

Please Log in to join the conversation.

More
2 months 1 week ago #159110 by tpartner
tpartner replied the topic: Dual Scale Array, getting rid of one side for one question
Can you activate a test survey and give a link here?

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
2 months 1 week ago #159155 by DerBibber17
DerBibber17 replied the topic: Dual Scale Array, getting rid of one side for one question
In the meanwhile I got a new problem. I couldn't activate my survey because I've got to many subquestions in it. So here's a link to just one question group of my survey.
In this group are for example 3 questions in which I would like to use sub-headers. One question with multiple numerical input and two arrays (I already changed the multiflex arrays so I dont need sub-headers in them anymore). The bold subquestion you see now should be only subheaders.
Thank you so much!

survey.tugraz.at/index.php/survey/index/...65/newtest/Y/lang/de

Please Log in to join the conversation.

More
2 months 1 week ago - 2 months 1 week ago #159156 by Joffm
Joffm replied the topic: Dual Scale Array, getting rid of one side for one question
Hello, Bibber,

Do I have to change something in the script when I'm using it in my question (except the Subheadings)?

You have to change this:
// Define the sub-heading text strings
		var subHeading1 = 'Subheading 1';
		var subHeading2 = 'Subheading 2';
		var subHeading3 = 'My third subheading';
and this (where does the subheading appear):
// Insert the new rows
		$('tr.subquestion-list:eq(0)', thisQuestion).before('<tr class="sub-header-row"><th colspan="'+columnsLength+'">'+subHeading1+'</th></tr>');
		$('tr.subquestion-list:eq(2)', thisQuestion).before('<tr class="sub-header-row"><th colspan="'+columnsLength+'">'+subHeading2+'</th></tr>');	
		$('tr.subquestion-list:eq(5)', thisQuestion).before('<tr class="sub-header-row"><th colspan="'+columnsLength+'">'+My third subHeading+'</th></tr>');

I got this result:



And this for your "normal" matrix (without any css to style the header row)


sample file attached

In the meanwhile I got a new problem. I couldn't activate my survey because I've got to many subquestions in it.

Well, that's something different. So either you try to shorten your survey or you have to split it.

Best regards
Joffm
Attachments:
Last Edit: 2 months 1 week ago by Joffm.
The following user(s) said Thank You: tpartner, DerBibber17

Please Log in to join the conversation.

More
2 months 1 week ago #159172 by DerBibber17
DerBibber17 replied the topic: Dual Scale Array, getting rid of one side for one question
Thank you so much, I would hug you if I could :) Finally something worked!

May I ask another question? I would also like to add a row with an "other"-option and a short textfield to some questions (arrays and multiflex arrays). Is that possible?

Please Log in to join the conversation.

More
2 months 1 week ago #159173 by Joffm
Joffm replied the topic: Dual Scale Array, getting rid of one side for one question
Hello, Bibber,
please do not add new question to a topic.

Open a new thread. It is easier for other users to find something.
How often do we read "I searched, but didn't find."

Okay,
Depends on the structure of your survey: (all on one page, group by group or question by question)

I did these in my last survey like this.
Though it is asked question by question I did it "group by group" (each group one question)

Only in this group I placed the array and underneath the question with the "Other"

Like this:


You know, I prefer the "out of the box" solutions, because most of the time there is no time to wait for an answer in the forum, though this forum is one of the best in quality and response time.

Joffm

Please Log in to join the conversation.

More
2 months 1 week ago #159174 by DerBibber17
DerBibber17 replied the topic: Dual Scale Array, getting rid of one side for one question
Of course, you're right :)
I'm going to ask this question in a new thread. My structure is question by question, so the solutions a I found dont work.

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!