Howdy, Stranger!

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

Supported by

Looking for some recommendation to write adaptive testing code

Hi all,

I'm writing an adaptive testing experiment, and thanks to the forum discussion, I learned a lot from here!

By the way, I need some recommendations or guidelines as I'm facing some problem in setting up my experiment. My experiment (Adaptive testing) was to evaluate the hearing status of the participants, therefore, we had a different level (for example, Level 1 to Level 6) of words in the experiment list.

(1) My first experiment trials should be started at the middle level, such as Level 3 (from 1 to 5), and my code was written as below. I wonder if anyone can give me some guide?

(2) If the participants have a correct response, then the next trial will be at a harder level, for example: if the participants have a correct response in level 3, then the next trial will be from level 4. Also, my highest level in the list was 6, and if the participants have the correct response in level 6, the next trial will remain in level 6, the same situation at the lowest level. So I wrote the code as below while it was worked in my e-prime, however, it seems like opensesame doesn't understand what I had written. Any recommendation?



  • Hi,

    Can you provide more information in how far this does not work? The code looks fine to me. Maybe the positioning in the experimental sequence is wrong, but without more detail, it is hard to pinpoint what is happening.


    Buy Me A Coffee

  • Hi Eduard,

    Thanks for your reply. My first trial of the experiment must be the item of middle level, and I have listed all of the trials into a particular level in the Experiment loop (var.item_level). However, I have tried a couple of times, but the first trial of the experiment sequence may not always be the particular item level that I wanted. Secondly, I have tried to insert either correct or incorrect responses; however, the next trial was not the particular level's item. e.g., I have inserted the correct response in the level 3' item, but the upcoming trial was not the item from level 4. It was randomly assigned from other item_level. So I have no clue that what I should do next, while these two settings were quite essential to my research design.

    I wonder these descriptions would add more information for you to know what I'm wanted to convey. Thanks again! I'm looking forward to your reply.

  • edited July 29

    Make it easier to know. My experiment design procedure would be like :

    My participants will see a fixation dot, and then stimuli sound on (sound_level [which is according to my var.item_level] start from level 3), then participants answer what they heard. If the participants insert the correct answer, then the next stimuli sound would be from level 4, else would be from level 2.

    #After fixation point, then sound on (sound should be starting from level 3[var.item_level]) #This might be the part that I'm stuck

    The figure I posted was not clear enough, so I re-post my code down here. Sorry for the inconvenience.

    #start from level 3
    var.item_level == 3
    #show fixation point to aware the participants
    #After fixation point, then sound on (#sound should draw according to var.item_level)
    #then allow participant to answer the question
    t0 =
    resp = "" #here we store the response
    while True:
    #Get a keyboard response
    key, time = kb.get_key()
    #if press return, then the loop should be exited.
    if kb.to_chr(key) == "return":
    #handle backspace by removing the last character
    if kb.to_chr(key) == "backspace":
    resp = resp[:-1]
    resp += kb.to_chr(key)
    #save response time
    var.response_time = time - t0
    #save all the response key
    self.experiment.set("response", resp)
    if resp == var.correct_response: 
    var.correct = 1
    var.correct = 0 
    if var.correct == 1: #if correct = 1, then go to harder level
    var.item_level = var.item_level + 1
    else: #if correct = 0, then go to easier level
    var.item_level = var.item_level - 1
    if var.item_level == 7: #when reach top level and have correct response, remains in the same level
    var.item_level = 6
    if var.item_level == 0: #when reach lowest level and have incorrect response, remains in the same level.
    var.item_level = 1

    Thanks again! I'm looking forward to your reply.


  • HI TZ,

    For a starter, your first line var.item_level == 3 only checks whether the current item level is 3. It doesn't do anything in the sequence, if you want to set the item level to 3, you need to use var.item_level = 3.

    However, if you want the current level to be +1/-1 relative to the previous trial, you can't reset it in the beginning of this block of code. Otherwise, everything that you set on the previous trial (the last lines in your script), will be undone by the first lines in the beginning of the next trial. So ,instead you probably want the item to be set only in the first trial, or even before the trial loop starts. Does that make sense?

    Seeing the experimental loops and variables in there would be helpful to know what is going on. If you say that the level is random on every trial and not incremented from the previous trial, I suspect you have the item level set in the experimental loop and on every trial it is pulling it from that table, rather than using the one you computed. Is that possible?


    Buy Me A Coffee

  • edited July 30

    Hi Eduard,

    I think I know what makes my works stuck! My experiment procedure will be like (1) fixation (2) stimuli sound (word sound) (3) Response (see the figure below).

    According to the script I wrote, the response step will note all of the responses that participants inserted, which is perfect! However, my stimuli sound won't start from the middle level at the beginning (first trail), which is level 3, for example. Should i add an inline_script var.item_level = 3 in before the experiment loop? or Experiment_procedure? Or somewhere else?

    Then, the sound playing script in the prepare and the run page was different, you can see as below.

    #prepare page

    path = pool(var.sound_experiment)
    soundP = sampler(path)

    #Run page #sound should draw according to var.item_level

    I think I know the reason why my upcoming trial couldn't run the script I wrote, is it because I didn't define the sound stimulus' level? The code was telling it to run the sound besides telling it to retrieve according to the stimuli sound's level. If yes, how do I modify the code I wrote to satisfy my needs? Any recommendations?

    Appreciate your bits of help! 


  • In your loop table, every line corresponds to one trial. So every time that you start a new iteration, item_level is set to the value that you see in the loop table. The adaptive character will be lost. You probably have to remove this columns altogether.

    >Should i add an inline_script var.item_level = 3 in before the experiment loop?

    That is what you should do I think. So after the start_sketchpad and before the ExperimentLoop. Then, the procedure will always start with the level set to 3, and during the loop it will dynamically be adapted depending on the performance (provided that you take out the column).

    If the variable item level should have an effect on a stimulus you'll have to set it of course. For example, if the loudness of the sound depends on the item level, you need to program it, otherwise, you won't see (or hear) any level-specific differences.

    Hope this clears things up.


    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