Both sides previous revisionPrevious revisionNext revision | Previous revision |
en:create:multilevel [02.08.2019 16:14] – admin | en:create:multilevel [10.02.2025 10:01] (current) – [Example 3] paula.dees |
---|
| |
| |
| ===== Using the multi-level overview ===== |
| |
| The [[:en:create:questions:multilevel]] question type links a higher-level questionnaire to a lower-level questionnaire, allowing a multi-level structure to be used without PHP programming. |
| |
| PHP code is only needed if you want to use ''[[:en:create:functions:multilevelprepare]]'' to generate a list of cases for the participant to fill in. |
| |
===== Simple Solution ===== | ===== Simple Solution ===== |
| |
| |
==== Example 1 ==== | |
| ===== Use cases and examples ===== |
| |
| ==== Query with cancellation condition ==== |
| |
| |
In the first application, the elements in the sub-questionnaire (naming "sub01") are queried. For this purpose, a //open question// ("NT01") with alternative option "no further element" will be used. | In the first application, the elements in the sub-questionnaire (naming "sub01") are queried. For this purpose, a //open question// ("NT01") with alternative option "no further element" will be used. |
</code> | </code> |
| |
| The following illustration uses a simplified example (selection question NT01 with 1=repeat) to show where the PHP code is placed, what data is transferred (orange) and which PHP commands jump to where (green). |
| |
==== Example 2 ==== | {{:de:create:multilevel.loop.png?nolink|Platzierung der PHP-Codes auf den unterschiedlichen Seiten}} |
| |
| |
| |
| |
| ==== Query for each nomination ==== |
| |
Alternatively, the main questionnaire can first query all elements and then start the sub-questionnaire a corresponding number of times. This example assumes that elements were first queried in a question of the type //Open namings// (identifier e.g. "NG01"). | Alternatively, the main questionnaire can first query all elements and then start the sub-questionnaire a corresponding number of times. This example assumes that elements were first queried in a question of the type //Open namings// (identifier e.g. "NG01"). |
A return value from the sub-questionnaire to the main questionnaire is usually not required for this design. | A return value from the sub-questionnaire to the main questionnaire is usually not required for this design. |
| |
| ==== Random draw ==== |
| |
==== Example 3 ==== | In this use case, 10 out of 100 stimuli are to be drawn and rated using [[:en:create:questions:random]]. The evaluation takes place in the lower-level questionnaire ‘rating’. The following preparations are necessary, the identifiers can of course be chosen freely: |
| |
| * In the random generator 'RG01' the stimuli are stored as terms and it is set to draw 10 codes per interview. The 'Variables' tab shows the variables 'RG01x01' to 'RG01x10' in addition to the variable 'RG01_CP' (which we do not need here). |
| * There is a question 'internal variables' with the identifier 'IV01' in which there is a variable 'IV01_01' with the label 'Stimulus'. |
| |
| In the higher-level questionnaire, the random generator is now integrated on a page (dragged into the page) and the following PHP code is placed below it: |
| |
| <code php> |
| // Reading out the drawn values |
| $stimuli = array_values(valueList('RG01')); |
| |
| // Display the page for each of the drawn values |
| $stimulusID = loopPage($stimuli); |
| |
| // Access the lower-level questionnaire for the stimulus |
| multiLevelDown('rating', $stimulusID); |
| </code> |
| |
| The ''valueList()'' function reads all drawn values and the ''array_values()'' function removes the variable names returned by the ''valueList()'' function, which are not needed here. The ''loopPage()'' function organises the repetitions and the ''multiLevelDown()'' function passes to the subordinate questionnaire 'rating', which is to be run for each stimulus. The information about which stimulus (numerical code) to display is passed. |
| |
| In the lower level questionnaire 'rating' you must first use ''multiLevelData()'' to read out which stimulus is to be displayed. Then use ''getItemtext()'' to find out which text it corresponds to, and use ''replace()'' to write it into the placeholder ''%text%'' (the name can be chosen freely). |
| |
| <code php> |
| // Reading information from multiLevelDown() |
| $stimulusID = multiLevelData(); |
| |
| // Save ID in data set |
| put('IV01_01', $stimulusID); |
| |
| // Search text for code |
| $stimulus = getItemtext('RG01', $stimulusID); |
| |
| // Write text in a placeholder |
| replace('%text%', $stimulus); |
| </code> |
| |
| The placeholder can now be used in subsequent questionnaires or, for example, in the following HTML code: |
| |
| <code html> |
| <h1>%text%</h1> |
| </code> |
| |
| |
| ==== Random draw with pictures ==== |
| |
| If you use images instead of words, store the filenames of the images in the random generator. |
| |
| The design of the higher-level questionnaire is the same as described above for the random draw. |
| |
| In the lower-level questionnaire, you can then use the file name to display the appropriate image. |
| |
| <code php> |
| // Reading information from multiLevelDown() |
| $stimulusID = multiLevelData(); |
| |
| // Save ID in data set |
| put('IV01_01', $stimulusID); |
| |
| // Search for the name of the image file for the code |
| $dateiname = getItemtext('RG01', $stimulusID); |
| |
| // Show image |
| html( |
| '<div style="text-align: center;">'. |
| '<img src="'.$dateiname.'" alt="" style="max-width: 100%">'. |
| '</div>' |
| ); |
| </code> |
| ==== Random draw with omissions or cancellation ==== |
| |
The instruction on [[:en:create:functions:randomuse#anwendungsbeispiel|randomUse()]] shows the complete PHP-Code for the case where participant has to rate 20 items randomly selected from a pool, but can also skip them. | The instruction on [[:en:create:functions:randomuse#anwendungsbeispiel|randomUse()]] shows the complete PHP-Code for the case where participant has to rate 20 items randomly selected from a pool, but can also skip them. |