exbuilder
Search
K
Comment on page

Experiments

The experiments folder contains (1) an exbuilder folder, which holds on to some helpful JavaScript and php code to help you write data to exbuilder's database, (2) two sample jsPsych experiments, and (3) an index.html landing page with accompanying config-exbuilder.json file to help you generate URL variables for your experiment.

The exbuilder folder

The exbuilder folder contains JavaScript and php code to handle some of the server-side stuff like saving data to exbuilder's database. There are three different .js files available . Each has their own reference page:

The sample jsPsych experiments

exbuilder's experiments folder also comes with two sample experiments experiment1-jspsych and experiment2-jspsych-record to serve as a model for how to use exbuilder with jsPsych experiments.

Add JavaScript to your experiment.html file

The first step is to add a line to your html file
<script src="../exbuilder/js/exbuilder.js"></script> <!-- EXBUILDER JS -->

Write data to exbuilder's database

To write jsPsych data to exbuilder's database, you'll need to initialize exbuilder somewhere near the begining of your code
Exbuilder.init()
And then insert the run into the database. Typically you use this only once per "run" of the experiment (once per participant). In the example experiment (experiment1-jspsych), we do this after the welcome message.
/* define welcome message trial */
var welcome = {
type: "html-keyboard-response",
stimulus: "Welcome to the experiment. Press any key to begin.",
on_finish: function(){
Exbuilder.insertRun(); // ADDS RUN TO EXBUILDER'S DATABASE
}
};
Finally, you'll want to update the run in the database with the jsPsych data. The data passed in with the data argument must be a JSON object. You can do this after every trial or at the end of the experiment. In the example, we push the jsPsych data at the end of the experiment.
/* start the experiment */
jsPsych.init({
timeline: timeline,
on_finish: function() {
Exbuilder.updateRun(jsPsych.data.get().json()); // ADDS STUDY DATA TO RUN IN EXBUILDER DATABASE
jsPsych.data.displayData();
}
});

Push audio recordings to an S3 bucket

The URL generator

exbuilder also comes with an index.html file that serves as a URL generator for your experiments. This is designed to make it easy for you to generate a URL for your experiment (passing URL variables is required to write to exbuilder's database). You can use the config-exbuilder.json file to constrain the values you or your research assistants can select.

Deployment

When you've finished developing your experiment local and you are ready to deploy your experiment to the web, you can follow these instructions: