This is an old revision of the document!
void put(string variable, mixed value)
The function put
enables you to store a single value in the data record. put()
is used when the questionnaire calculates or draws a value – and this value is needed for the analysis. For example, if the stimulus in a question is varied at random, then which one the respondent made a statement on has to be known for the analysis.
'IV01_01
'.
Before put()
can be used, create an internal variable in the data record. In order to do this, create a new question in the List of Questions with the type internal variables, with at least one variable (item) in it. The complete ID for this variable is entered as the first parameter in the command put()
. The ID can be found in the Variables Overview (e.g. if it is the first variable in the first question in the “IV” category, the ID is “IV01_01”).
Tip: Items in a question with the type “internal variables” can also be used in order to save values from JavaScript. To do so, integrate the question in the same way as usual, and write the responses in the hidden input fields that are generated (Use Custom Form Elements).
If you are using the command random()
for a randomization, you have to store the random number drawn in the data record.
The following example assumes that you have created an internal variable with the ID “IV01_01”.
// Draw a whole number between 1 and 2 $number = random(1,2); // Store the number drawn in the data record put('IV01_01', $number); // And, depending on the number, display text element "text1" or "text2" if ($number == 1) { text('text1'); } else { text('text2'); }
The following example assumes that one construct is assessed in two scales with the question IDs AB01 and AB02 – and that an internal variable AB03_01 was created in order to save the scale index (total value of all items).
$sum01 = valueSum('AB01'); $sum02 = valueSum('AB02'); $index = $sum01 + $sum02; put('AB03_01', $index);
Determining the scale index even during the survey is particularly useful if you want to inform the participant of the result, or if it is required for a filter:
if (value('AB03_01') > 100) { question('FU03'); // question for people who rate the construct with a higher extent } elseif (value('AB03_01') > 50) { { question('FU02'); // Frage für Personen mit mittlerer Ausprägung beim Konstrukt } else { question('FU01'); // Frage für Personen mit geringer Ausprägung beim Konstrukt }
The following example is taken from a questionnaire that shows different questions at several points for new customers and existing customers. A new customer distinguishes himself by showing that he is yet to have bought anything (answer 1 in selection question “KD01”) and that the current order has not yet been delivered (answer 1 to 3 in selection question “KD02”).
Of course, the filter could be repeated on each page with different questions – on the one hand, however, this is unnecessarily complicated, and, on the other hand, the distinction between new and existing customers is needed in the analysis anyway. Therefore, the this should be saved in the internal variable “KD03_01”.
if ((value('KD01') == 1) and (value('KD02') <= 3)) { put('KD03_01', 1); // code 1 for new customers } else { put('KD03_01', 2); //code 2 for existing customers }
The saved code can be used on later pages for filters with no hassle.
if (value('KD03_01') == 1) { question('SU02', '1-3,5'); // in question SU02 show items 1, 2, 3 and 5 } else { question('SU02', '1,2,5-7'); // in question SU02 show items 1, 2 and 5, 6, 7 }