Guide to childlanglab

Workflow for hosting jspsych experiments with github pages

Purpose

To provide a workflow to host jspsych experiments simply via github pages and push data to our database

Procedure

Prerequisites
  1. Program your experiment with jspsych
  2. Add your experiment to an empty github repo (use pennchildlanglab for lab experiments)
Host on github pages
  1. Go to Settings > Pages
  2. Under Build and deployment source select Deploy from a branch
  3. Under Build and deployment branch select main and /root
  4. At the top you’ll see where your site is live (e.g. https://pennchildlanglab.github.io/penguin-lexical-decision/)
Push data to lab database
  1. Add the following <script> tags to your html header

    /* add the call function jspsych plugin*/
     <script src="https://unpkg.com/@jspsych/plugin-call-function@1.1.3"></script>
    /* add the childlanglabClient to push to database */
     <script src="https://nyc3.digitaloceanspaces.com/experiments.childlanglab/childlanglabClient.js"></script>
    
  2. Add the following jsPsych call function to your code

    var sendData = {
       type: jsPsychCallFunction,
       async: true,
       func: function (done) {
         let data = jsPsych.data.get().json();
         childlanglabClient.sendData(data);
         done("Sent data object to childlanglab-api")
        
       },
     };
    
  3. In your jsPsych timeline, call the sendData function at the end of your experiment (but before your thanks screen and prolific redirect)

    /* create timeline */
      var timeline = [
        consent, 
        welcome,
        preload,
        instructions,
        sendData,   // add send data here 
        thanks
      ];
      /* start the experiment */
      jsPsych.run(timeline);
    
  4. Add your experiment to the lab database
    • Under an existing experiment, you can add a + New Version to add a new version of your experiment
    • Or you can create a new experiment and then add + New Version once created
    • You add the path to your experiment (e.g. https://pennchildlanglab.github.io/penguin-lexical-decision/experiment.html) without URL variables
  5. Use the Run experiment button on your experiment’s page in the database to run your experiment

FAQ