only progressing with correct answers

More
9 years 5 months ago #82558 by zz07
Hi,

I have a survey that asks what people think of a new scheme. To check they understand it I am asking participants multiple choice questions. I want participants to have to give the correct answers in order to progress in the survey.

I searched through the forums and found this:

www.limesurvey.org/en/forum/can-i-do-thi...-stop-from-advancing

This is exactly what I am looking for, but unfortunately I do not know javascript so I am finding it difficult to adapt the syntax.

What should it be for a multiple choice question with 4 answers where 1 and 2 have to be checked and 3 and 4 not checked?

I am using limesurvey 1.92 and XAMPP.

Thank you very much in advance. I know the limesurvey supporters are volunteers, so I very much appreciate the assistance.
The topic has been locked.
More
9 years 5 months ago #82564 by tpartner
Assuming you only have one multiple-options question with 4 answers on the page, this should do the trick.
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function(){
 
		// Set the initial state of the "Next" button
		handleNextButton();
 
		// Click events on the checkboxes
		$('input.checkbox').click(function(){
			handleNextButton();
		});
 
		// A function to set the state of the "Next" button depending on checked boxes
		function handleNextButton() {
			var box0 = $('input.checkbox:eq(0)').attr('checked');
			var box1 = $('input.checkbox:eq(1)').attr('checked');
			var box2 = $('input.checkbox:eq(2)').attr('checked');
			var box3 = $('input.checkbox:eq(3)').attr('checked');
 
			if(box0 == true && box1 == true && box2 == false && box3 == false) {
				$('#movesubmitbtn, #movenextbtn').attr('disabled', false);
			}
			else {
				$('#movesubmitbtn, #movenextbtn').attr('disabled', true);
			}
		}
	});
 
</script>

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
More
9 years 5 months ago #82566 by zz07
Thank you.

I will try it. I have other multiple choice questions, but I now I know the syntax I should be able to adapt it.

Thanks again.
The topic has been locked.
More
9 years 5 months ago #82575 by Mazi
If you are still having problems, always attach a sample file so we can check the details.

Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com
Want to use your survey offline -> www.offlinesurveys.com
The topic has been locked.
More
9 years 5 months ago #82590 by zz07
Hi

I tried the code, but it doesn't seem to work.

I have attached some of the question sets in the survey I am working on.

The correct answer(s) to the question named:
cc1b (in group 'commitment contracts 1(b)') is 'Someone who is willing to pay £50 at the start.'

cc1c (in group 'commitment contracts 1(c)') are 'Additional payments can be paid by direct debit.' and 'Additional payments can be paid by bank transfer.' and 'A direct debit can be changed or cancelled at any time.'

cc1d (in group 'commitment contracts 1(d)') are 'We will check you haven't been smoking using a breath test.' and 'You can have a breath test at your local pharmacy.'

cc1e (in group 'commitment contracts 1(e)') are 'A participant passes all six tests. She gets back what she paid in plus her share of what others lost.' and 'A participant passes four tests but fails two. She loses everything she has contributed.'

cc1f (in group 'commitment contracts 1(f)') do not have any correct answers.


Two things:

Although I have included so many question sets in the sample survey, I would appreciate it if you could take a look at cc1b and cc1c (since these are different question types). I can adapt the syntax for the other questions.

Secondly, currently the relevance equations for each group are set to only show if the participant gets the previous questions correct. I did this based on the original specifications of the survey, but realise that once the javascript is sorted I can remove these.

thanks for your help.
Attachments:
The topic has been locked.
More
9 years 5 months ago #82653 by tpartner
I didn't find any JavaScript in the survey but here it is with scripts in the first two groups.

File Attachment:

File Name: limesurvey...5_TP.lss
File Size:56 KB

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
The topic has been locked.
More
9 years 5 months ago #82656 by zz07
Thank you very much.
The topic has been locked.
More
9 years 5 months ago #82700 by Mazi

Thank you very much.

You're welcome :-)

If our hints have been helpful and you enjoy limesurvey please consider a donation to give Limesurvey a future .
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
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com
Want to use your survey offline -> www.offlinesurveys.com
The topic has been locked.

Start now!

Just create your account and start using Limesurvey today.

Register now