Welcome to the LimeSurvey Community Forum

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

Provide custom code to each participant

  • istewart6
  • istewart6's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 years 3 months ago #171826 by istewart6
Provide custom code to each participant was created by istewart6
I have a list of gift card codes that I want to distribute to my survey participants. If they make it to the end of the survey, they will receive a code. Can I upload/import the codes to LimeSurvey in order to do this?
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 3 months ago #171828 by Joffm
Replied by Joffm on topic Provide custom code to each participant
Hi,

if you use tokens you can use ATTRIBUTEs to provide a code.
Then each respondent will get a predefined code.

If you don't use tokens, or if you want to provide random codes, you can:
  • create a question of type huge free text,
  • enter all codes in a well defined format as "default answers", e.g. QW12ER BG5RTZ 45DFRE.
    You see each code starts at a multiple of 7 and is 6 characters long.
  • create a random number (rn) between 1 and the total number of codes
  • with functions like "substr" select the respective code like "mycode=substr((rn-1)*7,6)".

If there are further question don't hesitate to ask

Best regards
Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • istewart6
  • istewart6's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 years 3 months ago #171832 by istewart6
Replied by istewart6 on topic Provide custom code to each participant
OK! If I don't have a predefined list of participants, can I still assign tokens and attributes to the participants? Ex. each participant who clicks the URL is assigned a token that can be used to index into a gift code.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team & Official Partner
  • LimeSurvey Community Team & Official Partner
More
6 years 3 months ago #171839 by DenisChenu
Replied by DenisChenu on topic Provide custom code to each participant
I think the only solution is to create a plugin for such system

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. - Professional support - Plugins, theme and development .
I don't answer to private message.
The topic has been locked.
  • istewart6
  • istewart6's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 years 3 months ago #171842 by istewart6
Replied by istewart6 on topic Provide custom code to each participant
Oh I see. I thought I would be able to upload the gift code file and dynamically retrieve a new code every time that someone finished the survey. Maybe that is asking too much.
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 3 months ago #171846 by holch
Replied by holch on topic Provide custom code to each participant
You would have to program this yourself. This is not part of LS out of the box. You can create a little php (or whatever script), that is called by the end url feature.

But the token approach would be of course the best way.

Those gift vouchers have predefined codes or could you generate those codes yourself?

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
6 years 3 months ago #171848 by Joffm
Replied by Joffm on topic Provide custom code to each participant
Well, without tokens my second idea works.

And to avoid doubles you could use the {SAVEDID} as ID to find the code.

See example:

File Attachment:

File Name: limesurvey...1367.lss
File Size:15 KB


Of course, works only activated.

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • istewart6
  • istewart6's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 years 3 months ago #171852 by istewart6
Replied by istewart6 on topic Provide custom code to each participant
I like your idea of retrieving codes by index but have two worries:

1. Someone could inspect the source code and copy all the query codes.
2. I would need to manually update the codes every time that the participant count hit the limit (e.g. 100 codes only last for 100 participants).

The best solution is the token method but I won't be able to pre-determine who my participants will be, which means that I can't assign them tokens.
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 3 months ago #171854 by holch
Replied by holch on topic Provide custom code to each participant
How do you recruit your respondents? How do they access the survey?

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.
  • istewart6
  • istewart6's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 years 3 months ago #171856 by istewart6
Replied by istewart6 on topic Provide custom code to each participant
Great, thanks. I'll look into php scripts to handle this.

To answer your question, the codes are predefined which is why I wanted to upload a single file containing all the codes. You can generate them using an API but it's a bit complicated.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 3 months ago - 6 years 3 months ago #171857 by Joffm
Replied by Joffm on topic Provide custom code to each participant
Okay, if you have more participants than codes, just use a random number to select the code.

I tried to avoid to provide a code twice.

Someone could inspect the source code and copy all the query codes.

Put the hidden question with the codes into a different group

Joffm

BTW: I also prefer a small php script which is called by end-url.
But of course I was not sure how experienced you are.

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 6 years 3 months ago by Joffm.
The topic has been locked.
  • istewart6
  • istewart6's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 years 3 months ago #171858 by istewart6
Replied by istewart6 on topic Provide custom code to each participant
All participants who access the URL will be able to take the survey.
The topic has been locked.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose