How to Present Stimuli Provided by Subjects

Inquisit supports defining stimulus sets based on input provided by the subject. This feature can be used, for example, to present text provided by the subject (e.g., the subject's stated name), or to present only stimuli selected by the subject on previous trials.

Presenting text entered by the subject

To create a set of items consisting of text entered by the subject, first we'll define an empty item set to store the items:

<item responseitems>
</item>
Next, we'll create a survey page with textbox items for gathering the respondent's first and last name:
<textbox firstname>
/ caption = "Please enter your first name:"
</textbox>

<textbox lastname>
/ caption = "Please enter your last name:"
</textbox>

<surveypage page1>
/ questions = [1=firstname; 2=lastname]
/ ontrialend = [item.responseitems.insertitem(textbox.firstname.response, 1)]
/ ontrialend = [item.responseitems.insertitem(textbox.lastname.response, 2)]
</surveypage>

This is a survey page with two items allowing respondents to enter their first and last names. The ontrialend attributes contain the commands that actually do the work of adding the names to the responseitems set. The first ontrialend command adds a new item to responseitems by setting the item property to the response for the firstname question. The second ontrialend command adds the last name in a similar fashion. Neither of these commands changes or removes the items that are already in the responseitems item set - they simply add new items. Using this technique, we can build up item sets of arbitrary length containing user-supplied content.

If we later want to change the first name item to something else (e.g., a nickname), we could do so using the following command:

<surveypage page2>
/ questions = [1=nickname]
/ ontrialend = [item.responseitems.setitem(textbox.nickname.response, 1)]
</surveypage>

This time, the ontrialend command assigns the first item in the responseitems set to the middle name. This time, the command includes the index number "1", which refers specifically to the first item in the set. By specifying the index number, we can thus change item in that position. If the index number is omitted as in the first example, a new item is added.

Stimulus elements can use the responseitems element the same way they would use other item elements. For example:

<text responses>
/ txcolor = (0, 255, 0)
/ position = (25, 25)
/ items = responseitems
</text> 

This text element presents the responseitems in the upper left corner of the screen in green.

Text items selected by the participant

In additional to allowing participants to type in new stimuli, it is also possible for them to choose items from a predetermined list. Imagine we want to create an item set containing three cities the participant has never visited. We'll store these items in an item set called "cities":

    
<item cities>
</item>

Next, we'll create a survey page with a checkboxes item with a list of cities for the participant to choose from:

<checkboxes cities>
/ caption = "Select three of the cities below that you have never visited:"
/ options = ("Berlin", "London", "Tokyo", "Paris", "Rome", "Sydney", "New York")
/ range = (3, 3)
</checkboxes>

<surveypage page1>
/ questions = [1=cities]
/ ontrialend = [ if (checkboxes.cities.checked.1 == true) item.cities.item = checkboxes.cities.option.1 ] 
/ ontrialend = [ if (checkboxes.cities.checked.2 == true) item.cities.item = checkboxes.cities.option.2 ] 
/ ontrialend = [ if (checkboxes.cities.checked.3 == true) item.cities.item = checkboxes.cities.option.3 ] 
/ ontrialend = [ if (checkboxes.cities.checked.4 == true) item.cities.item = checkboxes.cities.option.4 ] 
/ ontrialend = [ if (checkboxes.cities.checked.5 == true) item.cities.item = checkboxes.cities.option.5 ] 
/ ontrialend = [ if (checkboxes.cities.checked.6 == true) item.cities.item = checkboxes.cities.option.6 ] 
/ ontrialend = [ if (checkboxes.cities.checked.7 == true) item.cities.item = checkboxes.cities.option.7 ] 
</surveypage>

The checkboxes item lists seven cities and uses the range attribute to constrain the number of selections to 3. There are seven ontrialend commands, each of which evaluates whether its corresponding city is checked, and if so, adds it to the cities item list. The items can then be presented using a text element.

<text responses>
/ items = cities
</text>

Next, define an item element whose items will consist of the picture or text items selected by the subject on each run of the multiplechoice trial:

<item selecteditems>
/ items = (multiplechoice)
</item> 

Each time a multiplechoice trial is run, Inqusit adds the item selected by the subject to the selecteditems item set. If the multiplechoice trial presented pictures, the selecteditems item element could be presented by picture elements in the script. If the multiplechoice trial presented text, the selecteditem item element could be presented by text elements.

Picture items selected by the participant

We'll use the cities example again, but modify it to create an item set of pictures. Again, we'll store these items in an item set called "cities":

<item cities>
</item>

Here is our checkboxes survey item with the list of cities. This time, we've added the optionvalues attribute to define, for each option, the name of the corresponding jpg file containing a picture of the city. The checkboxes item will still display the city names next to each the checkbox, not the underlying optionsvalues.

<checkboxes cities>
/ caption = "Select three of the cities below that you have never visited:"
/ options = ("Berlin", "London", "Tokyo", "Paris", "Rome", "Sydney", "New York")
/ optionvalues = ("berlin.jpg", "london.jpg", "tokyo.jpg", "paris.jpg", "rome.jpg", "sydney.jpg", "newyork.jpg")
/ range = (3, 3)
</checkboxes>

Finally, here is the surveypage that displays the checkboxes item:

<surveypage page1>
/ questions = [1=cities]
/ ontrialend = [ if (checkboxes.cities.checked.1 == true) item.cities.item = checkboxes.cities.optionvalues.1 ] 
/ ontrialend = [ if (checkboxes.cities.checked.2 == true) item.cities.item = checkboxes.cities.optionvalues.2 ] 
/ ontrialend = [ if (checkboxes.cities.checked.3 == true) item.cities.item = checkboxes.cities.optionvalues.3 ] 
/ ontrialend = [ if (checkboxes.cities.checked.4 == true) item.cities.item = checkboxes.cities.optionvalues.4 ] 
/ ontrialend = [ if (checkboxes.cities.checked.5 == true) item.cities.item = checkboxes.cities.optionvalues.5 ] 
/ ontrialend = [ if (checkboxes.cities.checked.6 == true) item.cities.item = checkboxes.cities.optionvalues.6 ] 
/ ontrialend = [ if (checkboxes.cities.checked.7 == true) item.cities.item = checkboxes.cities.optionvalues.7 ] 
</surveypage>

For each city listed in the checkboxes item, the corresponding ontrialend command evaluates whether its checkbox is checked, and if so, adds the optionvalue (i.e., the picture file name) to item set. Now, we can create a picture element that will display these pictures:

<picture selectedcities>
/ items = cities
</picture>

One additional step is required to make this solution work. To maximize performance, Inquisit loads all pictures files used by a script at the very beginning as it parses the script. We therefore we need to tell Inquisit that the script uses these files, or it won't load them. We can do this by creating a picture element that lists these files as items. We won't actually use this element anywhere in the script - it's just there so that Inquisit will load the pictures:

<picture dummy>
/ items = ("berlin.jpg", "london.jpg", "tokyo.jpg", "paris.jpg", "rome.jpg", "sydney.jpg", "newyork.jpg")
</item> 

There you have it.