Howdy, Stranger!

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

Supported by

How to vary in system output based on input of a participant

Hi Everyone,

I am currently trying to set up an experiment via OpenSesame. The idea is that a participant will fill in a questionnaire and after indicate how many questions (out of 10) they expect to answer correctly. Based on their input, the output is aimed to differ. Specifically, if a participant indicates that they expected to answer between 6 and 10 questions correctly, I want the software to randomly generate a number between 0 and 4 and communicate to the participant that that is the actual amount of correct answers. In contrast, when the participants expect to answers between 0 and 4 questions correctly, I am trying to make the system communicate a random value between 6 and 10.

Now, I am struggling to implement this. I've watched tutorials but I can't figure it out. I do not know if I need specific components to implement this, or adapt the script, or something else. Can anyone help me?

Regards, Tom


  • Hi @TomLammerts,

    The answer to your general question is that you need to use some coding to generate random numbers depending on the subject's subjective score. Hence, once you've asked the subject what they think their score is, you should use a script and an "if, else if, else" type of statement, and use the random.randint() function (if using Python) to generate a score between certain values.

    I don't know how you're implementing your task exactly, but I quickly put together a basic example task to illustrate how to achieve the above.

    Since you posted this message in the Open Sesame forum and not in the OSWeb forum, I have assumed that you plan to run the experiment in the lab and not through a browser, hence the coding I'm suggesting is in Python. If you wanted to achieve the same through a browser, you'd have to replace the Python code in the inline_script objects by Javascript code in inline_javascript objects. Writing code in Python or Javascript for the type of thing you want to do is not difficult. I myself have very limited knowledge of javascript and only began learning Python yesterday, but some quick searches on the internet allowed me to work out how to implement this example.

    Here's the general structure of the example I put together for you:

    I first have 10 multiple-choice questions in a loop, presented in a random order. I don't know how you implement your questions, but however you do it, it should not be an issue. Here, I implemented it that way as a quick solution just to illustrate the point.

    In this example, I'm gonna calculate the subject's actual score (I'll store it in the score variable). I first begin by setting it to zero before the questions are presented. I do that in an inline_script object (initialize_score):

    # Declares a variable that will count the number of correct responses and set it to 0

    Here is the loop with the questions, the options (I've marked the correct one with an asterisk), and the correct response (correct_response):

    When running the sequence displaying the questions and taking the answers, we're also gonna introduce some code to update the score based on the subject's responses. We do this in the update_score inline_script object:

    # if the response is correct, increment the score by 1
    if var.correct==1:
    # print score to console for monitoring
    print ('Score: '+str(var.score))

    You can see that there we declare that if the subject's response is correct, then the score should be incremented by 1 unit. The var.correct will be 1 if the subject's answer is correct, which will happen if their response is the same as the correct_response. I also output the score to the console as we go along, so that I can check that it is calculated correctly.

    Next, let's ask the subject to indicate how many questions they think they got right using a form_text_input object. I set the response to subjective_score.

    I then inserted a feedback object just to keep track of what's going on while programming the task (I'd delete that before running the task for real).

    Next comes the critical bit: the code where we'll define what feedback to give to the subject based on their subjective judgement of their performance. In the rules you set, you did not specify what feedback they should receive if they declared that they think they got 5 questions right. So, I decided that in that case, they'd get the truth. Otherwise, they'll get a random value between 0 and 4 if they declared they got 6 to 10 questions right, and a random value between 6 and 10 if they declared they got 0 to 4 right.

    Here's the code:

    import random
    if var.subjective_score < 5:
       var.feedback_score = random.randint(6,10)
    elif var.subjective_score > 5:
       var.feedback_score = random.randint(0,4)
       var.feedback_score = var.score

    (note that in Python, indentation is very important, as it is part of the code's sructure)

    As you can see, I'm using the subjective_score variable (which we got from the form_text_input object called meta_question described earlier) and test its value against different conditions... whether it's smaller than 5, greater than 5, or else equal to 5. Depending on the condition that is true, the new variable feedback_score will take a different value. Where we want to generate a random value, we use the random.randint() function from Python.

    After that, all that's left is to display a message to the subject with the feedback we want them to see.

    Et voilà!

    Your task will certainly will take a different form, but you you should now be able to implement the solution show here into your own experiment.

    I attach my example here:

    Good luck!


    Buy Me A Coffee

  • @Fab

    Wow.. you are a real hero. Thank you so much!! This made my day. Enjoy that coffee!


  • Hi @TomLammerts,

    Glad I could help! Good luck with your experiment, and thanks for the ☕️!


    Buy Me A Coffee

  • @TomLammerts

    PS: the program I described above illustrates the method. In the actual experiment, you'd have to add a data logger at the end of the question_sequence, and a linked copy of that logger after the score feedback is displayed to participant. That way, you'd have a record of all responses to the questions, as well as what score the participant declared they thought they had, and what score the task tells them they had. The reason for using a linked copy of the logger rather than a new one is because using more than one logger can confuse OS and can generate a messy output.

    Here's the example task with the logger integrated

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