Howdy, Stranger!

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

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

  • 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

  • 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
  • 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

  • edited October 2017

    Hi Roelof

    So, I did manage to get it working. It now looks like this. Works exactly as it should. Thanks so much for the help! I didn't need to set any variable for skipping the entire thing, because if the timeout runs out for one text input window, all the following ones will be 0 and open sesame flips through them in mere milliseconds.

    However, I noticed that the performance of the text-input widget is slower than the text-input plugin. If I switch to legacy backend it works fine, but then the other part of my experiment doesn't work properly, which relies on the feedback plugin to run for 150 miliseconds (under legacy it doesn't display at all unless I enter keypress or mouseclick for the duration).

    Is there a way to emulate the text-input plugin through python code? I ask because the performance of the text-input plugin is a bit better under the xperiment backend for me.

    If there is no easy answer, I will just run the first part of my experiment in one backend, finish, then open the second part in a new open sesame experiment and use the other backend. It's a pain but I'm happy I have a working solution :smile:

    `

        from libopensesame import widgets
        import time
    
        EGO_TOTAL_TIME = 1 * 60 * 1000 # total timeout time for task in miliseconds
        var.introtext = 'some intro defined elsewhere in the experiment'        
    
        sentenceList = ["Example sentence 1.",
        "Example of a sentence 2.",
        "Example of a sentence 3."]
    
        startTimeEgo = time.time()*1000 # time is in seconds, so multiply by 1000
    
    
        for sentence in sentenceList: # Loop through string array
    
            var.currentSentence = sentence # Hand over the sentence so it displays Umlauts
    
            # Calculate remaining time
            EgoElapsedTime = time.time() *1000- startTimeEgo
            EgoRemainingTime = EGO_TOTAL_TIME - EgoElapsedTime
    
            # Create a form
            form = widgets.form(exp, 
                cols=[1], 
                rows=[1,1,1],
                margins=(50,50,50,50), 
                spacing=10, 
                timeout = EgoRemainingTime) # Set remaining time
    
            # Create widgets
            labInstruction = widgets.label(form,
                text=var.introtext + '\n\n\n\n\n\n\n\n\n\n\n'+
                var.currentSentence,
                center=False)
            text_input = widgets.text_input(form,
                var='response',
                return_accepts=True,
                stub='Hier klicken, um zu tippen..')
    
            # Add the widgets to the form. The position in the form is indicated as a
            # (column, row) tuple.
            form.set_widget(labInstruction, (0,0))
            form.set_widget(text_input, (0,2))
    
            form._exec()
    

    `

  • Hi Amir,

    That looks great, and it works quite smoothly for me, even with xpyriment backend. Kind of odd that the widgets work slower though, since the plug in seems to make use of the same package, but via a different route.

    Perhaps one thing that could help is to move all the code that is not required in the run phase to the prepare phase, guess this would only be the import lines.

    Second option is to try to "Switch to the xpyriment backend and set OpenGL to 'no' in the backend settings."
    this means that this line has to be added to the general script:
    set expyriment_opengl no

    The last thing you could do is perhaps reduce the size and number of all the elements as much as possible, since:
    "The speed with which the form is rendered is directly proportional to the total surface of all its elements."

    These are just things to try, maybe they improve your timing a bit, as far as I can see there is no easy way to set a specific backend settings just for the widgets.

    Roelof

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu http://45.77.173.118/ Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games