Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

How to create a custom PIN number on End Message/question

  • RitaShen
  • RitaShen's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
5 years 7 months ago - 5 years 7 months ago #173686 by RitaShen
Hi there,

I have a question type, but I have no idea does it can work on LimeSurvey.

How to create a custom PIN number on End Message or in the question, each respondents will see their own unique PIN number. 100 respondents will have 100 unique PIN number.

how could I do this on the limesurvey?

Many thanks
Rita
Last edit: 5 years 7 months ago by RitaShen.
The topic has been locked.
More
5 years 7 months ago #173688 by jelo
What purpose has the PIN?
What format is needed?

You could use the respondent ID {SAVEID} and combine that ID (which is too easy to guess when used as PIN) with randomnumbers.

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
  • RitaShen
  • RitaShen's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
5 years 7 months ago #173690 by RitaShen
it's the coupon PIN
every one will have specify PIN number
they can use this PIN number to buy something.
as the Respondents finish the survey, they can will see their own PIN number on the END PAGE or in next page.

e.g.
Respondent A will see this PIN number : G12A35
Respondent B will see this PIN number : Z1553w
Respondent C will see this PIN number : O82aw7
The topic has been locked.
More
5 years 7 months ago #173715 by DB1324
I'm looking to do the exact same thing - we use multiple systems, and want to generate a not-immediately-predictable PIN to be entered into our other programmes to ensure participant records aren't mixed up.

RitaShen - I would be interested to hear if you are successful with this.
The topic has been locked.
More
5 years 7 months ago #173716 by jelo
If respondent get the URL with a token, you can create the PIN as an additional attribute and assign a unpredictable PIN to every token.
Since the PIN should be check in other systems, when respondents enter them, you can work with precreated PINs.

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 7 months ago #173717 by holch
I think the most important question is:

Can the PIN be created any way you want or do you need to use predefined PINs. Approaches need to be different for both options, I guess.

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.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 7 months ago #173730 by Joffm
Hi,.
If there is a predefined list of numbers, you may use an ajax call to select one.
I am not sure if I provided an example a few weeks ago.
Anyway, I will do it on Thursday when I am back home.
Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 7 months ago #173813 by Joffm
Hi,
here the promised example:
In my survey I have a hidden question of type "short text" with this javascript to do the ajax call:
Code:
<script type="text/javascript" charset="utf-8">
$(document).on('ready pjax:scriptcomplete',function(){
       $.post('https://www.myServerr.com/myFolder/getCode.php',function(data) {
 
                   $('#question{QID} input[type="text"]').val(data)
 
  });
        $('#question{QID}').hide();
);
</script>

In my database I created a table "voucher" with three fields:
1. id (autoincrement)
2. vouchercode (varchar(20))
3. status (Tinyint) This as flag, if the code was already used


And now the php file "getCode.php"
(only as example, depends on your way of connecting and library (mysqli, PDO, ...)
1. Connect to the database
2. query the table:
"SELECT vouchercode from voucher WHERE status=0 limit 1" (So you get always only one row with the first not used vouchercode)
3, Save the vouchercode to $myCode=
4. Update the table; set the status of this vouchercode to "used" =1)
"UPDATE voucher SET status=1 WHERE vouchercode=$myCode";

5. echo the vouchercode
echo $myCode;


which is really the next one in the database.

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: tpartner
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose