add button in a popup for mandatory questions

More
3 years 10 months ago - 3 years 10 months ago #147675 by KompetenzZ
Hello,

I would like to use a the setting "Mandatory: On" and adding a button into the popup notification when the mandatory question has not been answered. See the picture in the attachment :)

Thank you in advance

Cheers kompetenzz
Attachments:
Last edit: 3 years 10 months ago by KompetenzZ.
The topic has been locked.
LimeSurvey Partners
More
3 years 10 months ago #147684 by tpartner
You won't be able to do that if using the "mandatory" setting because there is no way to advance the survey without answering the question(s).

With non-mandatory questions you could insert a script to interrupt the "Next" button action, detect if certain questions are unanswered and, if so, pop up a modal asking whether you are sure you want to continue.

The details of that script would vary depending on the question types.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Official LimeSurvey Partner - partnersurveys.com
The topic has been locked.
More
3 years 10 months ago #147729 by DenisChenu
Alternative solution : framagit.org/SondagePro-LimeSurvey-plugin/checkboxForText

This add a checkbox for 'text' question type with 'I don't want to answer' (for example) . Tested and working on 2.55 and up.

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 , plugin development . I don't answer to private message.
The topic has been locked.
More
3 years 10 months ago #147817 by KompetenzZ
I would like to add this "Proceed anyway button" to the following question types (see attachment):
  • Multiple choice
  • List (radio)
  • Numerical input

Thank you

Cheers kompetenzz
Attachments:
The topic has been locked.
More
3 years 10 months ago #147825 by tpartner
I obviously can't give examples for all combinations of questions but the following example will test to see if all questions have been answered in a group containing:
- a single multiple-choice
- a single list-radio
- a single numeric

Set up your survey to use JavaScript and place a script like this in the source of one of the questions:

<script type="text/javascript" charset="utf-8">
	$(document).ready(function() {
 
		// Insert the modal elements
        $('body').append('<div id="submit-alert" class="modal fade">\
							<div class="modal-dialog">\
								<div class="modal-content">\
									<div class="modal-header" style="min-height:40px;">\
										<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>\
										<h4 class="modal-title"></h4>\
									</div>\
									<div class="modal-body">\
										<p>You have not answered all questions!</p>\
									</div>\
									<div class="modal-footer">\
										<a href="#" class="btn btn-default proceed">Proceed Anyway</a>\
										<a href="#" data-dismiss="modal" class="btn btn-default">Close</a>\
									</div>\
								</div>\
							</div>\
						</div>');
 
		// Listener on the modal "Proceed" button
		$('#submit-alert a.proceed').on('click', function(e) {
			e.preventDefault();
			$('#movenextbtn').prop('disabled', false).removeClass('disabled active').trigger('click');
		});
 
		// Listener on the "Next" button
        $('#movenextbtn').on('click', function(e) {
			// Conditions when to show the modal pop-up
			// In this example, show the modal IF:
			// 		The modal pop-up is not currently shown
			//		AND
			//		(
			// 			Q1 (multi-choice) has less than one checked item
			//			OR
			// 			Q2 (list-radio) is unanswered
			//			OR
			// 			Q3 (numeric) is unanswered
			//		)
			if(!$('#submit-alert').is(':visible') && ($('.multiple-opt:eq(0) input[type="checkbox"]:checked').length == 0 || $('.list-radio:eq(0) input[type="radio"]:checked').length == 0 || $('.numeric:eq(0) input[type="text"]:eq(0)').val() == '')) {
				e.preventDefault();
				$('#submit-alert').modal('show');
			}
			$('#movenextbtn').prop('disabled', false).removeClass('disabled active');
		});
    });
</script>

Sample survey attached:

File Attachment:

File Name: limesurvey...9892.lss
File Size:26 KB

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Official LimeSurvey Partner - partnersurveys.com
Attachments:
The topic has been locked.
More
3 years 10 months ago #147831 by jelo
We had this requesting answers vs. enforcing answers before.
www.limesurvey.org/forum/can-i-do-this-w...r-which-you-can-skip

I have opened a feature request for this kind of behavior.
bugs.limesurvey.org/view.php?id=12088

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
More
3 years 10 months ago #147832 by tpartner
Yup, but please note that the workaround in your first link is for 2.06 and probably won't work in 2.5x without modification.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Official LimeSurvey Partner - partnersurveys.com
The topic has been locked.
More
3 years 10 months ago #147837 by jelo

tpartner wrote: Yup, but please note that the workaround in your first link is for 2.06 and probably won't work in 2.5x without modification.

Yepp, still on 2.6.X ;-) Let's see if 3.X will bring a consolidation. Not sure if we can allow you to provide workarounds for three flavors of LS.

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
More
3 years 10 months ago #147838 by tpartner
I'll just have to increase my fees :)

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Official LimeSurvey Partner - partnersurveys.com
The topic has been locked.
More
3 years 10 months ago #147842 by holch

tpartner wrote: I'll just have to increase my fees :)


As long as it is a multiplication of the current fees I think it is totally fine... ;-)

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
The topic has been locked.
More
3 years 10 months ago #147864 by DenisChenu
Hi ,

I really think it's a misconcept to allow some question to be non mandatory if we click on a button.

I think the concept MUST be :
- Add a way to choose 'I don't want to answer' anywhere, i wrote NA after

Here : there are currently multiple solution
-> single choice : just add one Answer NA
-> multiple choice : Add a NA exlusivle option
-> Array : Add a NA answer (each line)

No , the 'hardest'
=> Any question (whole part), code (for the example) : CODE
-> Add a multiple choice after the question CODENA, with only one subquestion NA
-> Add relevance/equation/condition on the first question : CODENA_NA
=> Specific to single text and multiple text
-> Usage of framagit.org/SondagePro-LimeSurvey-plugin/checkboxForText

For this plugin : i must fork it and doing a plugin using only Question advanced settings, but it work, really work. I update it in 3.0 because seems to be easiest to add HTML in answers (unsure on this part ....)

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development . I don't answer to private message.
The topic has been locked.

Start now!

Just create your account and start using Limesurvey today.

Register now