Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1
  • 2

TOPIC: Require multiple answers of a specific option in an array?

Re: Require multiple answers of a specific option in an array? 2 years 8 months ago #75416

After a bit of testing it seems that these features work in 1.92, but but not 1.91, which is what we are running.

I'm trying to decide between upgrading to 1.92 RC5, using jQuery and 1.91, or worst case, waiting for the 1.92 official.
The administrator has disabled public write access.

Re: Require multiple answers of a specific option in an array? 2 years 8 months ago #75476

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5423
  • Thank you received: 307
  • Karma: 252
Version 1.92 already runs quite stable and there will be an official stable release the next 10-14 days I guess.

Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)limesurvey.org'"
The administrator has disabled public write access.

Re: Require multiple answers of a specific option in an array? 2 years 8 months ago #75504

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4358
  • Thank you received: 826
  • Karma: 381
malberghini, if you can attach a sample survey with the array question I can give you a JavaScript snippet to "default all answers to C, then require them to pick A for a minimum of two subquestions before it will let them continue."
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Re: Require multiple answers of a specific option in an array? 2 years 8 months ago #75549

That would be very much appreciated. Thanks.

www2.isye.gatech.edu/limesurvey/index.ph...54&newtest=Y&lang=en has the basic setup I'm using.

I need to figure out how to use jQuery to set columns in an array in general. I expect as soon as I post this survey, I'll have users asking for buttons that auto select everything in any specific column.
The administrator has disabled public write access.

Re: Require multiple answers of a specific option in an array? 2 years 8 months ago #75554

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4358
  • Thank you received: 826
  • Karma: 381
Can you please attach that survey (so I don't have to create it to test).
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Re: Require multiple answers of a specific option in an array? 2 years 8 months ago #75556

Here it is.
Attachments:
The administrator has disabled public write access.

Re: Require multiple answers of a specific option in an array? 2 years 8 months ago #75559

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4358
  • Thank you received: 826
  • Karma: 381
Okay, this code will check the last options by default and disable the "Next" button until at least 2 column-1 answers are checked.

Note: This code is for a single array on a page but could be modified for more than one on a page.

Set up your survey to use JavaScript and add this script to the source of the array.
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function() { 
 
 
		// Add some column-specific classes
		$('.array-flexible-row table.question tbody tr').each(function(i, el){
			$('> *', this).each(function(i, el){ 
				$(el).addClass('col-'+i);
			});
		});
 
		// Disable the "Next button if less than 2 checked in the first column
		if($('.col-1 input.radio:checked').length < 2) {
			$('#movenextbtn').attr('disabled', true);
		}
 
		// Default check the last option in each row
		$('.array-flexible-row table.question tbody').each(function(i){
			if($('input.radio:checked', this).length == 0) {
				$('input.radio:last', this).attr('checked', true);
			}
		});
 
		// A listener on the array radios
		$('.array-flexible-row table.question tbody td').click(function(el){
			// A small delay to allow the radio to be checked
			setTimeout(function() {
				// If less than 2 column-1 radios checked disable "Next"
				if($('.col-1 input.radio:checked').length < 2) {
					$('#movenextbtn').attr('disabled', true);
				}
				// If more than 1 column-1 radios checked enable "Next"
				else {
					$('#movenextbtn').attr('disabled', false);
				}
			}, 500); 
		});
	});
 
</script>

Here's your survey back with the script in the source of question 1.

File Attachment:

File Name: limesurvey_survey_92454_TP.lss
File Size: 25 KB
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Re: Require multiple answers of a specific option in an array? 2 years 8 months ago #75671

That worked! Thanks!
The administrator has disabled public write access.

Re: Require multiple answers of a specific option in an array? 2 years 8 months ago #75673

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5423
  • Thank you received: 307
  • Karma: 252
malberghini wrote:
That worked! Thanks!
You're welcome :-)

If our hints have been helpful and you enjoy limesurvey please consider a donation to the team .
We do all this in our free time and you don't have to pay a penny for this software.

Without your help we can't keep this project alive.

Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)limesurvey.org'"
The administrator has disabled public write access.
  • Page:
  • 1
  • 2
Moderators: ITEd
Time to create page: 0.134 seconds
Donation Image