Code Monkey home page Code Monkey logo

gorillafy's Introduction

Gorillafy

gorillafy is a tool for turning HTML/JavaScript experiments into tasks on Gorilla.sc, via the Gorilla Code Editor.

To install, run

pip install git+https://github.com/EoinTravers/Gorillafy

To use it at the command line, run

gorillafy path/to/Experiment/

replacing path/to/Experiment/ with the directory of your experiment.

You can try it out by downloading this repository and gorillafying the Flanker/ demo experiment:

gorillafy Flanker/

To gorillafy your own experiment, you'll need to follow a few simple conventions when building them. See the demo experiment in the Flanker/ folder for an example.

Directory structure

  • index.html: Your experiment's HTML page.
  • js/: JavaScript code for your experiment, split into
    • main.js: The main logic of the experiment, and
    • utils.js: Useful utility functions.
  • style/main.css: The CSS for your experiment.
  • libs/: JavaScript and CSS libraries used in your experiment (e.g. lodash, jQuery).
  • stimuli/: Any media (images, etc.) used in the experiment.

In index.html, wrap all of your experiment content inside a <div> tag with ID gorilla. Everything inside this tag will be copied to Gorilla.

In main.js, you'll see that all of the information want to log on each trial is stored in a single global variable, state, defined at the start of the file:

let state = {
    width: null,
    height: null,
    subject_nr: get_subject_nr(),
    target_size: null, // Between-subject manipulation
    trial_nr: 0,
    t_start_experiment: null,
    t_start_trial: null,
    t_response: null,
    target_right: null,
    flanker_right: null,
    response: null,
    said_right: null,
    rt: null,
    accuracy: null
};

gorillafy will use the the keys defined here to tell Gorilla what metrics it should record.

primate.js

primate.js is a simple JavaScript package that provides the same functions as the Gorilla API. When run on the Gorilla platform, primate.js just calls the corresponding Gorilla functions, and provides some useful output for debugging. When run on a normal web page, it provides alternatives for these functions, for instance allowing you to send data to the server. This means you can run exactly the same code on and off Gorilla. See the Flanker demo for examples.

gorillafy's People

Contributors

eointravers avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.