Notifying a user if he didn't answer a a non-mandatory question

Más
7 años 10 meses antes #76801 por davidspivak
Hi,
Is there a way to notify someone that he didn't answer a non-mandatory question?
I want to do this because some participants might skip a question unintentionally, and not necessarily because it was non-mandatory.

Thanks!
David

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

LimeSurvey Partners
Más
7 años 10 meses antes #76802 por tpartner
You can use JavaScript to do this.

What question type is it?

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Official LimeSurvey Partner - partnersurveys.com

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Más
7 años 10 meses antes #76804 por davidspivak
Array with 5 sub-questions.

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Más
7 años 10 meses antes #76805 por tpartner
So, you want to warn if they skip any row in the array or just if they skip the whole array?

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Official LimeSurvey Partner - partnersurveys.com

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Más
7 años 10 meses antes - 7 años 10 meses antes #76806 por davidspivak
I was thinking about warning them if they skipped any row in the array, but it would be great to have the code for skipping a whole question as well for future use (if they unintentionally skip a yes/no question, for example).

Thanks!

EDIT: i'd like the message to say something like: "You did not answer question {QUESTION-NUMBER}. Are you sure you don't want to answer that question?"

Or for a specific subquestion in an array: "You did not answer subquestion {SUBQUESTION_NUMBER} in question {QUESTION-NUMBER}. Are you sure you don't want to answer that subquestion?"
Última Edición: 7 años 10 meses antes por davidspivak. Razón: more info

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Más
7 años 10 meses antes #76807 por tpartner
1) Set up your survey to use JavaScript .

2) Add the following script to the source of the array. Replace "QQ" with the array question ID .

The script interrupts the Next/Submit process and if an unanswered row is found in the array, the respondent is asked if they would like to continue. This script is for array questions but could be modified for radio questions.
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function() {
 
		checkArray(QQ, 'You did not answer the question. Do you really want to continue?')
 
		function checkArray(qID, msg) {
 
			// Interrupt next/submit function 
			$('#movenextbtn, #movesubmitbtn').click(function(){
 
				var failTest = '';
 
				$('#question'+qID+' tbody[id^="javatbd"]').each(function(i) {
					if($('input.radio:checked', this).length < 1) {
						failTest = 1;
						$('th, td', this).css({'background':'pink'});
					}
					else {
						$('th, td', this).css({'background':''});
					}
				});
				if(failTest == 1) {
					if(confirm(msg)) {
						return true;
					}
					else {
						return false;
					}
				}
			});
		}
 
	});
 
</script>

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Official LimeSurvey Partner - partnersurveys.com

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Más
7 años 10 meses antes #76812 por davidspivak
Thanks so much, worked like a charm!

I noticed it highlights the unanswered question in pink, but is it also possible to make the pop-up message say which question was left unanswered?

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Más
7 años 10 meses antes #76815 por tpartner

...but is it also possible to make the pop-up message say which question was left unanswered?

Yes, you can just modify the message in the function call:
checkArray(QQ, 'You did not answer question 4. Do you really want to continue?');

Oops, just noticed a possible bug in 1.92...use this instead:
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function() {
 
		checkArray(QQ, 'You did not answer the question. Do you really want to continue?');
 
		function checkArray(qID, msg) {
 
			// Interrupt next/submit function 
			$('#movenextbtn, #movesubmitbtn').click(function(){
 
				var failTest = '';
 
				$('#question'+qID+' tbody[id^="javatbd"]').each(function(i) {
					if($('input.radio:checked', this).length < 1) {
						failTest = 1;
						$('th, td', this).css({ 'background':'pink' });
					}
					else {
						$('th, td', this).css({ 'background':'' });
					}
				});
				if(failTest == 1) {
					if(confirm(msg)) {
						return true;
					}
					else {
						return false;
					}
				}
			});
		}
 
	});
 
</script>

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Official LimeSurvey Partner - partnersurveys.com

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Más
7 años 10 meses antes #76816 por davidspivak
I see, Thanks!

Is it possible to insert such a piece of code into the template instead of putting it in each question, so that the survey automatically checks for unanswered questions in each page and then notifies the participant about it?

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Más
7 años 10 meses antes #76844 por DenisChenu
Hello,

For pseudo non-mandatory question, i use a lot:
- Add a 'I don't want to answer' answer
- Set to mandatory

:)

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 .
An error happen ? Before make a new topic : remind the Debug mode .

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Más
7 años 10 meses antes #76861 por tpartner

Is it possible to insert such a piece of code into the template instead of putting it in each question...

Yes, you can put this in template.js but if you want to check every question in the survey, you will need different code for every question type and search for those types on every page.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Official LimeSurvey Partner - partnersurveys.com

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Más
1 mes 2 semanas antes #191806 por kwalker
I am trying to use this script with LS 2.54, but it isn't working. I am assuming it will need to be updated? Would someone be able to help with this?

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Más
1 mes 2 semanas antes #191829 por tpartner
This will work in 2.x versions:

<script type="text/javascript" charset="utf-8">
 
	$(document).on('ready pjax:scriptcomplete',function(){
 
		checkArray('{QID}', 'You did not answer the question. Do you really want to continue?');
 
		function checkArray(qID, msg) {
 
			// Interrupt next/submit function 
			$('#movenextbtn, #movesubmitbtn').on('click', function(){
 
				var failTest = '';
 
				$('#question'+qID+' tr[id^="javatbd"]').each(function(i) {
					if($('input:radio:checked', this).length < 1) {
						failTest = 1;
						$('>', this).css('background-color', '#E74C3C');
					}
					else {
						$('>', this).css('background-color', '');
					}
				});
				if(failTest == 1) {
					if(confirm(msg)) {
						return true;
					}
					else {
						return false;
					}
				}
			});
 
			$('#question'+qID+' input:radio').on('click', function(){
				$(this).closest('tr').find('th, td');.css('background-color', '');
			});
		}
 
    });
</script>

Sample survey attached:

Archivo Adjunto:

Nombre del Archivo: limesurvey...2-06.lss
Tamaño del Archivo:18 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
Adjuntos:

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Más
1 mes 2 semanas antes #191830 por tpartner
And, for the record, this will work in 3.x:

<script type="text/javascript" charset="utf-8">
 
	$(document).on('ready pjax:scriptcomplete',function(){
 
		checkArray('{QID}', 'You did not answer the question. Do you really want to continue?');
 
		function checkArray(qID, msg) {
 
			// Interrupt next/submit function 
			$('#ls-button-submit').on('click', function(){
 
				var failTest = '';
 
				$('#question'+qID+' tr[id^="javatbd"]').each(function(i) {
					if($('input:radio:checked', this).length < 1) {
						failTest = 1;
						$(this).addClass('has-error');
					}
					else {
						$(this).removeClass('has-error');
					}
				});
				if(failTest == 1) {
					if(confirm(msg)) {
						return true;
					}
					else {
						return false;
					}
				}
			});
 
			$('#question'+qID+' input:radio').on('click', function(){
				$(this).closest('tr').removeClass('has-error');
			});
		}
 
    });
</script>

Sample survey attached:

Archivo Adjunto:

Nombre del Archivo: limesurvey...2-06.lss
Tamaño del Archivo:21 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
Adjuntos:

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Más
1 mes 2 semanas antes #191832 por kwalker
Thanks so much, Tony! This is very helpful.

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

¡Comenzar ahora!

Simplemente cree una cuenta y comience a usar LimeSurvey hoy mismo.

Registrarse ahora
¡Únase a nuestro boletín informativo!

Iniciar sesión