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