Howdy, Stranger!

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

Supported by

[solved] closing a form after a specific duration

edited February 2014 in OpenSesame

Hi Opensesame fellows,

Is there a straight forward way to close a form after a fixed duration, if a response has not been entered?
I've had a bit of a search on the site and the forum, but haven't found anything - apologies if I've missed something and this has been dealt with before.

To clarify, participants get 20 seconds to fill in a text box in a form - if they press enter before, the experiment proceeds, but if they haven;t pressed enter after 20 seconds, the experiment proceeds anyway.

I've had a couple of ideas, but they arent working so far.
Any advice very gratefully received.

Best wishes,

Neon

Comments

  • edited 1:43PM

    OK, so moving on, is there a way to use a parallel plugin with an inline script item to close the form? Does this sound reasonable, before I start fiddling with code?

    Again, many thanks in advance for any responses.

    Neon

  • edited February 2014

    I don't know if there's a set way of doing this using forms, but you could always use the following code. It's a DIY text input:

    # import the relevant libraries
    from openexp.canvas import canvas
    from openexp.keyboard import keyboard
    
    # define the timeout
    TIMEOUT = 20000 # ms
    # define the text wrapping width
    MAXWIDTH = 500 # pixels; or None to wrap text at screen edge
    
    # create a Canvas object
    cv = canvas(exp)
    
    # create a Keyboard object
    kb = keyboard(exp, keylist=None, timeout=1)
    
    # response variable, to store text in
    typed = ''
    
    # get starting time
    t0 = self.time()
    
    # run while there is no reason to stop
    stop = False
    while not stop:
        # check if there is a new keypress
        key, presstime = kb.get_key()
    
        # process the keypress if there is one
        if key != None:
            # if the key is the Enter key, stop
            if key in ['return','enter']:
                stop = True
            # if the key is backspace, delete the last letter of the response
            # (but only if there is a last letter!)
            elif key =='backspace' and len(typed) > 0:
                typed = typed[:-1]
            # if the key is the space key, add an empty space
            elif key == 'space':
                typed += ' '
            # if the key is something else, add this to the typed response
            else:
                typed += key
    
        # show the newly typed response
        # (first clear the canvas, to remove its previous contents)
        cv.clear()
        cv.text(typed, max_width=MAXWIDTH)
        t1 = cv.show()
    
        # check if the response time has elapsed
        if t1 - t0 >= TIMEOUT:
            stop = True
    
    # save some variables for later use
    exp.set("response", typed)
    exp.set("response_time", t1-t0)
    
    

    P.S.: This does allow for weird keypresses; if you want to constrict people to using only a certain set of keys (e.g. only vowels), please use the keylist keyword argument when the Keyboard object is created, e.g.:

    kb = keyboard(exp, keylist=['a','e','i','o','u','return','enter','space','backspace']
    

    Good luck!

  • edited February 2014

    Hi Neon,

    There is no timeout functionality in forms. Once a user engages with a form, you have to wait until the interaction is finished, i.e. until the user has clicked a button or some other widget that closes the form.

    So for now, the only options would be either Edwin's script, or the text_input plug-in, which is deprecated, but does offer timeout functionality.

    Cheers,
    Sebastiaan

    Buy Me A Coffee

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