Build the experiment files
build_experiment( timeline, path, experiment_folder = "experiment", data_folder = "data", experiment_title = NULL, jsPsych_path = file.path(system.file("extdata", "jsPsych", package = "jaysire")), resources = NULL, columns = NULL, ... )
A timeline object
A string specifying the path in which to build the experiment
A string specifying the experiment subfolder
A string specifying the data subfolder
A string specifying the title of the experiment
A string specifying the path to jsPsych
A tibble specifying how to construct resource files, or NULL
Additional data values (constants) to store
Arguments to pass to jsPsych.init()
build_experiment() function is used to build the actual jsPsych
experiment from the abstract description contained in the
The input for the
timeline argument should be a timeline constructed using
build_timeline() and the
path argument should specify the
path to the folder in which the experiment files should be created. If the
experiment needs to rely on resource files (e.g., images, audio files etc) then
resources argument should be a tibble containing the information needed
to copy those files to the appropriate location. The easiest way to do so is by
build_resources() function: see the documentation for that
function for a more detailed description of what this tibble should contain.
When called, the
build_experiment() function writes all the experiment files,
path folder are two subfolders,
experiment_folder (named "data" and "experiment" by default). The
data_folder folder is empty, but intended to serve as a location to which
data files can be written. The
experiment_folder folder contains the
"index.html" file, which is the primary source file for the experiment page, and an
"experiment.js" file that specifies the jsPsych timeline and calls the
contains a "resource" folder with other necessary files (see
build_resources() for detail). If specified,
will set the name of the experiment as the title of the HTML file in "index.html".
jsPsych_path is a string that specifies the path to jsPsych.
build_experiment() creates the call to jsPsych.init(), it can also
be used to specify any parameters that the user may wish to pass to that function
.... There are quite a number of parameters you can specify this way:
display_element is a string specifying the ID of an HTML element
to display the experiment in. If left blank, jsPsych will use the <body> element
to display content. All keyboard event listeners are bound to this element. In
order for a keyboard event to be detected, this element must have focus (be the
last thing that the subject clicked on).
ends. It can be constructed manually using
in many cases there is a jaysire function that will create the appropriate function
for you. For example, if you want the data to be saved locally at the end of the
experiment you can set
on_finish = save_locally(), whereas if you
want the data to be saved to the Google Datastore you can set
on_finish = save_googlecloud().
every time data is stored within the jsPsych internal storage.
every time a new interaction event occurs. Interaction events include clicking
on a different window (blur), returning to the experiment window (focus),
entering full screen mode (fullscreenenter), and exiting full screen mode
leaves the page. This can be used, for example, to ensure that data are saved
before the page is closed.
exclusions is used to specify restrictions on the browser the
subject can use to complete the experiment. See list of options below.
a progress bar is shown at the top of the page.
message_progress_bar is a string containing a message to display
next to the progress bar. The default is 'Completion Progress'.
then the progress bar at the top of the page will automatically update as
every top-level timeline or trial is completed.
then a progress bar is displayed while media files are automatically preloaded.
starting the experiment.
before starting the experiment.
before starting the experiment.
max_load_time is a numeric value specifying the maximum number
of milliseconds to wait for content to preload. If the wait time is exceeded
an error message is displayed and the experiment stops. The default value is
max_preload_attempts is numeric value specifying the maximum
number of attempts to preload each file in case of an error. The default
value is 10. There is a small delay of 200ms between each attempt.
not attempt to use the WebAudio API for audio playback. Instead, HTML5 Audio
objects will be used. The WebAudio API offers more precise control over the
timing of audio events, and should be used when possible. The default value
default_iti is a numeric value setting the default inter-trial
interval in milliseeconds. The default value if none is specified is 0.
experiment_width is a numeric value setting the desired width
of the jsPsych container in pixels. If left undefined, the width will be
100% of the display element. Usually this is the <body> element, and the
width will be 100% of the screen size.
Note: as of the current writing not all of these have been tested (even informally) through jaysire. Please report any unexpected behaviour by opening an issue on the GitHub page.