Welcome to the LimeSurvey Community Forum

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

Generate code at the end of survey - for mTurk

More
8 years 11 months ago #128638 by EmE9
Hello,

I would like to use LimeSurvey on mTurk and I need a way to generate a unique code (randomly) in the end message, that would be saved in the survey results preferably. In order to get paid, participants can then type in the code in mTurk and I would know that they have actually finished the survey.

Any help would be appreciated as I have not found good info on this problem

Best,
The topic has been locked.
More
8 years 11 months ago #128639 by Ben_V
Hi ,
there are 2 old great posts about this topic (using differents ways)... here (using Expression Manager) and there (using chance.js)

Benoît

EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
The topic has been locked.
More
8 years 11 months ago #128644 by EmE9
Hi,

thanks a lot. If I could have just a bit of your time since I am a total beginner. I have seen this SAVEDID option but I am not sure to what it relates to. Is this an option that is choosable or is it something that I need to have coded for. Plus, how would this ID be shown to the participants at the end?

All the best,
The topic has been locked.
More
8 years 11 months ago #128646 by Ben_V
"SAVEDID" is the respondant ID. It's a unique number (incremental, start is #1) for a survey but if you have several survey it's not so unique. You can print it at the end using the placeholder {SAVEDID}

Benoît

EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 11 months ago - 8 years 11 months ago #128654 by tpartner
Replied by tpartner on topic Generate code at the end of survey - for mTurk

...but if you have several survey it's not so unique.

You can combine it with the survey ID.

Code:
{SID}{SAVEDID}

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 8 years 11 months ago by tpartner.
The topic has been locked.
More
8 years 11 months ago #128658 by EmE9
Thanks to all.

If anybody else stumbles on this, I've managed to produce a random string of digits using the code already mentioned in one of the linked pages above.

{if(!is_empty(PIN),PIN,1*rand(357382, 908173))}

"PIN" is the name of your question group or just the questions (this can obviously be anything you want to name it). For me, as is per usual in mTurk, it was important to have a six digit number so I just basically said the rand() function to randomise between two six digit numbers (they can also be anything really). Not the most elegant solution but it works.

Hope it helps.
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 11 months ago #128659 by holch
You are aware that the same code could appear more than once, right? Ok, the chance is low, but it is there...

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.
More
8 years 11 months ago #128663 by EmE9
Yes, absolutely, but I'm starting the study in one day, so I'm willing to accept the risk. Plus, the, admittedly low chance of reoccurrence is worth it as I plan on some 100 - 200 participants.

Do you have a way of ensuring that it never repeats?

Best,
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 11 months ago #128665 by tpartner
Replied by tpartner on topic Generate code at the end of survey - for mTurk

Do you have a way of ensuring that it never repeats?

Incorporate the SAVEDID as Ben suggests.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
More
8 years 11 months ago #128666 by Ben_V
The problem with the SAVEDID is it can be 1, 2, 3 (even more) digits, so an advanced equation is required to match the required length...
Using time() & rand () with 6 digits, an option is:
Code:
{if(!is_empty(PIN),PIN,substr(time()*rand() , 3 ,6))}
(IMHO, with 200 participants, the probability of duplicate PIN outputs, may be the same than for of a sudden meteor shower on the server)

Benoît

EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 11 months ago - 8 years 11 months ago #128667 by tpartner
Replied by tpartner on topic Generate code at the end of survey - for mTurk

The problem with the SAVEDID is it can be 1, 2, 3 (even more) digits

You can pad it with zeros depending on the length.

Code:
{if(strlen(SAVEDID) < 4, 0, '')}{if(strlen(SAVEDID) < 3, 0, '')}{if(strlen(SAVEDID) < 2, 0, '')}{SAVEDID}

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 8 years 11 months ago by tpartner.
The following user(s) said Thank You: schmittg91
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 11 months ago - 8 years 11 months ago #128669 by holch
But if you have a fixed length code randomly generated number and then join the saved id at the end it should be fine. At least if you don't care that the final code could be anything from 7 to 9 digits long. But you will know that everything after the sixth digit is the savedid.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

Last edit: 8 years 11 months ago by holch.
The topic has been locked.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose