Provide custom code to each participant

Mehr
2 Wochen 6 Tage her #171826 von istewart6
istewart6 erstellte das Thema Provide custom code to each participant
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?

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
2 Wochen 5 Tage her #171828 von Joffm
Joffm antwortete auf das Thema: 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
Folgende Benutzer bedankten sich: LouisGac

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
2 Wochen 5 Tage her #171832 von istewart6
istewart6 antwortete auf das Thema: 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.

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
2 Wochen 5 Tage her #171839 von DenisChenu
DenisChenu antwortete auf das Thema: 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 service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
2 Wochen 5 Tage her #171842 von istewart6
istewart6 antwortete auf das Thema: 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.

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
2 Wochen 5 Tage her #171846 von holch
holch antwortete auf das Thema: 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'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
2 Wochen 5 Tage her #171848 von Joffm
Joffm antwortete auf das Thema: 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:

Dateianhang:

Dateiname: limesurvey...1367.lss
Dateigröße:15 KB


Of course, works only activated.

Joffm


Volunteers are not paid.
Not because they are worthless, but because they are priceless
Anhang:

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
2 Wochen 5 Tage her #171852 von istewart6
istewart6 antwortete auf das Thema: 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.

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
2 Wochen 5 Tage her #171854 von holch
holch antwortete auf das Thema: Provide custom code to each participant
How do you recruit your respondents? How do they access the survey?

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
2 Wochen 5 Tage her #171856 von istewart6
istewart6 antwortete auf das Thema: 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.

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
2 Wochen 5 Tage her - 2 Wochen 5 Tage her #171857 von Joffm
Joffm antwortete auf das Thema: 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
Letzte Änderung: 2 Wochen 5 Tage her von Joffm.

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
2 Wochen 5 Tage her #171858 von istewart6
istewart6 antwortete auf das Thema: Provide custom code to each participant
All participants who access the URL will be able to take the survey.

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
2 Wochen 5 Tage her #171860 von LouisGac
LouisGac antwortete auf das Thema: Provide custom code to each participant

istewart6 schrieb: 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.


I suggest you to have a look in the theme views, it should be the easiest way to do it or to write a plungin, as Denis suggested.

This view is the one rendering the final page after completion:
github.com/LimeSurvey/LimeSurvey/blob/ma.../content/submit.twig

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
2 Wochen 5 Tage her #171861 von Joffm
Joffm antwortete auf das Thema: Provide custom code to each participant
Here an example for an open survey with less codes than participants.

Surely you can reformat of your list by some formulas or macros in EXCEL to be able to just copy and paste it to LS.

Best regards
Joffm

Dateianhang:

Dateiname: limesurvey...7-27.lss
Dateigröße:15 KB


Volunteers are not paid.
Not because they are worthless, but because they are priceless
Anhang:

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
2 Wochen 4 Tage her #171870 von Joffm
Joffm antwortete auf das Thema: Provide custom code to each participant
Hi,
here a different approach.

You don't like to have the code list inside the survey.

So I took the opportunity to try an ajax call.
In a question (Q1) of type "short free text" I inserted the following script:
<script type="text/javascript" charset="utf-8">
$(document).on('ready pjax:scriptcomplete',function(){
	$.post('https://www.myServer.com/directory/getCode.php', function(data) {
		$('#question{QID} input[type="text"]').val(data)
	});
        $('#question{QID}').hide();
});
</script>


The php-script "getCode.php":
Here I used a plain array to store the codes.
<?php
 
$codes = array (
"aaaaaa",
"bbbbbb",
"cccccc",
...
"yyyyyy",
"zzzzzz"
);
$numberOfCodes=count($codes)-1;
$random=rand(0,$numberOfCodes);
echo ($codes[$random]);
 
?>

Of course you can store the codes in a database and retrieve them by SQL; but the example should be short and easy.
Therefore thee are no error checks at all.

It was my first try with ajax calls in LS. So any improvement is appreciated.
Especially how to hide the question if it is in "question by question" mode.
Here I used "group by group" mode and had a second visible question in this group.

Best regards
Joffm


Volunteers are not paid.
Not because they are worthless, but because they are priceless
Folgende Benutzer bedankten sich: LouisGac

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Jetzt loslegen!

Melden Sie sich jetzt an, und erstellen Sie in wenigen Minuten Ihre erste Umfrage.

Account einrichten

Abonnieren Sie unseren Newsletter

Abonnieren Sie unseren Newsletter für alle Neuigkeiten rund um LimeSurvey
captcha