Stop Participant to continue, if entered Code is wrong

More
2 months 2 weeks ago #163350 by DarioSto
DarioSto created the topic: Stop Participant to continue, if entered Code is wrong
Hey there,

I am creating a Limesurvey which should be the second part of a long-term study.
In the first study, every participant had to enter their so-called "Mothercode". This code will enable them to see their results from that first study once again at the beginning of Study #2 (current one).

The problem I'm facing is that if the participant enter a wrong code, they should NOT be able to CONTINUE the study anymore. (Everything else - e.g. presenting the results - works just fine!)

Is it possible to do that with LS? Notice, that there are 750 entered codes in total and that I would not be pleased to create a condition for each one of them! :)

Thanks in Advance!
Dario

Please Log in or Create an account to join the conversation.

More
2 months 2 weeks ago #163351 by tpartner
tpartner replied the topic: Stop Participant to continue, if entered Code is wrong
How are you accessing their previous response data?

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

Please Log in or Create an account to join the conversation.

More
2 months 2 weeks ago #163355 by DarioSto
DarioSto replied the topic: Stop Participant to continue, if entered Code is wrong
Just by a workaround. We copied all the codenames from the 1st survey and pasted them into a question of the 2nd.

Within the Expression Manager (pseudo):
If Code == 'abc123' then resultA

But thats well-working :) I just need something to keep them from advancing in case the code entered is not being found in our collection of Codes.

Thanks again!

Please Log in or Create an account to join the conversation.

More
2 months 2 weeks ago - 2 months 2 weeks ago #163361 by tpartner
tpartner replied the topic: Stop Participant to continue, if entered Code is wrong
There may be some magic way to do it with Expression Manager but it doesn't come to me. An alternative would be to use JavaScript to hide the "Next" button and put a listener on the text input that checks the value against an array of codes.

Something like this in the question source:

<script type="text/javascript" charset="utf-8">
	$(document).ready(function() {
 
		// A list of the "Mothercodes"
		var codes = ['abc123', 'abc124', 'abc125', 'abc126'];
 
		// A function to hide/show the "Next" button
		function handleNext() {
			$('#movenextbtn, #movesubmitbtn').hide();
			if($.inArray($.trim($('#question{QID} input[type="text"]').val()), codes) >= 0) {
				$('#movenextbtn, #movesubmitbtn').show();
			}
		}
 
		// Initial state
		handleNext();
 
		// Listener on the text input
		$('#question{QID} input[type="text"]').on('keyup change', function(i) {
			handleNext();
		});
 
	});
</script>

Sample survey attached:

File Attachment:

File Name: limesurvey...2-01.lss
File Size:14 KB

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
Last Edit: 2 months 2 weeks ago by tpartner.

Please Log in or Create an account to join the conversation.

More
2 months 2 weeks ago #163362 by holch
holch replied the topic: Stop Participant to continue, if entered Code is wrong
But these codes can be found in the javascript code, right? So someone with a little bit more technical background could access this.

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 or Create an account to join the conversation.

More
2 months 2 weeks ago #163363 by tpartner
tpartner replied the topic: Stop Participant to continue, if entered Code is wrong
Yes.

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

Please Log in or Create an account to join the conversation.

More
2 months 2 weeks ago #163368 by rigobertofernandez
rigobertofernandez replied the topic: Stop Participant to continue, if entered Code is wrong
Hello everyone
I ask in this topic to avoid not making a new one.
I need to do something similar to this question

I need to validate if the code entered is already in the response database (lime_sourvey_xxxx) and if it finds it send an alert and restart the survey. The code is the first question in the survey.

I know I need to create a php, but I do not know anything about programming.

If someone could guide me on how to make that code and call it in my survey, I would be very grateful.

Please Log in or Create an account to join the conversation.

More
2 months 2 weeks ago #163372 by holch
holch replied the topic: Stop Participant to continue, if entered Code is wrong
I think creating custom php programming is a little out of the scope of this forum.

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 or Create an account to join the conversation.

More
2 months 2 weeks ago #163376 by rigobertofernandez
rigobertofernandez replied the topic: Stop Participant to continue, if entered Code is wrong
If I already have the php that makes the query to database
how to code and insert the result that query sends me to validate and show the alert message

Please Log in or Create an account to join the conversation.

More
2 months 2 weeks ago #163392 by DarioSto
DarioSto replied the topic: Stop Participant to continue, if entered Code is wrong
Thanks for the code, tpartner. I tried it, but it doesn't work properly though.

I understand that I have to adjust the QID Number, within the 'handleNext()' function and the 'listener', right?
Because the QID of the Input Field, where the 'mothercodes' will be typed in, has the ID number '30156', i thought it has to be something like this (which doesn't work still).

function handleNext() {
$('#movenextbtn, #movesubmitbtn').hide();
if($.inArray($.trim($('#question{30156} input[type="text"]').val()), codes) >= 0) {
$('#movenextbtn, #movesubmitbtn').show();
}
}

.....

// Listener on the text input
$('#question{30156} input[type="text"]').on('keyup change', function(i) {
handleNext();
});


Somehow the page shows no next-button at all no matter the code input. What am I doing wrong here?

thanks for your help!

Please Log in or Create an account to join the conversation.

More
2 months 2 weeks ago #163395 by tpartner
tpartner replied the topic: Stop Participant to continue, if entered Code is wrong
Did you try the attached survey?

Do not modify {QID}, that will automatically pipe in the correct ID.

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

Please Log in or Create an account to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!