Move to Next Stimulus on Keypress

Home Forums Support Move to Next Stimulus on Keypress

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #2151
    Tim
    Guest

    Hello,

    I’m having trouble implementing a simple operation in which I remove a stimulus and advance to the next one when the participant presses a key. I understand that to do this, I need so specify ‘allowable’ keys as well and the ‘endAction’ that should happens when they are press (i.e., ‘TERMINATE’). However, this doesn’t seem to be working for me. Here’s my code for the ‘init’ question:

    QRTE.Init ({
    // +++++++++ Info necessary to properly initialize the library. DO NOT CHANGE +++++++++
    blockData: ‘${e://Field/QRTE_blockData}’,
    columnData: ‘${e://Field/QRTE_columns}’,
    idData: ‘${e://Field/QRTE_idData}’,
    exitQuestions: ‘${e://Field/QRTE_exitQuestions}’,
    // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

    // +++++++++ Info required to initialize the library, changes based on Survey configuration
    // Do change it when required!
    exitItemTag: ‘Exit’, //Refers to the ‘Exit’ question of this block. Remove < and > tags.
    //Enter the ‘item tag’, the tag that’s shown for the question
    //while looking at the qualtrics editor (this question’s tag is ‘Init’)

    blockId: “Trial_Block”, //Block Id, needs to be unique across blocks!
    onLoadFn: function () {
    QRTE.setConfig(‘Stimulus’,’Duration’,5000);
    QRTE.setConfig(‘Stimulus’,’Allowable’,’al’);
    QRTE.setConfig(‘Stimulus’, ‘EndAction’,’TERMINATE’);

    QRTE.setConfig(‘Feedback’,’Duration’,2000);
    QRTE.setConfig(‘Feedback’,’Allowable’,’ ‘);
    QRTE.setConfig(‘Feedback’, ‘EndAction’,’TERMINATE’);
    },
    interTrialDelay: [100],
    });

    What I’d like this code to do is make the ‘Stimulus’ item disappear after either the ‘a’ or ‘l’ key is pressed, and the ‘Feedback’ item disappear after the spacebar is pressed. However, neither item terminates after the allowable keys are pressed. Instead, they just remain on the screen for the specified and disappear after the time is up.

    What am I missing?

    #2153

    Hi Tim,

    Would it work if you use ‘endAction’ instead and also replace the capitals for the other properties? I thought Erwin made the config properties case-insensitive but I am not 100% sure. Also, did you perhaps have Caps Locks on? The allowable keys are definitively case-sensitive.

    Have you also labeled the screens with the correct stimulus ids?

    Hope that helps!

    Best, Henk

    #2159
    Tim
    Guest

    Hi Henk,

    Thanks for the quick reply. I’ve updated my code as you suggested, but still no luck. The same thing happens – the stimulus is presented for the full duration regardless of when and what buttons are pressed. I’ve also checked and the caps lock is not on. Note that in my experiment, there is no ‘correct’ response because people are making decisions based on preference. Do we HAVE to specify correct responses? I can arbitrarily specify one as ‘correct’ if necessary, but it makes no difference.

    Here is my new code:

    QRTE.Init ({
    // +++++++++ Info necessary to properly initialize the library. DO NOT CHANGE +++++++++
    blockData: ‘${e://Field/QRTE_blockData}’,
    columnData: ‘${e://Field/QRTE_columns}’,
    idData: ‘${e://Field/QRTE_idData}’,
    exitQuestions: ‘${e://Field/QRTE_exitQuestions}’,
    // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

    // +++++++++ Info required to initialize the library, changes based on Survey configuration
    // Do change it when required!
    exitItemTag: ‘Exit’, //Refers to the ‘Exit’ question of this block. Remove < and > tags.
    //Enter the ‘item tag’, the tag that’s shown for the question
    //while looking at the qualtrics editor (this question’s tag is ‘Init’)

    blockId: “Trial_Block”, //Block Id, needs to be unique across blocks!
    onLoadFn: function () {
    QRTE.setConfig(‘Stimulus’,’duration’,5000);
    QRTE.setConfig(‘Stimulus’,’allowable’,’al’);
    QRTE.setConfig(‘Stimulus’,’cresp’,’a’);
    QRTE.setConfig(‘Stimulus’, ‘endAction’,’terminate’);

    QRTE.setConfig(‘Feedback’,’duration’,2000);
    QRTE.setConfig(‘Feedback’,’allowable’,’ ‘);
    QRTE.setConfig(‘Stimulus’,’cresp’,’ ‘);
    QRTE.setConfig(‘Feedback’, ‘endAction’,’terminate’);
    },
    interTrialDelay: [100],
    });

    #2168

    Can you perhaps share a qsf file (e.g. link to dropbox) so that I can have a look what is going on. Correct response is not needed to be defined.

    best, Henk

    #2175
    Erwin Haasnoot
    Keymaster

    Hi Tim,

    A quick check in the source-code tells me that, although the config name is case-insensitive, the config value is not. See:

    https://github.com/ErwinHaasnoot/QRTEngine/blob/master/lib/QRTEngine.js#L941

    You need change all occurrences of ‘terminate’ to ‘TERMINATE’

    Best regards,

    Erwin

    #2189
    Tim
    Guest

    Hi Henk and Erwin,

    Thanks to you both for your replies. I have followed Erwin’s advice and changed the instances of ‘terminate’ to ‘TERMINATE’ and unfortunately am still getting the same issue. As Henk has suggested, I’ve provided a link to the .qsf file.

    https://www.dropbox.com/s/97eddo81uy51l1a/Plant_Task.qsf?dl=0

    Thanks again for all of your help.

    Cheers,
    Tim

    #2197

    Well, that looks like you know way more about JavaScript than I do. Do you actually need the engine if you are drawing stimuli yourself, like this? Perhaps the simple waitforkey command is sufficient in your case? Anyway, perhaps Erwin knows why it is not working. @Erwin, could you please have a look?

    Best, Henk

    #2224
    Tim
    Guest

    Hi Henk,

    After some playing around, I got it to work. I’m not really sure what I did. I suspect that I may have implemented Erwin’s suggestion incorrectly the first time. In any case, thanks for your help! And to answer your question, I quite like using the engine because once I program the stimuli, my students can take over and easily adapt the parameters of the experiment as they wish. Getting the stimuli in the first place has been the hard part!

    Cheers,
    Tim

    #2260
    Erwin Haasnoot
    Keymaster

    Hi Tim,

    Please note that the OnShow function is called AFTER the display stimulus is intended to be shown. This means that very heavy computations in the OnShow function can significantly alter the accuracy of the RT (as this is based on the current time against the Stimulus OnsetTime).

    As a rule of thumb, I would say that a calculation that takes more than 8 ms is unwanted, anything below should be fine in 99.9% of the cases. You can measure how long your function takes to see if it would alter the accuracy very much.

    Best regards,

    Erwin

Viewing 9 posts - 1 through 9 (of 9 total)
  • The forum ‘Support’ is closed to new topics and replies.