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

Internal Variables

In the collected data are two kinds of variables: On the one hand there is administrative information like the cas number CASE or the time in which the interview was started STARTED (Additional Variables in the Data Set). On the other hand there are the answers of the participant and the associated measurements(response time, i.e). The second type of variables is respectively linked to a module of the list of questions, for example to a question or the item which was answered. Moreover, there are functional modules like the Random Generator. They do not have identification labels like questions(AB01, i.e) and might possess related variables in the data set.

Examples of functional modules are “Internal Variables”. They are deployed when data that exceed the regular questions is supposed to be saved in the data set. Common fields of use for “Internal Variables” are:

A module like “Internal Variables” has the sole function to provide additional variables in the data set.

Creating Internal Variables

  • Create a question “Internal Variables” within a rubric in your list of questions :
    List of QuestionsAdd QuestionFunctional ModulesInternal Variables.
  • A variable is automatically created in the module.
  • Additional variables may be added (if necessary) by choosing List of QuestionsAdd Variable or directly in the question via Quick input for Items.

It is possible to enter a description for every variable. Those descriptions are used in the data set to label (Label) the variables. Additional notes can also be complemented here. For example. “1=control group, 2=EG many, 3=EG few”)

Important: Identification labels of Internal Variables always consist of 7 digits. If the module “Internal Variables” had the label IV01 , the first variable would have the label IV01_01. Labels of variables can always be looked up under the menu item Variables overview. This identifier is the ID you use when you want to call your internal variable in additional code, not the name under which you created the variable.


Internal Variables have two functions. For one thing, data that was determined by PHP-Code can be saved. Especially the functions put() und urnDraw() can be at service for this procedure. For another thing, data in a single page of the survey can be saved that was determined by JavaScript in the Questionnaire.

Internal Variables and PHP-Code

In order to use Internal Variables in the PHP-Code, they simply have to exist in the list of questions. They should not be ddragged into a page of the questionnaire or integrated via question() (This way the participants would be able to manipulate the data).

Example: On page 3 of the questionnaire a scale SK01 was inquired that consisted of 10 items. The questionnaire is supposed to save an average value of the scale (Scale Index) in the Internal Variable IV01_01. For that reason, the following PHP-Code would have been used on page 4:

$index = valueMean('SK01');
put('IV01_01', $index);

A number of other applications can be checked in the reference of the function put().

A special role is taken up by the Randomization Using Urns. By the means of the function urnDraw(), a combination of various results is drawn out of an urn and saved in multiple internal variables within a module “Internal Variables”.

Please note: put() and urnDraw() save the results immediately in the data set. Therefore, the results can be retrieved on the same page of the questionnaire by the help of value().

Internal Variables and JavaScript

When a module “Interne Variablen” is being dragged into a page of the survey, hidden form elements are provided within the page. Those can be filled with data, for example via JavaScript in the Questionnaire. When you click “Advance”, the data will be transmitted to the Server and will be saved in the data set.

The HTML-ID of the hidden input fields match the identification label of the internal variable.

The following HTML - respectively JavaScript-Code would, for example, save the time of day that is set on the computer of the participant. This can be helpful when the data is collected across several time zones. The premise is, however, that an internal variable “TN01_01” is created in the list of questions and was dragged into the survey by the JavaScript-Code.

<script type="text/javascript">
// Die aktuelle Systemzeit auslesen
var date = new Date();
// Systemzeit als Stunden:Minuten formatieren
var hours = String(date.getHours());
if (hours.length < 2) hours = "0" + hours;
var minutes = String(date.getMinutes());
if (minutes.length < 2) minutes = "0" + minutes;
var time = hours + ":" + minutes;
// Das versteckte Eingabefeld identifizieren
var input = document.getElementById("TN01_01");
// Den Wert hineinschreiben
input.value = time;
// -->

The application is clarified in the chapter Use Custom Form Elements.

en/create/questions/internal.txt · Last modified: 29.10.2020 09:44 by sophia.schauer
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
Driven by DokuWiki