This topic contains 6 replies, has 2 voices, and was last updated by Discount True Religion 5 years, 4 months ago.
March 30, 2015 at 11:54 am #1969
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!
BeckyMarch 30, 2015 at 3:49 pm #1974
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:
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!
ErwinApril 1, 2015 at 8:48 am #1985
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!
BeckyApril 1, 2015 at 8:58 am #1986
ErwinApril 1, 2015 at 9:38 am #1989
Got it working, thanks very much!
I’ll add my experiment to your Experiments forum to share with others.
BeckyApril 20, 2015 at 1:57 pm #2193
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
$('CustomElement')to control the formatting?
BeckyJuly 30, 2015 at 8:39 pm #3579
Discount True Religion
I enjoy the efforts you have put in this, thanks for all the great posts.
The forum ‘Support’ is closed to new topics and replies.