====== caseNumber() ======

''int **caseNumber**()''

Each questionnaire in the survey project has a unique number, which also appears as the variable CASE in the data record ([[:en:results:variables|Addition Variables in the Data Set]]). This number can be called up with the function ''caseNumber()''.


===== Example 1 =====

The participant should maybe note down the number of their questionnaire so they can request an individual analysis later on.


<code php>
html('<p>This is the questionnaire no. '.caseNumber().'</p>');
</code>

However, the [[:en:create:placeholders##predefined_placeholders|predefined placeholder]] ''%caseNumber%'' could also be used to give the same result:


<code php>
html('<p>This is the questionnaire no. %caseNumber%</p>');
</code>


===== Example 2 =====

Or, the survey is composed of several questionnaires, because the second questionnaire (stimulus analysis) can be filled out multiple times, while the first questionnaire (master data) is only filled out once.

The various different data records belonging to a participant can be assigned with the case number. The following PHP code in the first questionnaire leads the participant to another questionnaire, and submits the case number as a reference ([[:en:survey:url|URL to the Questionnaire]]).

 
<code php>
$num = caseNumber();
$url = 'https://www.soscisurvey.de/followup/?r='.$num;
redirect($url);
</code>

The same thing but a little more compact:

<code php>
redirect('https://www.soscisurvey.de/followup/?r='.caseNumber());
</code>

The function ''redirect()'' supports placeholders as well as ''html()'' and text elements:

<code php>
redirect('https://www.soscisurvey.de/followup/?r=%caseNumber%');
</code>

At the second of the second questionnaire the participant would then be asked if they would like to evaluate another stimulus. Here, the reference (i.e. the case number from the first questionnaire) would have to be submitted, instead of the case number:


<code php>
redirect('https://www.soscisurvey.de/followup/?r=%reference%');
</code>