This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
en:create:questions:random [26.11.2016 14:52] – admin | en:create:questions:random [11.03.2021 17:21] – sophia.schauer | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Random | + | ====== Random |
- | The random generator | + | **Tip:** This page explains in detail how to create a random generator and when such a generator |
- | The random generator | + | The random generator |
- | The extensive examples in the chapter [[: | + | By default, the random number generator ensures that all slips are drawn the same number |
- | **Hint:** If the random variation | + | **Tip:** If the random variation |
+ | There are several ways how to use a random generator. This are some functions which the random generator can execute: | ||
+ | * Two values are available for the drawn note: First, the numeric code and second, the entered text for the slip -- this can be, for example, the filename of an image (e.g. [[en: | ||
+ | * The random generator can draw multiple slips within an interview (option //Codes drawn per interview// | ||
+ | * The random generator returns only one value (and its label) per slip. But combinations can also be implemented using randomization (see [[en: | ||
- | ===== Differences between random generator and urn function ===== | ||
- | * For the second drawn ballot two kinds of values are available: first the numeric code and second the inscribed text for the ballot (e.g. the file name of a image, as seen in the example | + | ===== Create a Random Generator===== |
+ | Here is explained how to create | ||
- | * The random generator can draw multiple ballots during one interview (option //Amount of ballots per interview// | + | ====Step 1: Add a Random Generator==== |
- | * The random generator | + | The random generator |
- | ===== Example: Varying screen-stimulus ===== | + | {{:de: |
- | This example describes | + | You need the question ID in following PHP-codes. |
+ | ====Step 2: Add Contents==== | ||
+ | In the next step you enter the //Codes (Contents)// | ||
- | ===== Preperations ===== | + | For example, if you want to randomize the participants into different groups (e.g., in [[en: |
+ | Example: | ||
+ | Group 1 | ||
+ | Group 2 | ||
+ | Control group | ||
+ | By saving the question, the system now automatically assigns values (starting with 1) to the individual labels: | ||
+ | Example: | ||
+ | 1= Group 1 | ||
+ | 2= Group 2 | ||
+ | 3= Control group | ||
- | * Upload | + | Now, when the random number generator is placed in the questionnaire, |
- | * Create | + | |
- | < | + | ====Step |
- | 1 = stimulusA.jpg | + | In some cases it is necessary to optimize the random generator: |
- | 2 = stimulusB.jpg | + | |
- | 3 = stimulusC.jpg | + | |
- | 4 = control_group | + | |
- | </ | + | |
- | ===== Application ===== | + | * Specify how many codes must be drawn:\\ In some cases it is necessary to draw several slips (for example 20 images out of 300). Enter the corresponding value under //Codes drawn per interview// |
+ | * Type of drawing:\\ As mentioned above, you should think about which draw you need before you create the random number generator. By default, equal distribution is provided. However, this can lead to unequal groups if the groups are small and many dropouts are expected. So, under //Type of draw// there are different settings how the slips are drawn. | ||
+ | * Display contents:\\ it is also possible to already specify file names as slips and to include them directly on the questionnaire page using //show content// (see [[en: | ||
- | Under **Create a Questionnaire** you can drag and drop the random generator to the page you want the picture to appear. Now place (s. also [[: | ||
- | <code php> | + | ====Step 4: Placing the Random Generator==== |
- | // Retrieve the numeric codes (1 bis 4) | + | Depending on the further use of the values of the random generator, it must be placed appropriately |
- | $code = value(' | + | |
- | // The control group has to be treated differently | + | |
- | if ($code | + | |
- | // Kontrollgruppe - nichts anzeigen | + | |
- | } else { | + | |
- | // The inscription is saved as a value label – in this example | + | |
- | $img = value(' | + | |
- | // The HTML-Tag <img> shows an image, the filename will be shown with src | + | |
- | html(' | + | |
- | <div style=" | + | |
- | <img src="' | + | |
- | </ | + | |
- | '); | + | |
- | } | + | |
- | </ | + | |
+ | =====Using the Random Generator===== | ||
- | ==== Addition 1 ==== | + | The random generator is needed as a basis for some dynamic content in SoSci Survey. This includes: |
+ | * [[en: | ||
+ | * [[en: | ||
+ | * [[en: | ||
+ | * [[en: | ||
- | Not every experimental variation is resolved by displaying a single image. The following PHP code shows how to display another image on another position. The variation happens contingent by the first image, so if someone got the image 1a displayed he will on this position get image 1b. | ||
- | This time the filename for the image will not be saved directly into the random generator (like above) but in an array ([[: | ||
- | <code php> | + | ===== Readjust Drawings |
- | // Retrieving of the numeric codes (1 to 4) | + | |
- | $code = value(' | + | |
- | // The control group must (here to) be treated differently | + | |
- | if ($code | + | |
- | // Control group – display nothing | + | |
- | } else { | + | |
- | // Array, that saves an image for every group | + | |
- | $bilder | + | |
- | 1 => stimulusA2.jpg | + | |
- | 2 = stimulusB2.jpg | + | |
- | 3 = stimulusC2.jpg | + | |
- | ); | + | |
- | // With the square brackets an element from the array is read | + | |
- | $bild = $bilder[$code]; | + | |
- | // Display oft he image as above | + | |
- | html(' | + | |
- | <div style=" | + | |
- | <img src="' | + | |
- | </ | + | |
- | '); | + | |
- | } | + | |
- | </ | + | |
- | **Note:** This PHP-code only works, | + | If one works with many experimental groups, it can be that the actually successful equal distribution is lost after the adjustment. Especially if the number of cases per group is very small, |
- | ==== Addition | + | **Attention: |
+ | Imagine an experiment with 4 groups, where the participants are all invited on a certain day. After 2/3 of the participants have completed the questionnaire, | ||
- | Instead of an image also a question or a text module can be integrated. The following PHP code displays an individual text module (create under **Text Elements and Labels** -- and in groups 1 and 2 the question | + | **Tip:** In case you cannot adjust the random draw afterwards, you can use a [[: |
- | <code php> | + | If the conditions for readjustment |
- | // Retrieving of the numeric codes (1 to 4) | + | |
- | $code = value(' | + | |
- | // Varriing | + | - This frequency table is converted |
- | if ($code == 1) { | + | - This list is entered in the random generator |
- | | + | - After saving, the list is automatically sorted and further random draws are made in such a way that previous inequalities |
- | } elseif ($code == 2) { | + | |
- | text(' | + | |
- | } elseif ($code == 3) { | + | |
- | text(' | + | |
- | } elseif ($code == 4) { | + | |
- | text(' | + | |
- | } | + | |
- | // Variing the questions | + | |
- | if (($code == 1) or ($code == 2)) { | + | |
- | question(' | + | |
- | } else { | + | |
- | question(' | + | |
- | } | + | |
- | </ | + | |
- | + | ||
- | **Note:** view in addition | + | |
- | + | ||
- | + | ||
- | ===== Example: Show multiple images ===== | + | |
- | In this example participants should rate 300 images. To achieve this each participant has to rate 20 different pictures - each on a different page. | + | |
- | ==== Preperation ==== | + | |
- | | + | |
- | * Create a new question | + | |
- | * Enter the file names of the images as ballots | + | |
- | * For the option //Number of ballots per interview//, | + | |
- | * For the ratings create 20 questions with ID’s ranging from '' | + | |
- | + | ||
- | ==== Application ==== | + | |
- | Create one (!) page to display the images and the corresponding questions using **Create a Questionnaire**. Place the random generator | + | |
- | + | ||
- | <code php> | + | |
- | // loopPage(20) provides a number between 0 and 19 (plus one at every repetition) | + | |
- | $i = loopPage(20); | + | |
- | // Show the chosen picture | + | |
- | $varID = ' | + | |
- | $img = value($varID, | + | |
- | // The HTML-Tag <img> shows one image, the filename will be shown with src | + | |
- | html(' | + | |
- | | + | |
- | <img src="' | + | |
- | </ | + | |
- | '); | + | |
- | // Create the fitting question ID and show the question using question() | + | |
- | question(id(' | + | |
- | </ | + | |
- | + | ||
- | If you didn’t create 20 questions ('' | + | |
- | + | ||
- | <code php> | + | |
- | // Shows the item fitting to the question using question() | + | |
- | question(' | + | |
- | </ | + | |
- | + | ||
- | + | ||
- | ===== Example: Rate multiple political parties ===== | + | |
- | + | ||
- | In the following example the participants have to evaluate political parties using many different criteria. Altogether 6 parties have to be evaluated – but every participant should only have to evaluate two of them chosen randomly. | + | |
- | + | ||
- | ==== Option 1 ==== | + | |
- | + | ||
- | This Option will always save the answers to the first drawn party in the same variable. If you use e.g. 20 variables per party, your dataset will have 40 variables for party evaluations. This is overseeable, | + | |
- | * Create a category (e.g. “P1”) in your questionnaire, with all questions you want to ask about a party. Instead of the party name enter the [[: | + | For example, the list of codes and usable cases may look like the following: |
- | * Create a copy of the category, by downloading the category as an XML-file (Arrow down symbol in the toolbar above the question) | + | |
- | * Create a questionnaire under ** Create a Questionnaire ** and place the questions from '' | + | |
- | * Create a question of the type " | + | |
< | < | ||
- | 1 = CDU/CSU | + | 111111: 2 |
- | 2 = SPD | + | 111211: |
- | 3 = Die Grünen | + | 111311: |
- | 4 = Die Linke | + | 111411: 2 |
- | 5 = Piraten | + | 112111: 1 |
- | 6 = AfD | + | 112211: 2 |
+ | 112311: 2 | ||
+ | 112411: 2 | ||
+ | u.s.w. | ||
</ | </ | ||
- | Place the random generator under ** Create | + | In Excel or OpenOffice Calc, you create such a list by merging |
- | < | + | < |
- | $name = value(' | + | =CONCATENATE(A1; ": "; B1) |
- | replace(' | + | |
</ | </ | ||
+ | | ||
+ | In GNU R you can output frequency table and list as follows (if the variable of the random generator is called e.g. RG01): | ||
- | + | < | |
- | From there on the placeholder '' | + | tmp = table(data$RG01) |
- | + | cat(paste(paste(names(tmp), tmp, sep=": "), collapse=" | |
- | Place the following PHP-code on the first page with a „P2“-question: | + | |
- | + | ||
- | < | + | |
- | $name = value(' | + | |
- | replace(' | + | |
</ | </ | ||
- | If you want to mix the questions about the two parties, and if you have therefore used the placeholders '' | ||
- | <code php> | ||
- | $name1 = value(' | ||
- | replace(' | ||
- | $name2 = value(' | ||
- | replace(' | ||
- | </ | ||
- | |||
- | |||
- | ==== Option 2 ==== | ||
- | |||
- | It’s also possible to create own questions for every party. If you ask for 20 variables per party, the dataset will sum up to 120 variables – but therefore the evaluations of a party will always be saved into the same variables. The creation of that many questions might be more effortful but it’s also way easier to analyse. | ||
- | |||
- | * Create a category (e.g. “P1”) in your questionnaire, | ||
- | * In this option you can enter the party name directly into the question (and change it in every copy manually) or | ||
- | * Instead of entering the party name you can enter the [[: | ||
- | * Create 5 copies of the category by downloading the category as an XML-file (Arrow down symbol in the toolbar above the question) and subsequently import it multiple times using //New Category//. In this example the copys will be labelled '' | ||
- | * Create a question of the type " | ||
- | |||
- | < | ||
- | 1 = CDU/CSU | ||
- | 2 = SPD | ||
- | 3 = Die Grünen | ||
- | 4 = Die Linke | ||
- | 5 = Piraten | ||
- | 6 = AfD | ||
- | </ | ||
- | |||
- | Place the random generator under ** Create a Questionnaire ** on or before the first party question. | ||
- | |||
- | If you are working with the placeholder '' | ||
- | |||
- | <code php> | ||
- | $name = value(' | ||
- | replace(' | ||
- | </ | ||
- | |||
- | The questions have the labels '' | ||
- | |||
- | Place the following PHP-code where the corresponding question should be asked. So if you have 9 questions per party, place the code 9 times in the first partys block and 9 times in the second partys block. In the second block '' | ||
- | |||
- | === PHP-code with assembly === | ||
- | |||
- | <code php> | ||
- | $code = value(' | ||
- | $kennung = ' | ||
- | question($kennung); | ||
- | </ | ||
- | |||
- | === PHP-code with filters === | ||
- | |||
- | <code php> | ||
- | $code = value(' | ||
- | if ($code == 1) { | ||
- | question(' | ||
- | } elseif ($code == 2) { | ||
- | question(' | ||
- | } elseif ($code == 3) { | ||
- | question(' | ||
- | } elseif ($code == 4) { | ||
- | question(' | ||
- | } elseif ($code == 5) { | ||
- | question(' | ||
- | } elseif ($code == 6) { | ||
- | question(' | ||
- | } | ||
- | </ | ||
- | |||
- | |||
- | ==== Option 3 ==== | ||
- | |||
- | Another option would be to place all questions to all parties in the questionnaire and to give labels to the pages (s. bellow e.g. " | ||
- | |||
- | This variant is more vulnerable to errors (e.g. that somebody forgets to answer a question) and makes the questionnaire confusing. The command '' | ||
- | |||
- | Due to the limited use, we only present some example PHP code on this option. If you still decide for this option, place the following PHP-code on the last page of the generic part (the part everybody has to answer the same way before the branching occurs). He will display the two party blocks separated by an intermediate part between them (" | ||
- | |||
- | <code php> | ||
- | $pages = array(); | ||
- | // Numeric code of the first party | ||
- | $code1 = value(' | ||
- | // Write the fitting pages into the array | ||
- | if ($code1 == 1) { | ||
- | $pages[] = ' | ||
- | } elseif ($code1 == 2) { | ||
- | $pages[] = ' | ||
- | } elseif ($code1 == 3) { | ||
- | $pages[] = ' | ||
- | } elseif ($code1 == 4) { | ||
- | $pages[] = ' | ||
- | } elseif ($code1 == 5) { | ||
- | $pages[] = ' | ||
- | } elseif ($code1 == 6) { | ||
- | $pages[] = ' | ||
- | } | ||
- | // Complement the pages fort he intermediarry part | ||
- | $pages[] = ' | ||
- | // Numeric code of the second party | ||
- | $code2 = value(' | ||
- | // Write the pages for the second party into the array | ||
- | if ($code2 == 1) { | ||
- | $pages[] = ' | ||
- | } elseif ($code2 == 2) { | ||
- | $pages[] = ' | ||
- | } elseif ($code2 == 3) { | ||
- | $pages[] = ' | ||
- | } elseif ($code2 == 4) { | ||
- | $pages[] = ' | ||
- | } elseif ($code2 == 5) { | ||
- | $pages[] = ' | ||
- | } elseif ($code2 == 6) { | ||
- | $pages[] = ' | ||
- | } | ||
- | // Determine where it shall continue | ||
- | $pages[] = ' | ||
- | // Set the page order | ||
- | setPageOrder($pages); | ||
- | </ | ||
- | |||
- | Also this PHP-code can be written more compact if the labels for the pages are " | ||
- | |||
- | <code php> | ||
- | $code1 = value(' | ||
- | $code2 = value(' | ||
- | setPageOrder( | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ); | ||
- | </ | ||
- | |||
- | ===== Example: Varying page sequence ===== | ||
- | The questionaire of this example belongs to the “Within-Subject” experimental design. This means the questionnaire has a generic part, followed by some pages containing the first stimulus, followed by some puffer pages and some pages with the second stimulus. The sequence of the two units of stimuli should vary randomly. | ||
- | ==== Preperation ==== | ||
- | * Create a new question of the „random generator“ type (in the following case the question is named ZG02). Enter the following ballots (Note that file names can deviate from case to case.) into the question: | ||
- | < | ||
- | 1 = experimentalgroup 1 | ||
- | 2 = experimentalgroup 2 | ||
- | </ | ||
- | * Give ID’s to the pages of the questionnaire using ** Create a questionnaire** ([[: | ||
- | * The first Page which belongs to stimulus A receives the ID “beginA”. | ||
- | * The last Page which belongs to stimulus A receives the ID “endA”. | ||
- | * The first Page which belongs to the puffer pages receives the ID “beginMiddle”. | ||
- | * The last Page which belongs to the puffer pages receives the ID “endMiddle”. | ||
- | * The first Page which belongs to stimulus B receives the ID “beginB”. | ||
- | * The last Page which belongs to stimulus B receives the ID “endB”. | ||
- | * The first Page of the final part (which follows directly to “endB”) receives the ID “final”. | ||
- | |||
- | ==== Application ==== | ||
- | Under **Create a Questionnaire** drag and drop the random generator to the last page of the generic part. The following page should respectively have the ID „beginA“. | ||
- | |||
- | Place the following PHP-code beneath the random generator (s. auch [[: | ||
- | |||
- | <code php> | ||
- | $code = value(' | ||
- | if ($code == 1) { | ||
- | // Keeps the normal sequence – it is possible to omit this order... | ||
- | setPageOrder(' | ||
- | } else { | ||
- | // Reverse sequence of the units A and B | ||
- | setPageOrder(' | ||
- | } | ||
- | </ | ||