- Posts: 11
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Generate a random number code on survey end page
- GBMIMM
- Topic Author
- Offline
- New Member
Less
More
2 years 6 months ago #220447
by GBMIMM
Generate a random number code on survey end page was created by GBMIMM
Hi all, I'd like to end my survey by giving participants a unique survey completion code (a non-repeating 5 digit number) that appears on the final page of the survey.
Ideally, I'd like to be able to save these codes myself as participants would need it in order to withdraw from the study.
Can someone advise me how to implement this?
Best,
GM
Ideally, I'd like to be able to save these codes myself as participants would need it in order to withdraw from the study.
Can someone advise me how to implement this?
Best,
GM
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10099
- Thank you received: 3589
2 years 6 months ago #220456
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 Generate a random number code on survey end page
Why not use the response ID?
Code:
{SAVEDID}
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: DenisChenu, holch
The topic has been locked.
- GBMIMM
- Topic Author
- Offline
- New Member
Less
More
- Posts: 11
- Thank you received: 0
2 years 6 months ago #220512
by GBMIMM
Replied by GBMIMM on topic Generate a random number code on survey end page
Hi Tony, thanks for the response and suggestion. Is there a tutorial available to implement this?
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12888
- Thank you received: 3965
2 years 6 months ago #220513
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Generate a random number code on survey end page
Hi,
there is nothing to implement.
This {SAVEDID} gives you the ID of the response in the answer table.
It is an autoincrement number - starting with 1.
Try it yourself.
Create a small survey, activate it, enter some responses and have a look at the answer table.
To see this ID, just enter the placeholder {SAVEDID} in the question text of one of your questions.
Probably you do not want to display a "00001" to the first respondent, you may "hide" it.
Maybe by adding a constant number like {sum(18300,SAVEDID)} or other mathematical transformations.
And you may read the manual here
[url] manual.limesurvey.org/ExpressionScript_-_Presentation [/url]
there is nothing to implement.
This {SAVEDID} gives you the ID of the response in the answer table.
It is an autoincrement number - starting with 1.
Try it yourself.
Create a small survey, activate it, enter some responses and have a look at the answer table.
To see this ID, just enter the placeholder {SAVEDID} in the question text of one of your questions.
Probably you do not want to display a "00001" to the first respondent, you may "hide" it.
Maybe by adding a constant number like {sum(18300,SAVEDID)} or other mathematical transformations.
And you may read the manual here
[url] manual.limesurvey.org/ExpressionScript_-_Presentation [/url]
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11639
- Thank you received: 2737
2 years 6 months ago #220550
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 Generate a random number code on survey end page
As the SAVEID is autoincremental, it might actually be a good idea to add a random part to it, like 3 random digits at the beginning, just to make it look like it is random. You can then ignore those 3 digits to identify the respondent and just use the numbers provided by the SAVEDID, which is always saved in your results table.
Might not be necessary in this specific case, but whenever you can easily "guess" codes, there are people how might use it to their advantage.
Might not be necessary in this specific case, but whenever you can easily "guess" codes, there are people how might use it to their advantage.
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.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13597
- Thank you received: 2487
2 years 6 months ago - 2 years 6 months ago #220569
by DenisChenu
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 .
I don't answer to private message.
Replied by DenisChenu on topic Generate a random number code on survey end page
Really unique ?
To be used as validation ?
gitlab.com/SondagesPro/QuestionSettingsType/generateUniqId
Because a 5 digit code is really bad for validation.
Else with Expression manager : in a equation question{if(is_empty(self.NAOK),rand(10000,99999),self.NAOK)}
To be used as validation ?
gitlab.com/SondagesPro/QuestionSettingsType/generateUniqId
Because a 5 digit code is really bad for validation.
Else with Expression manager : in a equation question{if(is_empty(self.NAOK),rand(10000,99999),self.NAOK)}
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 .
I don't answer to private message.
Last edit: 2 years 6 months ago by DenisChenu. Reason: Em solution
The topic has been locked.