Howdy, Stranger!

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

Supported by

[solved] How to repeat a particular trial until correct before moving on to next trial?

edited August 2013 in OpenSesame

Hi, how can I repeat a particular trial or question until a correct response is obtained (e.g., participants must keep trying question 1 until they get it correct before they can move on to question 2)? Are there any examples of how this has been implemented? Thanks very much.

Comments

  • edited 6:36PM

    Hi,

    You can add a repeat_cycle plug-in (typically) to the end of the trial_sequence. This plug-in has a 'Repeat if' statement, which you can set to any arbitrary criterion. For example, if the trial_sequence contains a keyboard_response item, and you want to repeat the trial if the response was incorrect, you can set the 'Repeat if' statement to [correct] = 0.

    Best wishes,

    Lotje

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

  • edited 6:36PM

    Hi Lotje,

    Thanks for the reply. The repeat_cycle plug-in repeats all the incorrect cycles AFTER all cycles have been completed, but what I want is to repeat a particular cycle immediately. So instead of cycle 1, 2, 3, 4, 5, repeat 1, 2, I want it proceed this way 1, 1, 2, 2, 3, 4, 5. Any idea how to accomplish that? Thanks again.

  • edited 6:36PM

    Hi,

    I see what you mean. You can immediately repeat an error trial by:

    1.) Appending an inline_script item to the very end of your trial sequence:

    image

    2.) And placing the following code in its Run phase tab:

    # If participant gave an incorrect response:
    if self.get('correct') == 0:
        # Prepare the whole trial sequence (here called
        # 'trial_sequence') again:
        exp.items['trial_sequence'].prepare()
        # And run it again:
        exp.items['trial_sequence'].run()
    
    

    You can find a simple example experiment here (download, change the extension from .txt into .opensesame and open as normally):

    I hope this helps!

    Best,

    Lotje

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

  • edited 6:36PM

    Hi Lotje,

    That worked brilliantly! Thanks very much!

  • edited 6:36PM

    I am using this code to do something similar in my experiment. It does repeat the current trial but it also seems to leave off a trial at the end. That is if I have 10 questions, this will repeat say question 1 once but then only go to question 9. I assume this is because it is using up one of the predefined cycles to repeat this trial. Is there a way to hold this cycle constant until the trial has been answered successfully?

  • edited 6:36PM

    I am using this code to do something similar in my experiment. It does repeat the current trial but it also seems to leave off a trial at the end. That is if I have 10 questions, this will repeat say question 1 once but then only go to question 9. I assume this is because it is using up one of the predefined cycles to repeat this trial. Is there a way to hold this cycle constant until the trial has been answered successfully?

    Repeating a trial, as described above, shouldn't result in skipping another trial. So presumably something else is going wrong here. Could you describe in more detail how you have implemented this exactly?

    Cheers,
    Sebastiaan

  • edited 6:36PM

    Thanks for the reply. I have checked the sample code and indeed it doesn't do what my program is doing. I can't immediately see what the experiment is doing wrong but I'll keep analyzing it and report back if I find anything that might be helpful to others. For now, I've started with a fresh experiment and gotten it working correctly.

  • Hello! I am making a discrimination reversal task on a touch screen for dogs to participate in. It is a two choice task, with two stimlui being randomly presented together on the left and right side of the screen. The dog must learn to discriminate between the two objects to receive a food reward. I used the inline script given above to allow for a trial to repeated if a the subject makes an incorrect choice. However, I want to repeat a trial only once if they chose the wrong choice (or don't make a choice). So essentially it is giving the subject a second chance to choose or not choose the positive stimulus. So, for example, if the subject chooses the negative stimulus, the same trial (let's say with the negative stimulus on the left side and the positive stimulus on the right side) will be ran once before moving on two the next trial (which will present the neg stimulus and positive stimulus on the left or right side randomly). I am very new to opensesame and python so I am not sure how to code for this. Any help is greatly appreciated!!

  • Hi Jackie,

    I think a puppy deserves more than a single chance to right a wrong ;-) But to answer your question, I would write a simple inline_script that executes the trial_sequence again, but only if the response was incorrect and the trial was not repeated before.

    if not var.correct and not var.repeated:  # 0 == False
        var.repeated = 1
        items.execute('trial_sequence')
    

    This requires that the variable repeated is set to 0 in the block_loop.

    I attached a simple example experiment that illustrates the idea.

    Cheers!

    Sebastiaan


  • Hi Sebastiaan,


    It works perfectly! Thank you SO MUCH!!! The pups will appreciate it too :-)


    Jackie

  • Does anybody perhaps know how would the same code proposed by lvanderlinden look like in the inline Java script?:)

    Thank you!

  • Hi,


    "Translating" this piece of Python code to Java script is, unfortunately, not possible. This is because exp.items[] is not available in Java script.


    Is it necessary for your experiment to repeat an error trial immediately after participants made an incorrect response?


    If not, you could consider repeating the error trial(s) (if any) at the end of the block loop, by:

    • Appending a repeat cycle item to the end of your trial sequence
    • Setting the run-if statement to [correct] = 0


    I attached an example script. This should run on OSWeb as well. I hope this helps.


    Cheers,


    Lotje



    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