add button in a popup for mandatory questions

More
9 months 3 weeks ago - 9 months 3 weeks ago #147675 by KompetenzZ
KompetenzZ created the topic: add button in a popup for mandatory questions
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
Attachments:
Last Edit: 9 months 3 weeks ago by KompetenzZ.

Please Log in to join the conversation.

More
9 months 3 weeks ago #147684 by tpartner
tpartner replied the topic: add button in a popup for mandatory questions
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.

Please Log in to join the conversation.

More
9 months 3 weeks ago #147729 by DenisChenu
DenisChenu replied the topic: add button in a popup for mandatory questions
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 (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in to join the conversation.

More
9 months 3 weeks ago #147817 by KompetenzZ
KompetenzZ replied the topic: add button in a popup for mandatory questions
I would like to add this "Proceed anyway button" to the following question types (see attachment):
  • Multiple choice
  • List (radio)
  • Numerical input

Thank you
Attachments:

Please Log in to join the conversation.

More
9 months 3 weeks ago #147825 by tpartner
tpartner replied the topic: add button in a popup for mandatory questions
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.
Attachments:

Please Log in to join the conversation.

More
9 months 3 weeks ago #147831 by jelo
jelo replied the topic: add button in a popup for mandatory questions
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

Please Log in to join the conversation.

More
9 months 3 weeks ago #147832 by tpartner
tpartner replied the topic: add button in a popup for mandatory questions
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.

Please Log in to join the conversation.

More
9 months 3 weeks ago #147837 by jelo
jelo replied the topic: add button in a popup for mandatory questions

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.

Please Log in to join the conversation.

More
9 months 3 weeks ago #147838 by tpartner
tpartner replied the topic: add button in a popup for mandatory questions
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.

Please Log in to join the conversation.

More
9 months 3 weeks ago #147842 by holch
holch replied the topic: add button in a popup for mandatory questions

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'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
9 months 3 weeks ago #147864 by DenisChenu
DenisChenu replied the topic: add button in a popup for mandatory questions
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 (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!