- Posts: 9
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Stop Participant to continue, if entered Code is wrong
- DarioSto
- Topic Author
- Offline
- New Member
Less
More
6 years 1 month ago #163350
by DarioSto
Stop Participant to continue, if entered Code is wrong was created by DarioSto
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
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
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10634
- Thank you received: 3698
6 years 1 month ago #163351
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on 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.
The topic has been locked.
- DarioSto
- Topic Author
- Offline
- New Member
Less
More
- Posts: 9
- Thank you received: 0
6 years 1 month ago #163355
by DarioSto
Replied by DarioSto on 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!
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!
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10634
- Thank you received: 3698
6 years 1 month ago - 6 years 1 month ago #163361
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on 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:
Sample survey attached:
Something like this in the question source:
Code:
<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:
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
Last edit: 6 years 1 month ago by tpartner.
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11758
- Thank you received: 2753
6 years 1 month ago #163362
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on 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 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.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10634
- Thank you received: 3698
6 years 1 month ago #163363
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on 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.
The topic has been locked.
- rigobertofernandez
- Offline
- New Member
Less
More
- Posts: 2
- Thank you received: 0
6 years 1 month ago #163368
by rigobertofernandez
Replied by rigobertofernandez on 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.
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.
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11758
- Thank you received: 2753
6 years 1 month ago #163372
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on 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 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.
- rigobertofernandez
- Offline
- New Member
Less
More
- Posts: 2
- Thank you received: 0
6 years 1 month ago #163376
by rigobertofernandez
Replied by rigobertofernandez on 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
how to code and insert the result that query sends me to validate and show the alert message
The topic has been locked.
- DarioSto
- Topic Author
- Offline
- New Member
Less
More
- Posts: 9
- Thank you received: 0
6 years 1 month ago #163392
by DarioSto
Replied by DarioSto on 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!
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!
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10634
- Thank you received: 3698
6 years 1 month ago #163395
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on 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.
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.
The topic has been locked.