Howdy, Stranger!

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

Supported by

[solved] repeat sketchpad until correct response given

edited April 2015 in OpenSesame

Hi,

I am trying to build an experiment with this structure:

1 - Loop with the variables [stimulus] and [correct_response]

2 - Sequence

3 - Sketchpad ([stimulus])

4 - Keyboard_response (a;l as possible keys)

Now, I want another Sketchpad to appear only if the response was wrong:

5 - Sketchpad ('wrong!')

This works, if I set a run if statement for 5 in the surrounding sequence ([response]!=[correct_response]).

But now I want the Sketchpad 5 to be shown until the correct response is given.

How do I do that? I already started with nested loops and break if and also tried to do everything with an inline script but with no success so far. I think I need a while loop that collects a second keyboard_response.

Thanks for your help,

Johannes

Comments

  • edited 5:54PM

    Hi Johannes,

    What happens, if you put following script in an inline_script after Sketchpad 5 (whose duration is set to keypress)?

    from openexp.keyboard import keyboard
    keyb = keyboard(exp)
    
    while True:
        resp,time = keyb.get_key()
        if resp == exp.correct_response:
            break
    

    I haven't tried it, but I believe this (or something similar) should do the trick.

    Eduard

    Buy Me A Coffee

  • edited 5:54PM

    Thank you Eduard,

    That did the trick. I inserted this inline script (I had to change exp.correct_response to exp.get('correct_response'), though).

    Then I set both Sketchpad 5 and the inline script to run if [response]!=[correct_response] within the surrounding sequence.

    I still have to check if all the variables are logged that I want to be logged, but it already runs the way I want it to.

    Johannes

Sign In or Register to comment.