On QRTEngine JavaScript, part 1

So you’ve just made your first task using the QRTEngine and our beginner’s tutorial and you’re hungry for more? Good! This series of tutorials will explain in more detail what exactly you did that made Qualtrics in combination with the QRTEngine perform a Stroop Task.  Specifically, what was all the JavaScript code that you copied into your survey? Hopefully you’ll come out of it with a deeper understanding of the inner and outer processes of the QRTEngine + Qualtrics, allowing you to build increasingly more complex tasks with the method.  The first instalment of this series will be concerned with explaining the structure of a ‘trial block’, whereas the next parts will be concerned with explaining what each necessary component of a trial block details.

Basic Task Structure

First off, we need to refer back to the figure from our paper, specifically part C.  See below.

Part C of Tutorial Figure

Upon first viewing the figure, I assume the JavaScript must have looked pretty scary and upon viewing it now, it probably still looks the part (but maybe less so).  Not to worry! We will go over all of it. First off, note the first line of each code block in part C. In order:

QRTE.Stimulus (3 times)

Init, Stimulus and Exit are so-called methods of the JavaScript Object QRTE and the stuff between { and } is the object parameter, which is an argument to the method. If this all sounds complicated, don’t worry! The methods can be thought of as ‘tags’ for the Qualtrics Question that it’s associated with, effectively tagging the question to be processed with the QRTEngine. Depending on the method being called (init, stimulus or exit). The parameter object being given along to the method determines in more detail how the question should behave.

Question ‘tags’

Glossing over each type of ‘tag’ in use, one will find that for all trial blocks (in the Stroop Task, but also in the Skeleton task and/or any derivatives), exactly one Init and exactly one Exit question is use. Next to that, any amount of Stimulus questions are permissible to be used inside a trial block. The most basic reason for this structure is that the QRTEngine needs to know when the trial block starts and when it ends, in the process it doesn’t care about the amount of stimuli in a given trial. In the Attentional Blink Task <Link to it!> we made available for download you will find a trial block with many stimuli between the Init and Exit questions.

Init thus marks the start of the trial block and it triggers the QRTEngine to initialize the trial, whereas Exit marks the end and QRTEngine exits the trial (when exiting it stores the current trial’s data). Between the Init and the Exit the QRTEngine, by default, works through each Stimulus question one by one, in a serial manner. Only displaying the next stimulus when the current stimulus has been disabled (nb, a quick tutorial has been written on how to make multiple stimuli active at the same time, click here).

This concludes part 1 of the On QRTEngine JavaScript series. Part 2 will discuss in more detail what happens after a question is marked Stimulus, or rather when the Stimulus method is called. Part 3 will then discuss in more detail what happens after the Init and Exit methods are called.

Thanks for reading!


Leave a Reply

