Welcome!

Sign in with your CogSci, Facebook, Google, or Twitter account.

Or register to create a new account.

We'll use your information only for signing in to this forum.

Supported by

Can I abort/skip a form after a dynamic amount of time?

I have noticed that it doesn't seem to be possible to define a dynamic amount of time out for certain modules. For example I can calculate the necessary time out time for a feedback module but not for a sketchpad module. Apparently the same applies to the form modules.

My specific problem is the following: I have seven text input modules and I want for them to be terminated and skipped after a total amount of six minutes has passed. For this I need to calculate how much time has passed in total before each text input module and then set the time out appropriately. However, the time out and seems to be fixed to what has been defined in the prepare face. Am I missing something or is there a way to get around this?

Thanks so much (among other things for making and maintaining open Sesame!)

Comments

  • RoelofRoelof Posts: 75

    You can set a dynamic time out of a sketchpad using the following notation in the duration box of the sketchpad: [six_minutes_variable], if this variable has been defined somewhere (var.six_minutes_variable = something) the sketchpad will understand the duration.

    However, since you want both a conditional execution of the sketchpad and a dynamic duration I think it is easiest to use an inline script.

    Example in the attachment, this experiment presents one sentence waits for response, if a response is made presents the next sentence and at the same time constantly checks if the duration is not longer then the time out, hope this helps, good luck,

    Roelof

    Thanked by 1Amir Moye
  • Hi Roelof

    Thanks for getting back to me so quickly!

    I can understand what you did in that inline script for the most part. However, I realize that I was imprecise regarding the kind of text input field that I'm working with, otherwise I would be able to use what you put together out of the box/adapted it a bit. Nevertheless, I see now how using inline script to essentially do a same as the open sesame module is a lot more versatile. Is there a way to get the equivalent python code from a Open Sesame module? That would be incredibly convenient as it would allow me to then put a while loop around it like you did.

    Another solution for my problem would be if there were a way to force the form module to update the variable defined in the run phase of an inline script, which it does not do currently. I attached an example script, which shows this along with how a variable updated in a run phase can be used only by the feedback module but not by the sketchpad module. The same thing seems to be happening for the form module. Is there a way around this?

    Thanks again and warm greetings from Switzerland

    • Amir
  • RoelofRoelof Posts: 75

    Hi Amir,

    The text forms are preparing everything in advance, like you said, and updating the time out during the presentation of the forms does not change the time out in the text forms since this variable is already prepared. I think the way to go, unfortunately, is to rewrite the text forms as custom forms:
    http://osdoc.cogsci.nl/3.1/manual/forms/custom/

    That would look something like this:

    from libopensesame import widgets
    form            = widgets.form(exp, cols=[1,1], rows=[1,2,1], margins=(50,100,50,100), 
    spacing=25, timeout = var.duration)
    labelTitle      = widgets.label(form, text='Question') 
    labelQuestion   = widgets.label(form, text='[text_2]', center=False)
    button          = widgets.button(form, text='Weiter')
    text_input      = widgets.text_input(form, text = 'write here...')
    form.set_widget(labelTitle, (0,0), colspan=2)
    form.set_widget(labelQuestion, (0,1), colspan=2)
    form.set_widget(button, (1,2))
    form.set_widget(text_input, (2,1))

    Then in order to adjust the timeout you would have to play around with the start time and response times, something like this, although I am not sure this works exactly:

    start_time = clock.time()
    button_clicked = form._exec()
    current_time = clock.time()
    var.text_timeout = var.duration - (current_time - start_time)

    I could not get this to work since opensesame crashed, but maybe this works for you, there should also be a time stamp associated with the response so you don't have to use the clock.time() which would be better.

    You would additionally also have to set a different variable to true/false in order to completely skip the text forms if the total time has already passed, and use this in the run if part of the sequence, as far as I know this variable is dynamically updated.

    Now there are some general timing issues with the text form input (see: http://osdoc.cogsci.nl/3.1/manual/forms/performance/) and there is one other way which works with a sketchpad and an inline script and allows participants to type in the sketchpad, this works very fast but has a very basic lay out, and might be a last resort.

    Hope this helps, good luck.

    Roelof

Sign In or Register to comment.