Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

Defining correct response when multi-character response (text input) is used

Hi all,

I have recently started using OpenSesame with little knowledge in inline scripts. I am creating a digit span task, in which participants had to type the numbers in the presented order. That is, if 1, 5, 2 appeared one by one, the correct answer should be 152. I used text_input to record the answers. However, I used a random number generator, so I don't know how to specify correct response in order to give feedback after the text_input. I tried the following but it didn't work:
1. Create a correct response column in the loop. E.g., Column name: fwresp, then if the trial is supposed to generate four random numbers, i give a value of [num0][num1][num2][num3] to indicate the correct response.
2. Create an inline script, in which I specify if the text_input variable (e.g., "fwkey") and correct response. E.g.,
if self.get("fwkey") != ("fwresp"):
exp.set("fwcorrect", 0)
exp.set("fwcorrect", 1)

Any solution is highly appreciated!


  • Hi oasistree,

    I think your idea was very good, in attached an example of how it could work, not sure if this looks anything like your experiment, to give more precise advice it'd be handy to have a look at the script.
    But in general using an 'if else' structure to set the correct response based on the specific random numbers is the way to go, hope this helps,

  • Hi Roelof!

    You've made my day! Thank you for the awesome code! I was able to specify one "check-response" integer for each of the span widths(3-9 digits), and put them as values under a loop variable named correctkey (specify if var.key == var.correctkey). The feedback also works correctly now after I insert them into a new sequence, before it was always "incorrect" regardless of the text_input answers.


Sign In or Register to comment.