Millisecond Forums

Adding a Y/N response with feedback a la IAT, and if/then clauses

https://forums.millisecond.com/Topic19602.aspx

By briancjo - 8/28/2016

Dear Divine Intervention,
I have 3 hopefully simple questions (for you)

1. I have script that I have been doing this in person but I have to transition it to the web.
It basically presents a jpeg, and on the next frame, asks a question.
Similar to the IAT, I want subjects to input 'Y' or 'N' and then I want the script to give a green checkmark for correct and red X for incorrect.
Can you point me to the part of the IAT script that does this so I can edit it or give me a quick run down?

2. At the end of my trial, subjects have to choose 1 of 8 answer choices. I also want to add a box with an input and enter button at the end of my script. Afterwards, the script will provide feedback. Green/red marks like above. It can either be on the final screen or the following screen. whatever is easiest. It seems like this part needs an if/then clause.

3. Similarly to 3, I need to input a if/then clause at the end of the practice trial that will have the same screen as #2. If the subject answers correctly, the actual trials will begin. If the subject answers incorrectly, I want to present explanations. 

Hope all those are clear and simple.

Any help is much appreciated for the unworthy underdweller of your rule.

Brian
By Dave - 8/28/2016

Re. #1: You'll need to set up <text> or <picture> elements for your correct / incorrect feeback stimuli (red x, green checkmark). Then display them via the <trial>'s /correctmessage and /errormessage attributes respectively. Of course, you need to specify the /correctresponse.

<trial sometrial>
...
/ validrespone = ("y", "n")
/ correctresponse = ("y")
/ correctmessage = true(greencheckmark, 500)
/ errormessage = true(redx, 500)
</trial>

You'll find elementary syntax constructs like this covered in the tutorials in the documentation. These are worth going through if you haven't done so already.

Re. #2: Your eight answer choices work the same way as the yes / no trial above. It's completely unclear to me why an if/then clause would be needed or for what. Give an concrete example, please.

Re. #2 & #3: You'll want to set up an <openended> element for the text input. Here, too, the need for or purpose of any if/then logic is unclear.
By briancjo - 9/1/2016

Hi Superion,

Your responses make sense. the if/then clauses are unnecessary. Next Problems.
My basic script is such that for each block, I have 10 figures that are presented and the order is fixed in the code.
After each figure, the subject has to input 'y' or 'n' to a question. 
Problem 1: each figure has its own independent answer so i am not sure that I can setup the correctresponse like the IAT does. 
Would I have to setup have correct answers for each figure and if so, how would I do that?

Problem 2: for the previous block, after the subject gives a response, and they receive feedback, i will insert a posttrialpause like the IAT.
However, for a different condition will be such that the subject has only 5 seconds to respond 'y' or 'n'. If they respond, then they will get the 'correct' or 'wrong' message.
If they do not respond, I want the script to move onto the next trial. do i add in  a
/ timeout = 5000

thanks, brian
By Dave - 9/1/2016

Re. #1: You can use the <trial>'s /iscorrectresponse attribute to do this. See e.g.

https://www.millisecond.com/forums/FindPost15355.aspx

or

https://www.millisecond.com/forums/FindPost11991.aspx

Re. #2: Yes, you can use a /timeout. But they'll still receive the error message in case of a non-response; not responding is also an error. See the "How to Control Trial Duration and Inter-Trial Intervals" topic in the documentation regarding the relationship of the various timing components involved in a trial: http://www.millisecond.com/support/docs/v4/html/howto/howtocontroltiming.htm


By briancjo - 9/5/2016

Dave you are truly supreme,

All previous suggestions have worked beautifully. Next question.

I want my subjects to repeat a practice block 0 (or do a new practice block) if they get it wrong. 
If they get it right, they move on to the next block 1.
After completing the repeat practice block, they always go to block 1.
I looked at conditional statements, ontrialend, but all the examples seem tied to counters or values. I did not see any that began a new trial.
Would this be the if/then clauses?

Any thoughts would be helpful.
By Dave - 9/5/2016

It's unclear what "if they get it wrong" means specifically, i.e., what is the criterion here for "getting it wrong"? In any case, you'll want to look into using the <block>'s /branch attribute or using the /correcttarget attribute.

https://www.millisecond.com/support/docs/v4/html/language/attributes/correcttarget.htm
By briancjo - 9/15/2016

Dave,
Here is the code first of the blocks and trials. After, I set out my questions.

Here is the practice block code
<block DISC0>
/trials = [1-10 = sequence(picture0, Combo0); 11 = ComboFinal; 12 = Practice]
</block>
Trials 1-10 = subjects see 1 figure and then answer a Y/N question, for 10 total figures. 
Trial 11 = Combofinal is a final question asking participants to choose 1 of 8 answer choices. 
Trial 12 = Practice is an explanation of the previous Trial.
---------------
Here are my main issues.
If subjects get trial 11 incorrect, I want to run the trial 12 (practice) and then have them re-run the entire block (Disc0).
If subjects get trial 11 correct, I want to run trial 12 and then run the next block (Disc1).
--------------------
Here are the trial/texts for Combofinal and Practice
<trial ComboFinal>
/ stimulusframes = [1=ComboFinal]
/ validresponse = ("1", "2", "3", "4", "5", "6", "7", "8")
/ iscorrectresponse = [trial.combofinal.response == list.combofinal.nextvalue]
/ errormessage = true(errormsg, 1000)
/ correctmessage = true(correctmsg, 1000)
/ posttrialpause = 250
</trial>
<text ComboFinal>
/ items = ("Below are the 8 possible variables. Which variable was CHOSEN for this puzzle?
Press '1' for 'Letter Type A'
Press '2' for 'Letter Type T'
Press '3' for 'Letter Size Big'
Press '4' for 'Letter Size Small'
Press '5' for 'Figure Type 'Circle'
Press '6' for 'Figure Type 'Square'
Press '7' for 'Line Type 'Solid'
Press '8' for 'Line Type 'Dotted'")
/ halign = center
/ size = (90%, 80%)
/ position = (50%, 85%)
/ valign = bottom
</text>
<trial Practice>
/ stimulusframes = [1 = Practice, break, spacebar]
/ correctresponse = (" ")
/ errormessage = false
/ recorddata = false
</trial>
<text Practice>
/ items = ("For this puzzle, the CHOSEN variable was 'LETTER TYPE A.' 
This means that for every figure that had 'LETTER TYPE A', 'Y' was the correct answer.
For every figure that did not have 'LETTER TYPE A', 'N' was the correct answer.")
/ size = (90%, 80%)
/ halign = center
</text>
-------
I reviewed both branch and correct target. branch would seem to work better. Does inquisit have values for correct responses and incorrect responses such as 1 (cor) and 0 (inc), respectively, or does inquisit have code like trial.combofinal.correct, trial.combofinal.incorrect?
any help is grateful.
By Dave - 9/15/2016

> Does inquisit have values for correct responses and incorrect responses such as 1 (cor) and 0 (inc), respectively, or does inquisit have
> code like trial.combofinal.correct, trial.combofinal.incorrect?

Yes, and you will find those documented in the language reference for the <trial> element.

trial.sometrial.correct returns 1 (true) in case of a correct response, 0 (false) otherwise

Conversely, trial.sometrial.error returns 1 (true) in case of an incorrect response, 0 (false) otherwise.

Thus:

<block DISC0>
/trials = [1-10 = sequence(picture0, Combo0); 11 = ComboFinal; 12 = Practice]
/ branch = [if (trial.combofinal.error) block.disc0]
</block>

with

<expt>
/ blocks = [1=disc0; 2=disc1; ...]
...
</expt>

should give you exactly the behavior you want.
By briancjo - 9/16/2016

that worked, excellent work as usual, but it brought up a new question, of course...

<block DISC0>
/trials = [1 = combopractice; 2 = practice]
/ branch = [if (trial.combopractice.error) block.disc0]
</block>

what i discovered is that the practice block Disc0 will repeat until it gets the correct response. is there a way to limit the number of repeated blocks? i would like 3 max.
I added "branch [if block.disc0.currentblocknumber == 3] block.disc1] after the above branch to limit the total to 3 blocks, but it did not work. it still kept repeating until the correct response

By Dave - 9/16/2016

> what i discovered is that the practice block Disc0 will repeat until it gets the correct response.

That is the behavior your initial question implied.

> is there a way to limit the number of repeated blocks? i would like 3 max.

Yes, there of course is. (See below.)

> I added "branch [if block.disc0.currentblocknumber == 3] block.disc1] after the above branch to limit the total to 3 blocks, but it did not
> work. it still kept repeating until the correct response

When you have several /branch attributes, they are evaluated in the order given, from top to bottom. The first /branch that evaluates to true is executed. I.e., you're seeing the intended behavior. Switch the order of the two /branch attributes and you'd see different behavior.

Anyway, in a nutshell, I suggest you do:
<expt>
/ blocks = [1=disc0; 2=disc1]
</expt>

<block DISC0>
/trials = [1 = combopractice]
/ branch = [if (trial.combopractice.error && block.disc0.totalcount < 2) block.disc0]
</block>

<trial combopractice>
/ stimulusframes = [1=sometext]
/ validresponse = ("Y", "N")
/ correctresponse = ("Y")
</trial>

<block DISC1>
/ trials = [1=sometrial]
</block>

<trial sometrial>
/ stimulusframes = [1=sometext]
/ validresponse = (57)
</trial>

<text sometext>
/ items = ("Block is <%script.currentblock%>. Number of DISC0 blocks completed <%block.disc0.totalcount%>.")
</text>
By briancjo - 9/19/2016

Master Dave,

RE: htmlpage size.

I have an htmlpage of instructions. is there a way to make the center window larger. i tried canvassize in defaults but no changes.
By Dave - 9/20/2016

What you are looking for is the /windowsize attribute in the <instruct> element:

<instruct>
/ windowsize = (90%, 90%)
...
</instruct>
By gwat - 9/21/2016

I am new to Inquisit and am trying to code a word completion task.  I have found some useful hints here and elsewhere and am using a survey page with a sequence of captions (for revealed text) and textboxes (for hidden characters - that the user has to fill in).   For example, the target might be constucted as <INQU>[_]<S>[_]<T>  where the <..>'s are captions and  the[_]'s are textboxes, and  which displays as INQU_S_T.

My current problem is that I can't find how to set the cursor (which can be tabbed from textbox to textbox) back to the first textbox after creating the target word.

It would also be useful if I could set CapsLock on, but this is not so important.

Cheers
Geoffrey Watson, 
QUT, Brisbane

By Dave - 9/22/2016

> My current problem is that I can't find how to set the cursor (which can be tabbed from textbox to textbox) back to the first textbox after
> creating the target word.

I don't understand the problem. Please illustrate with a code example and provide a more detailed explanation (e.g. what does "creating the target word" mean?).
By briancjo - 9/23/2016

I am trying to setup likert scales. I am setting up the frames to ask one question at a time on the screen to  help the subject focus and not get lost in the inordinate amount of questions.
I need to have an input to skip the question if necessary, so I wanted to make a 0 value, which it the reference library states it can, but i get an error that the likert somlikert is missing a quote, number, whatever. i am aware that a zero "skip" value is against likert if you were wondering.
so now i have it as point 6 which is not ideal. any thoughts/help?
By Dave - 9/23/2016

> I need to have an input to skip the question if necessary, so I wanted to make a 0 value, which it the reference library states it can, but i get
> an error that the likert somlikert is missing a quote, number, whatever. i am aware that a zero "skip" value is against likert if you were
> wondering.so now i have it as point 6 which is not ideal.

This description does not make much sense without you showing some actual code and explaining how you envision a 'zero "skip" value' to work. I'm also not sure what you are referring to with "so I wanted to make a 0 value, which it the reference library states it can". Please point to what you are referring to. Which topic in the reference library (?) are you talking about?
By Dave - 9/23/2016

While I'm still unclear about what exactly you want to do, perhaps some of this may be helpful.

#1: If you want to stick with using <likert>s, you can do something like this:

<block someblock>
/ trials = [1-2 = somelikert]
</block>

<likert somelikert>
/ stimulusframes = [1=somequestion]
/ anchors = [1="Good"; 5="Bad"]
/ numpoints = 6
/ anchorwidth = 8%
/ buttonvalues = [1="1"; 2="2"; 3="3"; 4="4"; 5="5"; 6="X"]
/ position = (50%, 60%)
</likert>

<text somequestion>
/ items = ("Cat?", "Dog?")
</text>

#2: Alternatively, build your own likert-type scale using standard <trial>, <text>, etc. elements and give it a dedicated "skip" response.

<block someblock>
/ trials = [1-2 = somelikert]
</block>

<trial somelikert>
/ posttrialpause = 200
/ stimulusframes = [1=somequestion, lanchor, ranchor, line, 01, 02, 03, 04, 05, 00]
/ validresponse = ("01","02","03","04","05","00")
/ inputdevice = mouse
</trial>

<text somequestion>
/ items = ("Cat?", "Dog?")
/ position = (50%, 40%)
</text>

<text lanchor>
/ items = ("Bad")
/ position = (25%, 52.5%)
</text>

<text ranchor>
/ items = ("Good")
/ position = (75%, 52.5%)
</text>

<shape line>
/ shape = rectangle
/ color = black
/ size = (50%, 1%)
/ position = (50%, 60%)
</shape>

<text 01>
/ items = ("1")
/ size = (4%, 0.04px*display.canvaswidth)
/ position = (25%, 60%)
/ txbgcolor = grey
/ vjustify = center
</text>

<text 02>
/ items = ("2")
/ size = (4%, 0.04px*display.canvaswidth)
/ position = (37.5%, 60%)
/ txbgcolor = grey
/ vjustify = center
</text>

<text 03>
/ items = ("3")
/ size = (4%, 0.04px*display.canvaswidth)
/ position = (50%, 60%)
/ txbgcolor = grey
/ vjustify = center
</text>

<text 04>
/ items = ("4")
/ size = (4%, 0.04px*display.canvaswidth)
/ position = (62.5%, 60%)
/ txbgcolor = grey
/ vjustify = center
</text>

<text 05>
/ items = ("5")
/ size = (4%, 0.04px*display.canvaswidth)
/ position = (75%, 60%)
/ txbgcolor = grey
/ vjustify = center
</text>

<text 00>
/ items = ("SKIP")
/ size = (5%, 5%)
/ position = (50%, 70%)
/ txbgcolor = grey
/ vjustify = center
</text>
By briancjo - 9/25/2016

Here is the code

<text Panas>
/size = (500, 100)
/items = panas
/position = (50, 50)
/vjustify = center
/select = sequence
</text>

<item Panas>
/1 = "sad"
/2 = "calm"
/3 = "afraid"
/4 = "lonely"
/5 = "happy"
/6 = "hostile"
/7 = "relaxed"
/8 = "irritable"
/9 = "angry"
/10 = "fearless"
/11 = "disgusted with self"
/12 = "active"
/13 = "guilty"
/14 = "tired"
/15 = "distressed"
/16 = "excited"
/17 = "scornful"
/18 = "alert"
/19 = "upset"
/20 = "ashamed"
/21 = "scared"
/22 = "angry at self"
/23 = "enthusiastic"
/24 = "nervous"
/25 = "sleepy"
/26 = "determined"
/27 = "alone"
/28 = "jittery"
/29 = "lively"
/30 = "inspired"
/31 = "concentrating"
/32 = "dissatisfied with self"
/33 = "disgusted"
/34 = "attentive"
/35 = "sluggish"
/36 = "blameworthy"
/37 = "strong"
/38 = "proud"
/39 = "interested"
/40 = "loathing"
/41 = "bold"
</item>

<likert Panas>
/ anchors = [1="Very Slighty or Not At All";
2="A Little";
3="Moderately";
4="Quite a Bit";
5="Extremely";
6="Skip"]
/ fontstyle = ("Arial", 2%, true)
/ stimulusframes = [1 = panas]
/ mouse=false
/ numpoints=6
/ position= (50, 80)
</likert>

<block likertPanas>
/ preinstructions=(rate_panas)
/ trials = [1-41 = panas]
</block>

-------
These are the "remarks" re: anchors in the documentation:
This attribute assigns text labels to points on the Likert scale. Labels can be specified for any subset of points. The labels can be any string of text including blanks. Only one label can be assigned to a given point on the scale, and labels can not be assigned to points less than 0 or greater than the number of points specificed in the numpoints attribute.
------
It says labels cannot be assigned to points less than 0. That implies that points can be equal to 0? However whenever I try to assign
0=Skip, it will not let me and says that a number, point, label is missing when I check the code.

Right now, I have 6=Skip, which if i do averages and subjects skip will muck the data. obviously i can clean the data first, but i'm wondering if there is a shortcut.
So Is there a way to assign a value of zero to skip through the anchor element, OR is there a way i can add a button to skip the question, hence setting that button "Skip" equal to 0 on the stimulusframe that has the normal 5 pt likert scale.

simply, can i have the normal 5 pt likert scale with a addition button called "skip"

By Dave - 9/26/2016

See the two examples in my previous reply for what you can do.

As detailed in the 1st example, if you want to stick to <likert>, you'll want to use the /buttonvalues attribute. If you want to set the 6th point to zero, you do

/ buttonvalues = [1="1"; 2="2"; 3="3"; 4="4"; 5="5"; 6="0"]