This translation is older than the original page and might be outdated. See what has changed.
Translations of this page:
 

This is an old revision of the document!


Table of Contents

reference()

string reference()

If a reference in the URL to the Questionnaire was transferred, the function reference() will return it. The reference can have information concerning the participant encoded within it, which the questionnaire can use straightaway for filtering (see example 2).

Tip: The reference can also be integrated into questions, text elements and the function redirect() with the help of the predefined placeholder %reference%.

Example 1

In the following example, the reference is merely displayed.

html('<p>Your reference: <strong>'.reference().'</strong></p>');

The placeholder %reference% has the same effect here:

html('<p>Your reference: <strong>%reference%</strong></p>');

Example 2

The use of the reference can be useful if other information is encoded within it. In the following example, social scientists would have “Axxx” as a reference (e.g. A100, A201, A991), and natural scientists would have a “BXXX” reference (e.g. B100, B201, B990) in the URL.

Depending on the reference, question “AB01” or “AB02” will now be displayed. The first character has to first be extracted from the reference in order to so by using {0}. PHP's own function strtoupper() ensures that potential lower case letters are converted into upper case.

$ref = strtoupper(reference()); // identify reference and convert into upper case 
if (strlen($ref) < 1) {
  // No reference submitted (less than 1 character)
  goToPage('next');
} elseif ($ref{0} == 'A') {
  question('AB01');  // question for social scientists
} elseif ($ref{0} == 'B') {
  question('AB02');  // question for natural scientists
} else {
  // No valid reference submitted
  goToPage('next');
}
en/create/functions/reference.1422099875.txt.gz · Last modified: 24.01.2015 12:44 by alexander.ritter
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
Driven by DokuWiki