====== 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'' ([[:en:results:variables]]). 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 [[:en:create:questions:random]]. 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:
* Random draw from an urn ([[:en:create:random_urns]])
* User-defined questions that are unprovided for SoSci Survey ([[:en:create:inputs-custom]])
* Measurements during the Survey by the use of JavaScript ([[:en:create:javascript]])
* Live evaluation in the survey ([[:en:create:points]])
* Recoding during the survey ([[:en:create:functions:put#beispielcodes_transformieren|put() - Codes transformieren]])
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 Questions** -> **Add Question** -> //Functional Modules// -> //Internal Variables//.
* A variable is automatically created in the module.
* Additional variables may be added (if necessary) by choosing **List of Questions** -> **Add 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.
===== Use =====
Internal Variables have two functions. For one thing, data that was determined by PHP-Code can be saved. Especially the functions ''[[:en:create:functions:put]]'' und ''[[:en:create:functions: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 [[:en:create:javascript]].
==== 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 ''[[:en:create:functions: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 ([[:en:general:indices]]) 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 ''[[:en:create:functions:put]]''.
A special role is taken up by the [[:en:create:random_urns]]. By the means of the function ''[[:en:create:functions: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 ''[[:en:create:functions: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 [[:en:create:javascript]]. 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.
The application is clarified in the chapter [[:en:create:inputs-custom]].