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
  • GBMIMM's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 years 6 months ago #220447 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
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 6 months ago #220456 by tpartner
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
  • GBMIMM's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 years 6 months ago #220512 by GBMIMM
Hi Tony, thanks for the response and suggestion. Is there a tutorial available to implement this?
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 6 months ago #220513 by Joffm
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]

 

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 6 months ago #220550 by holch
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.

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
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 6 months ago - 2 years 6 months ago #220569 by DenisChenu
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)}

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.

Lime-years ahead

Online-surveys for every purse and purpose