Displaying RT data after each trial

Home Forums Support Displaying RT data after each trial

  • This topic has 6 replies, 2 voices, and was last updated 8 years, 1 month ago by Discount True Religion.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #1969
    Becky
    Guest

    Dear QRTEngine forum,

    I’m working on a Qualtrics/QRTEngine experiment where I’d like to display the reaction times after each response. I’ve looked at the tutorial on conditional stimuli, which is very helpful. However the tutorial appears to only explain how to present stimuli based on booleans. For example, ‘return QRTE.getTrialData(“PressKey[RT]”) > 2000;’ presents a stimulus if statement evaluates to TRUE (i.e. response is longer than 2 seconds), otherwise nothing is presented. The tutorial does not say how to dynamically change the stimuli text based on the actual RT (or key press, etc.).

    Is it possible ‘pipe’ data from each trial, such as the RT, into a feedback stimulus? I’m guessing this would use the QRTE.getTrialData() method? If someone could explain or write a quick example of the code for this, I would really appreciate it!

    Thanks,
    Becky

    #1974
    Erwin Haasnoot
    Keymaster

    Hi Becky,

    Good question. In technical terms this is called “view binding” or “one-way binding”. If a value of a variable changes, update it in the corresponding element that’s being viewed. (As opposed to two-way binding, where if a view is updated, the corresponding variable (model) is updated as well) Currently one-way binding is not supported in the QRTEngine, so your best bet would be to build your own JS/HTML solution. The trick would be to use a combination of HTML and JS to update your value upon showing the stimulus, the simplest form would be the following:

    In your HTML View, add an element with a specific ID (important!). For example:

    <div id="CustomElement"></div>

    The onShowFn in the Stimulus JS is a function that gets called upon the stimulus being shown (or rather, right before its shown). This would be the ideal place to put a bit a code that changes the innerHTML of the HTML element we just defined.

    We can target the element as defined above, with the JS defined below:

    $('CustomElement').innerHTML = 'testtext';

    This would change the contents of the HTML element to ‘testtext’.

    Instead of using the ‘testtext’ as, you want to use the RT instead. Which would be the following:

    $('CustomElement').innerHTML = QRTE.getTrialData(“PressKey[RT]”);

    If placed in the correct question, this should update the content of our CustomElmement to the RT of the PressKey stimulus.

    Hope this helps!

    Best,

    Erwin

    #1985
    Becky
    Guest

    Hi Erwin,

    Thanks so much for this explanation – it’s super helpful!

    I was able to replace the innerHTML with ‘testtext’ but when I tried to do this with the trial RT, the text shown on the screen was “undefined”. I suppose this is because something is wrong with my use of getTrialData(), or because “PressKey[RT]” hadn’t been defined at the time the getTrialData function was called (i.e. at the time that the onShowFn() function ran for my RT feedback stimulus).

    Do you have any thoughts as to why this is happening? I tried adding a 1000 ms blank interval between the RT stimulus and the RT feedback questions, thinking that perhaps there needed to be a buffer between the key response and when the getTrialData function was called, but this didn’t solve the problem.

    Thanks again for your help!

    Best,
    Becky

    #1986
    Erwin Haasnoot
    Keymaster

    Hi Becky,

    The “PressKey” part is the ID of the stimulus, not some kind of magic value that gets the RT of any stimulus. So you would either need a stimulus with PressKey as ID (which you can change in the JavaScript of said stimulus), or you would need to change PressKey to something else in the JavaScript I posted. Hopefully you’ll be able to figure it out from here!

    Best regards,

    Erwin

    #1989
    Becky
    Guest

    Hi Erwin,

    Got it working, thanks very much!

    I’ll add my experiment to your Experiments forum to share with others.

    Becky

    #2193
    Becky
    Guest

    Hi Erwin and forum,

    I’ve been using the $('CustomElement').innerHTML" method for dynamically changing the text of a stimulus, however when I use this the text formatting specified within <div id="CustomElement"></div> seems to be ignored. Is there another way to control the text formatting in this situation? For instance, in the JavaScript for the question, are there other methods I can use on $('CustomElement') to control the formatting?

    Thanks!
    Becky

    #3579
    Discount True Religion
    Guest

    I enjoy the efforts you have put in this, thanks for all the great posts.

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