====== Assignment ====== Different stimuli are shown in an assignment question, which the participant has to assign to one of two (or more: max. 10) categories. The categories or options (e.g. "good" or "bad") are the same for each stimulus. Stimuli are assigned by clicking on the option or with a single keystroke. The latter is useful if the response time should be recorded. {{:en:create:questions:exp.assignment.png?nolink|Assignment Example}} * Assigning items works in a similar way to a single block in the [[:en:create:questions:iat|Implicit Association Test (IAT)]]. * Response time is measured in milliseconds with an accuracy of approx. 10 ms. [[:en:glossary#javascript|JavaScript]] is used to achieve this level of accuracy -- this means loading times between stimuli are omitted. * An introduction will be shown before the first stimulus. Selecting one of the options begins the assignment. * The "Next" button is hidden while working through the question. After the last stimulus has been categorized -- depending on the settings in the question -- the Next button will be displayed or the questionnaire will switch automatically to the next page. * Depending on previous responses, stimuli can be skipped by using a little bit of JavaScript (see below). **Tip:** Graphics can also be used as options (e.g. thumbs up/down, emoticons). HTML code to integrate the graphic is used as the text for the option ([[:en:create:images|Images in the Questionnaire]]). ===== Operating with Keys ===== Selection keys differ depending on the number of options: * Two options:\\ Left-hand option: D, F, G, V, B, 1, 2, 3, 4, 5, <-, Num4, Num1\\ Right-hand option: K, J, H, N, M, 6, 7, 8, 9, 0, ->, Num3, Num6 * Three options:\\ Left-hand option: 1, Num1, Num4, <-\\ Middle option: 2, Num2, Num5, Arrow down, Arrow up\\ Right-hand option: 3, Num3, Num6, -> * Four to ten options:\\ Numerical keys 1 to 10 (depending on the number of options) ===== Filtering ===== The different stimuli are loaded onto the same page in the questionnaire and shown in succession by using JavaScript -- responses are not transmitted to the server until the question has been completed. Classic [[en:create:filters|filters]] using PHP code therefore cannot be implemented in order to skip individual stimuli (items), or to end assigning of items prematurely. Nevertheless, this question type offers an opportunity for filters to be used. A Javascript function is defined in order to this. After this function is applied in the question through ''setCallbackSelect()'', it will be invoked during each assignment (selection). The function is informed each time as to which stimulus was just assigned and which option was selected. Depending on what the function returns, the response will be ignored, the question will jump to another stimulus, or the question will be terminated. The callback function can return the following numerical values: * ''-1'' Terminate assignment question * ''-2'' Ignore keystroke, show selection again * Jump to the stimulus with the corresponding ID * ''0'' or ''false'' Resume with the next stimulus, as if there was no filter **Caution:** If the participant jumps to a stimulus that has already been assigned, it will be shown again and the old assignment and measured response time will be overwritten. ==== An Example of a Filter ==== The following Javascript code can be saved as a text element. Drag the text element into the questionnaire below the question. The function ''selFilter()'' included provides the following filtering: - If the first (left-hand) option is selected for the first stimulus, the second item will be skipped, and it will continue directly to item 3. - The second stimulus can only be assigned to the right-hand (second) category. Selecting the left-hand option will be ignored. - If the second option is selected for a later stimulus (third, fourth, ...), the assignment will be terminated immediately. ===== JavaScript Connection ===== The JavaScript function ''setCallbackSelect()'' (see above) is primarily designed for filter guidance. In addition, the assignment task supports events, which allow JavaScript to intervene directly. The following events are triggered by the container of the question: * ''fixation'' -- A pause is placed between two stimuli (items), e.g. a fixation cross. This event is only triggered if a pause is set between the stimuli. The following attributes are available in the ''detail'' property of the event: * ''evt.detail.question'' -- Identification of the question * ''evt.detail.item'' -- Identification (ID) of the item, which is displayed after the pause * ''evt.detail.node'' -- The HTML element that is displayed in the pause * ''evt.detail.duration'' -- The duration of the pause [ms]. * ''prime'' -- A prime that may be displayed before a stimulus. This event is only triggered if a prime has been defined for the item. The following attributes are available: * ''evt.detail.question'' -- Identification of the question * ''evt.detail.item'' -- Identification (ID) of the item, which is displayed after the prime * ''evt.detail.node'' -- The HTML element that is displayed as Prime * ''evt.detail.duration'' -- The duration for which the Prime is displayed [ms]. * ''present'' -- The actual stimulus or a text is displayed. * ''evt.detail.question'' -- Identification of the question * ''evt.detail.type'' -- Type of display (''"intro"''=text at the beginning, ''"outro"''=text after the last item, ''"item"''=one item/stimulus is displayed) * ''evt.detail.item'' -- Identification (ID) of the displayed item/stimulus, ''null'' if a text is displayed * ''evt.detail.node'' -- The HTML element that is displayed as stimulus or text * ''select'' -- The respondent has selected a category. If this event is caught with ''evt.preventDefault()'', the item will be displayed again (possibly including Prime) and a function registered with ''setCallbackSelect()'' will not be called. The following attributes are available: * ''evt.detail.question'' -- Identification of the question * ''evt.detail.item'' -- Identification (ID) of the stimulus * ''evt.detail.option'' -- The selected category (starting with 1) The function ''setPrimeTimes()'' can be used to individually set the presentation duration for primes (if defined for stimuli/items). The function ''setPauseTimes()'' can be used to set the duration of the pause between items individually, during which the fixation is displayed if necessary. The ''selectOption()'' function triggers the same reaction as clicking on a response option. The number of the option (starting with 1) is entered in brackets. ==== Playing Audio ==== If the stimuli (also) contain an audio file, the ''present'' event can be used to play it at the right time. For example, stimuli 1 and 2 would have the following content: audio sample 1 audio sample 2 The following HTML/JavaScript code is placed under the question (here e.g. ''AB01''): Note that the HTML IDs for the ''