Translations of this page:
 

Resuming by Means of an External Code

This manual describes how you can use a reference (Marking a URL) or a person code passed otherwise (Device and Transmitted Variables), …

Note: Only use this implementation if the regular solution by means of mailings or Access Codes cannot be used for organizational reasons.

How It Works

This solution makes use of the Content Database. For each person code, the interview token (case token) is stored there. By means of the interview token, the previously started interview can be resumed.

Implementation

On the first page of the questionnaire, read the person ID. In this example, it would be passed as a reference (r=…) in the link.

$personID = reference();

Then check whether there is an entry for this person ID in the content database. The following PHP code additionally prepends a prefix user to the ID. This makes it easier to use the database for different purposes. The prefix can be chosen freely.

$key = 'user-'.$personID;
$info = dbGet($key);

If an entry exists, the respondent is directly redirected to the corresponding case, and the current interview is deleted from the dataset. Otherwise (else), the interview token of the current interview is written to the database.

if ($info) {
  $url = info('project.url').'?i='.$info[0];
  dropCase();
  redirect($url);
} else {
  dbSet($key, caseToken());
}

The PHP code parts mentioned above must all be placed together in one “PHP code” element. This element must be placed at the very top of the first questionnaire page. However, it is also conceivable, for example, to write the entry to the content database only after a screenout. In that case, the else part at the beginning would be omitted, and the code placed later would look as follows.

$personID = reference();
$key = 'user-'.$personID;
dbSet($key, caseToken());

Thus, an interview would only be resumed if the place with the second PHP code containing dbSet() was reached.

en/survey/unique-redirect.txt · Last modified: by 127.0.0.1
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
Driven by DokuWiki