Millisecond Forums

coding for correct answers with key press

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

By raynae - 1/23/2023

Hello, 

I'm looking for help on how to code for /iscorrectresponse. 

In my study I prefer for participants to respond using a keyboard press which corresponds to the location of the stimulus. e.g, "1" for left and "2" for right. 

However, I want to randomise the presentation of the stimulus location of which I'm doing using a counter. Is there a way to code for if the position is 40% then the correct response ==  "1" keypress but if position is 60% then correct response == "2" keypress

thank you 
By Dave - 1/23/2023

raynae - 1/23/2023
Hello, 

I'm looking for help on how to code for /iscorrectresponse. 

In my study I prefer for participants to respond using a keyboard press which corresponds to the location of the stimulus. e.g, "1" for left and "2" for right. 

However, I want to randomise the presentation of the stimulus location of which I'm doing using a counter. Is there a way to code for if the position is 40% then the correct response ==  "1" keypress but if position is 60% then correct response == "2" keypress

thank you 

Sure.

<values>
/ x = 0%
/ cresp = " "
</values>

<list xpos>
/ items = (40%, 60%)
/ poolsize = 4
</list>

<text stimulus>
/ items = ("A", "B", "C", "D")
/ hposition = values.x
</text>

<trial mytrial>
/ ontrialbegin = [
    values.x = list.xpos.nextvalue;
    if (values.x == 40%) {
        values.cresp = "1";
    } else {
        values.cresp = "2";
    }
]
/ stimulusframes = [1=stimulus]
/ validresponse = ("1", "2")
/ correctresponse = (values.cresp)
</trial>

<block myblock>
/ trials = [1-4 = mytrial]
</block>

By raynae - 1/23/2023

Thank you!