====== Display Individual Codes or Voucher Codes ====== This chapter describes different ways of displaying an individual code to the participants (e.g. at the end of the questionnaire). Possible applications for this are: * an anonymous reference to the questionnaire/the participant's answers * distribution of unique codes (one-time passwords), which are recognized e.g. as test person hours or on a crowdsourcing marketplace (e.g. [[https://en.wikipedia.org/wiki/Amazon_Mechanical_Turk|Amazon Mechanical Turk]]) as confirmation for filling out * distribution of voucher codes (e.g. shopping vouchers) as incentives If you want to give out vouchers as incentives, the special function [[:en:create:voucher]] is your best choice. ===== Show Record Reference ===== If it is only a matter of giving the participant a reference to their record, the interview number is usually sufficient. For example, if you want to give participants the opportunity to receive individual advice later. The number of the data set (CASE, see [[:en:results:variables|additional variables in the data output]]) can be easily displayed using the [[:en:create:placeholders|placeholder]] ''%caseNumber%''. You might want to add a letter in front of it, as in the following HTML code:

Your personal participant code is: D%caseNumber%

===== Assign Individual Codes ===== The prerequisite for this is that you have received individual codes in advance (e.g. voucher codes) or have created them (e.g. using the [[:en:survey:serials|access code function]] of SoSci Survey at **Invitation Mailings** → **Access Codes** → //administration//). Now create a question of type "random number generator" and copy the codes (one code per line) into the field //ballots//. For //type of draw//, please keep the default value "Equally distributed draw (draw without replacement)". A small filter ensures that the questionnaire will display an error message if there are no more codes in the random number generator. If all the codes of a random generator have been drawn, then its variable with the postfix "_CP" will deliver "1". If there are still codes in there, then this value will return "0" (see an example below). The following example assumes that the random number generator has the code "RG01" and the text with the error message has the code "RG02". // If the random number generator has already been emptied completely if (value('RG01_CP') > 0) { text('RG02'); } else { // Store code in placeholder %code% replace('%code%', 'RG01', 'response'); // display HTML code with the code (alternatively: include text with the placeholder %code%) html('

Your code is: %code%

'); }
**Note:** If you want to give out vouchers as incentives, the special function [[:en:create:voucher]] offers several advantages over the random generator. **Note:** If you distribute voucher codes, make sure, if necessary, that only authorized participants access the questionnaire. The [[:en:survey:mailing|mailing feature]] can be used for this purpose. **Tip:** Check with ''[[:en:create:functions:casetime|caseTime('hitherto')]]'' and ''value('MISSING')'' if the participant has earned the code at all. ===== Anonymity ===== Possibly, participants must prove with a code that they have filled out the questionnaire, but no assignment to a data record shall be possible. In this case, generate a series of random codes and copy them into a random generator as described above. To ensure anonymity, delete the code from the random generator directly after displaying it. However, you cannot use ''dropValue()'' for this, because the random generator would then draw a new code when the page is reloaded. Use ''put()'' instead. // If the random number generator has already been emptied completely if (value('RG01_CP') > 0) { text('RG02'); } else { // Store code in placeholder %code% replace('%code%', 'RG01', 'response'); // Display HTML code with the code (alternatively: include text with the placeholder %code%) html('

Your code is: %code%

'); // Delete code from the data record put('RG01', '[cannot be displayed again]', true); }
---- Search terms: Completion code, voucher, tokens, confirmation of participation