Howdy, Stranger!

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

Supported by

[solved] OpenSesame: Use lists made in an inline script as 'variabeles'

edited March 2016 in OpenSesame

Hello all,

I've a new question. I've made a inline script that generates equations combined with an answer and a type and saves it as dictionaries in a list (because in this way each equation has been connected to the right answer and type). In a block loop, you are able to make variables and give each variable different values. I would like to use my script to generate three variables (equation, answer and type). So that, each round, one equation will be used out of the list. How do I do this? How do I connect the list of equations I generate with the inline script to the block-loop? Or is it not necessary to add variables to the block-loop and do I have to connect it to an sketchpad to directly show an aquation to the participant? And how do I keep the answer and type connected to the equation?

I hope my question is understandable. If my description is to faque, please let me know!

Comments

  • edited March 2016

    Hi Merel,

    One solution that comes to mind is to change your dictionary into a list of smaller lists.
    In the smaller lists, the first element is the question, the second one is the correct response, and the third one is the type.

    For example:

    Define the entire list at the beginning of your experiment:

    lEq = [
        ["2 x 2 = ", "4", "multiplication"],
        ["2 + 3 = ", "5", "addition"],
        ["2 - 2 = ", "0", "subtraction"]
        ]
    
    # If you want, you could randomize the list. (This won' affect
    # the content of the smaller lists):
    import random
    random.shuffle(lEq)
    

    Append aninline_script item to the beginning of the trial sequence, and place something like the following in the Prepare tab:

    # Pop one equation from the list. This is without replacement:
    var.equation = lEq.pop()
    
    # We now have one small list, where the first item is the
    # question, the second one the correct response,
    # and the last one the type of equation.
    
    # (We tell OpenSesame what the correct answer is by setting the
    # built-in variable 'correct_response')
    
    var.question, var.correct_response, var._type = var.equation
    

    Now you can use the variables question, correct_response and equation as if they were defined in the block_loop. For example:

    image

    The three variables are also logged, so you can keep track of all three of them.

    I hope this helps!

    Cheers,

    Lotje

    Did you like my answer? Feel free to Buy Me A Coffee :)

  • edited March 2016

    Hi Lotje,

    Thanks for your response! I still have a question:

    In the inline script you made, one equation will be shown to the participant, but how do you loop through the list of equations to show them all, one by one, to the participant?
    Or is that solved by using 'pop'?

  • edited 8:34PM

    Hi Merel,

    I thought the idea was to show the participant one equation per trial:

    • show equation
    • collect the response
    • log all variables from the current trial

    etc.

    If this is indeed what you want, I think the above method should work. I just forgot to mention that you have to set the number of cycles in the block_loop to the total number of equations.

    I uploaded an example here:
    http://pastebin.com/9Jumk5Cj

    (download and save with the extension .osexp)

    If this is not what you meant, please let me know!

    Cheers,

    Lotje

    Did you like my answer? Feel free to Buy Me A Coffee :)

  • edited 8:34PM

    Also, I get an error that lEq is not defined .. :(

  • edited 8:34PM

    Thanks! I will look at your example first!

  • edited March 2016

    Hi Lotje,

    Thanks a lot for your help! My experiment is working now! I changed your example a little by using the list of dictionaries directly instead of making it a list of lists.

    # Pop one dictionairy from the list of dictionairies. This is without replacement:
    var.equation = final_equations.pop()
    
    # Connect items dictionary to variables
    var.question = var.equation["equation"] 
    var.correct_response = var.equation["answer"]
    var._type = var.equation["type"]
    

    you're example was very useful, thanks!

    Cheers,

    Merel

  • edited 8:34PM

    Perfect! I'm glad to hear! :)

    Did you like my answer? Feel free to 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