Howdy, Stranger!

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

Supported by

Creation of new variables and storing in logger using custom form with loop

edited June 2017 in OpenSesame

Hello,

Using OpenSesame 3.1.6

I have a form_base that contains image-buttons whose content is specified via a loop that calls a sequence (containing a single form/test to run).

The loop contains a list of words to be translated ([word_to_translate]), and three "guesses"/words given to the participant: [guess1], [guess2], [guess3]. These options are presented to the participant as image-buttons:

widget 0 0 1 1 label text="[word_to_translate]"
widget 0 1 1 1 image_button path="[guess1].png" var="[word_to_translate]\_[guess1]"
widget 0 2 1 1 image_button path="[guess2].png" var="[word_to_translate]\_[guess2]"
widget 0 3 1 1 image_button path="[guess3].png" var="[word_to_translate]\_[guess3]"

The correct answer [correct_response] is also specified in the loop's table.

I have the "Log all variables" enabled in the logger, and I am seeing the following info correctly registered:

[word_to_translate]_[guess1] -> Yes/No
[word_to_translate]_[guess2] -> Yes/No
[word_to_translate]_[guess3] -> Yes/No
time_[word_to_translate]
etc

What I also want to record in the logger is the following info:

(a) Whether the participant answered correctly for any given [word_to_translate], i.e. effectively something like:
was_correct_answer_given_for_[word_to_translate] --> Yes/No

(b) The "response time", defined (I guess?) as
response_time_[word_to_translate] = time_[word_to_translate] - time_["previous"_word_to_translate]

But I don't know how to do either of them.

Could you please let me know if this is feasible?

With many thanks,

--Christos

Comments

  • Hi Cristos,

    In this case, I think you're better off using a simple inline_script. Below you see an example of how that works, with the difference that I used a button widget instead of an image_button. But the idea is the same. Does that clear things up?

    Cheers,
    Sebastiaan

    from libopensesame import widgets
    
    # These variables are probably defined in a loop table
    var.word_to_translate = u'pour'
    var.guess1 = u'to'
    var.guess2 = u'for'
    var.guess3 = u'against'
    var.correct_response = u'for'
    
    # Create a form
    form = widgets.form(exp, cols=[1], rows=[1,1,1,1])
    form.set_widget(widgets.label(form, text=var.word_to_translate), (0,0) )
    form.set_widget(widgets.button(form, text=var.guess1), (0,1) )
    form.set_widget(widgets.button(form, text=var.guess2), (0,2) )
    form.set_widget(widgets.button(form, text=var.guess3), (0,3) )
    
    # Execute the form and see how long it took. Also see if the return value of the
    # form matches the correct response. In the case of an image_button, the return
    # value wil correspond to the `path`.
    start_time = clock.time()
    response = form._exec()
    response_time = clock.time() - start_time
    correct = response == var.correct_response
    
    # Add the response to the response history!
    responses.add(response=response, correct=correct, response_time=response_time)
    
  • Many thanks for the detailed response, Sebastiaan. I can see that with the inline python one has much more flexibility.

    I still need some help with adding some variables to the response history, though. As it stands, only the response, correct and response_time from the last entry in the loop table are saved (because they are overwritten every time the sequence is called). Can I add a "_word_to_translate" suffix to these variables somehow? Not sure how to do that.

    (my logger claims it logs all variables)

    --Christos

  • You can specify an item as keyword. If you do that, OpenSesame will also register the responses with a _[item] suffix, just like for a keyboard_response.

    responses.add(
        response=response,
        correct=correct,
        response_time=response_time,
        item='some_unique_identifier')
    

    See also:

  • Thank you very much Sebastiaan! This seems to do what I need.

    Best, C.

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